llvm.org GIT mirror llvm / 6a9506a
Merging r227005: ------------------------------------------------------------------------ r227005 | dsanders | 2015-01-24 14:35:11 +0000 (Sat, 24 Jan 2015) | 38 lines [mips] Fix 'jumpy' debug line info around calls. Summary: At the moment, address calculation is taking the debug line info from the address node (e.g. TargetGlobalAddress). When a function is called multiple times, this results in output of the form: .loc $first_call_location .. address calculation .. .. function call .. .. address calculation .. .loc $second_call_location .. function call .. .loc $first_call_location .. address calculation .. .loc $third_call_location .. function call .. This patch makes address calculations for function calls take the debug line info for the call node and results in output of the form: .loc $first_call_location .. address calculation .. .. function call .. .loc $second_call_location .. address calculation .. .. function call .. .loc $third_call_location .. address calculation .. .. function call .. All other address calculations continue to use the address node. Test Plan: Fixes test/DebugInfo/multiline.ll on a mips host. Subscribers: dblaikie, llvm-commits Differential Revision: http://reviews.llvm.org/D7050 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@227193 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 4 years ago
4 changed file(s) with 124 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
496496 SDValue JumpTarget = Callee;
497497
498498 // T9 should contain the address of the callee function if
499 // -reloction-model=pic or it is an indirect call.
499 // -relocation-model=pic or it is an indirect call.
500500 if (IsPICCall || !GlobalOrExternal) {
501501 unsigned V0Reg = Mips::V0;
502502 if (NeedMips16Helper) {
503503 RegsToPass.push_front(std::make_pair(V0Reg, Callee));
504504 JumpTarget = DAG.getExternalSymbol(Mips16HelperFunction, getPointerTy());
505505 ExternalSymbolSDNode *S = cast(JumpTarget);
506 JumpTarget = getAddrGlobal(S, JumpTarget.getValueType(), DAG,
506 JumpTarget = getAddrGlobal(S, CLI.DL, JumpTarget.getValueType(), DAG,
507507 MipsII::MO_GOT, Chain,
508508 FuncInfo->callPtrInfo(S->getSymbol()));
509509 } else
16121612
16131613 if (TLOF.IsGlobalInSmallSection(GV, getTargetMachine()))
16141614 // %gp_rel relocation
1615 return getAddrGPRel(N, Ty, DAG);
1615 return getAddrGPRel(N, SDLoc(N), Ty, DAG);
16161616
16171617 // %hi/%lo relocation
1618 return getAddrNonPIC(N, Ty, DAG);
1618 return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
16191619 }
16201620
16211621 if (GV->hasInternalLinkage() || (GV->hasLocalLinkage() && !isa(GV)))
1622 return getAddrLocal(N, Ty, DAG,
1622 return getAddrLocal(N, SDLoc(N), Ty, DAG,
16231623 Subtarget.isABI_N32() || Subtarget.isABI_N64());
16241624
16251625 if (LargeGOT)
1626 return getAddrGlobalLargeGOT(N, Ty, DAG, MipsII::MO_GOT_HI16,
1626 return getAddrGlobalLargeGOT(N, SDLoc(N), Ty, DAG, MipsII::MO_GOT_HI16,
16271627 MipsII::MO_GOT_LO16, DAG.getEntryNode(),
16281628 MachinePointerInfo::getGOT());
16291629
1630 return getAddrGlobal(N, Ty, DAG,
1630 return getAddrGlobal(N, SDLoc(N), Ty, DAG,
16311631 (Subtarget.isABI_N32() || Subtarget.isABI_N64())
16321632 ? MipsII::MO_GOT_DISP
16331633 : MipsII::MO_GOT16,
16411641
16421642 if (getTargetMachine().getRelocationModel() != Reloc::PIC_ &&
16431643 !Subtarget.isABI_N64())
1644 return getAddrNonPIC(N, Ty, DAG);
1645
1646 return getAddrLocal(N, Ty, DAG,
1644 return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
1645
1646 return getAddrLocal(N, SDLoc(N), Ty, DAG,
16471647 Subtarget.isABI_N32() || Subtarget.isABI_N64());
16481648 }
16491649
17341734
17351735 if (getTargetMachine().getRelocationModel() != Reloc::PIC_ &&
17361736 !Subtarget.isABI_N64())
1737 return getAddrNonPIC(N, Ty, DAG);
1738
1739 return getAddrLocal(N, Ty, DAG,
1737 return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
1738
1739 return getAddrLocal(N, SDLoc(N), Ty, DAG,
17401740 Subtarget.isABI_N32() || Subtarget.isABI_N64());
17411741 }
17421742
17531753
17541754 if (TLOF.IsConstantInSmallSection(N->getConstVal(), getTargetMachine()))
17551755 // %gp_rel relocation
1756 return getAddrGPRel(N, Ty, DAG);
1757
1758 return getAddrNonPIC(N, Ty, DAG);
1759 }
1760
1761 return getAddrLocal(N, Ty, DAG,
1756 return getAddrGPRel(N, SDLoc(N), Ty, DAG);
1757
1758 return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
1759 }
1760
1761 return getAddrLocal(N, SDLoc(N), Ty, DAG,
17621762 Subtarget.isABI_N32() || Subtarget.isABI_N64());
17631763 }
17641764
26802680 InternalLinkage = Val->hasInternalLinkage();
26812681
26822682 if (InternalLinkage)
2683 Callee = getAddrLocal(G, Ty, DAG,
2683 Callee = getAddrLocal(G, DL, Ty, DAG,
26842684 Subtarget.isABI_N32() || Subtarget.isABI_N64());
26852685 else if (LargeGOT) {
2686 Callee = getAddrGlobalLargeGOT(G, Ty, DAG, MipsII::MO_CALL_HI16,
2686 Callee = getAddrGlobalLargeGOT(G, DL, Ty, DAG, MipsII::MO_CALL_HI16,
26872687 MipsII::MO_CALL_LO16, Chain,
26882688 FuncInfo->callPtrInfo(Val));
26892689 IsCallReloc = true;
26902690 } else {
2691 Callee = getAddrGlobal(G, Ty, DAG, MipsII::MO_GOT_CALL, Chain,
2691 Callee = getAddrGlobal(G, DL, Ty, DAG, MipsII::MO_GOT_CALL, Chain,
26922692 FuncInfo->callPtrInfo(Val));
26932693 IsCallReloc = true;
26942694 }
27012701 const char *Sym = S->getSymbol();
27022702
27032703 if (!Subtarget.isABI_N64() && !IsPIC) // !N64 && static
2704 Callee = DAG.getTargetExternalSymbol(Sym, getPointerTy(),
2705 MipsII::MO_NO_FLAG);
2704 Callee =
2705 DAG.getTargetExternalSymbol(Sym, getPointerTy(), MipsII::MO_NO_FLAG);
27062706 else if (LargeGOT) {
2707 Callee = getAddrGlobalLargeGOT(S, Ty, DAG, MipsII::MO_CALL_HI16,
2707 Callee = getAddrGlobalLargeGOT(S, DL, Ty, DAG, MipsII::MO_CALL_HI16,
27082708 MipsII::MO_CALL_LO16, Chain,
27092709 FuncInfo->callPtrInfo(Sym));
27102710 IsCallReloc = true;
27112711 } else { // N64 || PIC
2712 Callee = getAddrGlobal(S, Ty, DAG, MipsII::MO_GOT_CALL, Chain,
2712 Callee = getAddrGlobal(S, DL, Ty, DAG, MipsII::MO_GOT_CALL, Chain,
27132713 FuncInfo->callPtrInfo(Sym));
27142714 IsCallReloc = true;
27152715 }
271271 //
272272 // (add (load (wrapper $gp, %got(sym)), %lo(sym))
273273 template
274 SDValue getAddrLocal(NodeTy *N, EVT Ty, SelectionDAG &DAG,
274 SDValue getAddrLocal(NodeTy *N, SDLoc DL, EVT Ty, SelectionDAG &DAG,
275275 bool IsN32OrN64) const {
276 SDLoc DL(N);
277276 unsigned GOTFlag = IsN32OrN64 ? MipsII::MO_GOT_PAGE : MipsII::MO_GOT;
278277 SDValue GOT = DAG.getNode(MipsISD::Wrapper, DL, Ty, getGlobalReg(DAG, Ty),
279278 getTargetNode(N, Ty, DAG, GOTFlag));
290289 // computing a global symbol's address:
291290 //
292291 // (load (wrapper $gp, %got(sym)))
293 template
294 SDValue getAddrGlobal(NodeTy *N, EVT Ty, SelectionDAG &DAG,
292 template
293 SDValue getAddrGlobal(NodeTy *N, SDLoc DL, EVT Ty, SelectionDAG &DAG,
295294 unsigned Flag, SDValue Chain,
296295 const MachinePointerInfo &PtrInfo) const {
297 SDLoc DL(N);
298296 SDValue Tgt = DAG.getNode(MipsISD::Wrapper, DL, Ty, getGlobalReg(DAG, Ty),
299297 getTargetNode(N, Ty, DAG, Flag));
300298 return DAG.getLoad(Ty, DL, Chain, Tgt, PtrInfo, false, false, false, 0);
304302 // computing a global symbol's address in large-GOT mode:
305303 //
306304 // (load (wrapper (add %hi(sym), $gp), %lo(sym)))
307 template
308 SDValue getAddrGlobalLargeGOT(NodeTy *N, EVT Ty, SelectionDAG &DAG,
309 unsigned HiFlag, unsigned LoFlag,
310 SDValue Chain,
305 template
306 SDValue getAddrGlobalLargeGOT(NodeTy *N, SDLoc DL, EVT Ty,
307 SelectionDAG &DAG, unsigned HiFlag,
308 unsigned LoFlag, SDValue Chain,
311309 const MachinePointerInfo &PtrInfo) const {
312 SDLoc DL(N);
313 SDValue Hi = DAG.getNode(MipsISD::Hi, DL, Ty,
314 getTargetNode(N, Ty, DAG, HiFlag));
310 SDValue Hi =
311 DAG.getNode(MipsISD::Hi, DL, Ty, getTargetNode(N, Ty, DAG, HiFlag));
315312 Hi = DAG.getNode(ISD::ADD, DL, Ty, Hi, getGlobalReg(DAG, Ty));
316313 SDValue Wrapper = DAG.getNode(MipsISD::Wrapper, DL, Ty, Hi,
317314 getTargetNode(N, Ty, DAG, LoFlag));
323320 // computing a symbol's address in non-PIC mode:
324321 //
325322 // (add %hi(sym), %lo(sym))
326 template
327 SDValue getAddrNonPIC(NodeTy *N, EVT Ty, SelectionDAG &DAG) const {
328 SDLoc DL(N);
323 template
324 SDValue getAddrNonPIC(NodeTy *N, SDLoc DL, EVT Ty,
325 SelectionDAG &DAG) const {
329326 SDValue Hi = getTargetNode(N, Ty, DAG, MipsII::MO_ABS_HI);
330327 SDValue Lo = getTargetNode(N, Ty, DAG, MipsII::MO_ABS_LO);
331328 return DAG.getNode(ISD::ADD, DL, Ty,
337334 // computing a symbol's address using gp-relative addressing:
338335 //
339336 // (add $gp, %gp_rel(sym))
340 template
341 SDValue getAddrGPRel(NodeTy *N, EVT Ty, SelectionDAG &DAG) const {
342 SDLoc DL(N);
337 template
338 SDValue getAddrGPRel(NodeTy *N, SDLoc DL, EVT Ty, SelectionDAG &DAG) const {
343339 assert(Ty == MVT::i32);
344340 SDValue GPRel = getTargetNode(N, Ty, DAG, MipsII::MO_GPREL);
345341 return DAG.getNode(ISD::ADD, DL, Ty,
0 ; RUN: llc -mtriple=mips-linux-gnu -filetype=asm -asm-verbose=0 -O0 < %s | FileCheck %s
1 ; RUN: llc -mtriple=mips-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=line - | FileCheck %s --check-prefix=INT
2
3 ; Mips used to generate 'jumpy' debug line info around calls. The address
4 ; calculation for each call to f1() would share the same line info so it would
5 ; emit output of the form:
6 ; .loc $first_call_location
7 ; .. address calculation ..
8 ; .. function call ..
9 ; .. address calculation ..
10 ; .loc $second_call_location
11 ; .. function call ..
12 ; .loc $first_call_location
13 ; .. address calculation ..
14 ; .loc $third_call_location
15 ; .. function call ..
16 ; ...
17 ; which would cause confusing stepping behaviour for the end user.
18 ;
19 ; This test checks that we emit more user friendly debug line info of the form:
20 ; .loc $first_call_location
21 ; .. address calculation ..
22 ; .. function call ..
23 ; .loc $second_call_location
24 ; .. address calculation ..
25 ; .. function call ..
26 ; .loc $third_call_location
27 ; .. address calculation ..
28 ; .. function call ..
29 ; ...
30 ;
31 ; Generated with clang from fn-call-line.c:
32 ; void f1();
33 ; void f2() {
34 ; f1();
35 ; f1();
36 ; }
37
38 ; CHECK: .loc 1 3 3
39 ; CHECK-NOT: .loc
40 ; CHECK: %call16(f1)
41 ; CHECK-NOT: .loc
42 ; CHECK: .loc 1 4 3
43 ; CHECK-NOT: .loc
44 ; CHECK: %call16(f1)
45
46 ; INT: {{^}}Address
47 ; INT: -----
48 ; INT-NEXT: 2 0 1 0 0 is_stmt{{$}}
49 ; INT-NEXT: 3 3 1 0 0 is_stmt prologue_end{{$}}
50 ; INT-NEXT: 4 3 1 0 0 is_stmt{{$}}
51
52
53 ; Function Attrs: nounwind uwtable
54 define void @f2() #0 {
55 entry:
56 call void (...)* @f1(), !dbg !11
57 call void (...)* @f1(), !dbg !12
58 ret void, !dbg !13
59 }
60
61 declare void @f1(...) #1
62
63 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
64 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
65
66 !llvm.dbg.cu = !{!0}
67 !llvm.module.flags = !{!8, !9}
68 !llvm.ident = !{!10}
69
70 !0 = !{!"0x11\0012\00clang version 3.7.0 (trunk 226641)\000\00\000\00\001", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/fn-call-line.c] [DW_LANG_C99]
71 !1 = !{!"fn-call-line.c", !"/tmp/dbginfo"}
72 !2 = !{}
73 !3 = !{!4}
74 !4 = !{!"0x2e\00f2\00f2\00\002\000\001\000\000\000\000\002", !1, !5, !6, null, void ()* @f2, null, null, !2} ; [ DW_TAG_subprogram ] [line 2] [def] [f2]
75 !5 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/fn-call-line.c]
76 !6 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
77 !7 = !{null}
78 !8 = !{i32 2, !"Dwarf Version", i32 4}
79 !9 = !{i32 2, !"Debug Info Version", i32 2}
80 !10 = !{!"clang version 3.7.0 (trunk 226641)"}
81 !11 = !MDLocation(line: 3, column: 3, scope: !4)
82 !12 = !MDLocation(line: 4, column: 3, scope: !4)
83 !13 = !MDLocation(line: 5, column: 1, scope: !4)