llvm.org GIT mirror llvm / 8478c82
[BasicBlockUtils] Set debug locations for instructions created in SplitBlockPredecessors. Test Plan: regression test suite Reviewers: eugenis, dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10343 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239438 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 4 years ago
3 changed file(s) with 95 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
485485 }
486486
487487 // Create new basic block, insert right before the original block.
488 BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), BB->getName()+Suffix,
489 BB->getParent(), BB);
488 BasicBlock *NewBB = BasicBlock::Create(
489 BB->getContext(), BB->getName() + Suffix, BB->getParent(), BB);
490490
491491 // The new block unconditionally branches to the old block.
492492 BranchInst *BI = BranchInst::Create(BB, NewBB);
493 BI->setDebugLoc(BB->getFirstNonPHI()->getDebugLoc());
493494
494495 // Move the edges from Preds to point to NewBB instead of BB.
495496 for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
552553
553554 // The new block unconditionally branches to the old block.
554555 BranchInst *BI1 = BranchInst::Create(OrigBB, NewBB1);
556 BI1->setDebugLoc(OrigBB->getFirstNonPHI()->getDebugLoc());
555557
556558 // Move the edges from Preds to point to NewBB1 instead of OrigBB.
557559 for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
592594
593595 // The new block unconditionally branches to the old block.
594596 BranchInst *BI2 = BranchInst::Create(OrigBB, NewBB2);
597 BI2->setDebugLoc(OrigBB->getFirstNonPHI()->getDebugLoc());
595598
596599 // Move the remaining edges from OrigBB to point to NewBB2.
597600 for (SmallVectorImpl::iterator
143143 PreheaderBB = SplitBlockPredecessors(Header, OutsideBlocks, ".preheader",
144144 AA, DT, LI, PreserveLCSSA);
145145
146 PreheaderBB->getTerminator()->setDebugLoc(
147 Header->getFirstNonPHI()->getDebugLoc());
148146 DEBUG(dbgs() << "LoopSimplify: Creating pre-header "
149147 << PreheaderBB->getName() << "\n");
150148
0 ; Check that LoopSimplify creates debug locations in synthesized basic blocks.
1 ; RUN: opt -loop-simplify %s -S -o - | FileCheck %s
2
3 %union.anon = type { i32 }
4 %"Length" = type <{ %union.anon, i8, i8, i8, i8 }>
5 declare void @bar(%"Length"*) #3
6 @catchtypeinfo = external unnamed_addr constant { i8*, i8*, i8* }
7 declare i32 @__gxx_personality_v0(...)
8 declare void @f1()
9 declare void @f2()
10 declare void @f3()
11
12 ; CHECK-LABEL: @foo
13 ; CHECK: for.body.preheader:
14 ; CHECK-NEXT: br label %for.body, !dbg [[PREHEADER_LOC:![0-9]+]]
15 ; CHECK: for.end.loopexit:
16 ; CHECK-NEXT: br label %for.end, !dbg [[LOOPEXIT_LOC:![0-9]+]]
17
18 define linkonce_odr hidden void @foo(%"Length"* %begin, %"Length"* %end) nounwind ssp uwtable align 2 {
19 entry:
20 %cmp.4 = icmp eq %"Length"* %begin, %end, !dbg !7
21 br i1 %cmp.4, label %for.end, label %for.body, !dbg !8
22
23 for.body: ; preds = %entry, %length.exit
24 %begin.sink5 = phi %"Length"* [ %incdec.ptr, %length.exit ], [ %begin, %entry ]
25 %m_type.i.i.i = getelementptr inbounds %"Length", %"Length"* %begin.sink5, i64 0, i32 2, !dbg !9
26 %0 = load i8, i8* %m_type.i.i.i, align 1, !dbg !9
27 %cmp.i.i = icmp eq i8 %0, 9, !dbg !7
28 br i1 %cmp.i.i, label %if.then.i, label %length.exit, !dbg !8
29
30 if.then.i: ; preds = %for.body
31 tail call void @bar(%"Length"* %begin.sink5) #7, !dbg !10
32 br label %length.exit, !dbg !10
33
34 length.exit: ; preds = %for.body, %if.then.i
35 %incdec.ptr = getelementptr inbounds %"Length", %"Length"* %begin.sink5, i64 1, !dbg !11
36 %cmp = icmp eq %"Length"* %incdec.ptr, %end, !dbg !7
37 br i1 %cmp, label %for.end, label %for.body, !dbg !8
38
39 for.end: ; preds = %length.exit, %entry
40 ret void, !dbg !12
41 }
42
43 ; CHECK-LABEL: @with_landingpad
44 ; CHECK: catch.preheader:
45 ; CHECK: br label %catch, !dbg [[LPAD_PREHEADER_LOC:![0-9]+]]
46 ; CHECK: catch.preheader.split-lp:
47 ; CHECK: br label %catch, !dbg [[LPAD_PREHEADER_LOC]]
48
49 define void @with_landingpad() uwtable ssp {
50 entry:
51 invoke void @f1() to label %try.cont19 unwind label %catch, !dbg !13
52
53 catch: ; preds = %if.else, %entry
54 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
55 catch i8* bitcast ({ i8*, i8*, i8* }* @catchtypeinfo to i8*), !dbg !13
56 invoke void @f3() to label %if.else unwind label %eh.resume, !dbg !13
57
58 if.else: ; preds = %catch
59 invoke void @f2() to label %try.cont19 unwind label %catch, !dbg !13
60
61 try.cont19: ; preds = %if.else, %entry
62 ret void, !dbg !13
63
64 eh.resume: ; preds = %catch
65 %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
66 cleanup catch i8* bitcast ({ i8*, i8*, i8* }* @catchtypeinfo to i8*), !dbg !13
67 resume { i8*, i32 } undef, !dbg !13
68 }
69
70 ; CHECK-DAG: [[PREHEADER_LOC]] = !DILocation(line: 73, column: 27, scope: !{{[0-9]+}})
71 ; CHECK-DAG: [[LOOPEXIT_LOC]] = !DILocation(line: 75, column: 9, scope: !{{[0-9]+}})
72 ; CHECK-DAG: [[LPAD_PREHEADER_LOC]] = !DILocation(line: 85, column: 1, scope: !{{[0-9]+}})
73
74 !llvm.module.flags = !{!0, !1, !2}
75 !0 = !{i32 2, !"Dwarf Version", i32 4}
76 !1 = !{i32 2, !"Debug Info Version", i32 3}
77 !2 = !{i32 1, !"PIC Level", i32 2}
78
79 !3 = !{}
80 !4 = !DISubroutineType(types: !3)
81 !5 = !DIFile(filename: "Vector.h", directory: "/tmp")
82 !6 = !DISubprogram(name: "destruct", scope: !5, file: !5, line: 71, type: !4, isLocal: false, isDefinition: true, scopeLine: 72, flags: DIFlagPrototyped, isOptimized: false, function: void (%"Length"*, %"Length"*)* @foo, variables: !3)
83 !7 = !DILocation(line: 73, column: 38, scope: !6)
84 !8 = !DILocation(line: 73, column: 13, scope: !6)
85 !9 = !DILocation(line: 73, column: 27, scope: !6)
86 !10 = !DILocation(line: 74, column: 17, scope: !6)
87 !11 = !DILocation(line: 73, column: 46, scope: !6)
88 !12 = !DILocation(line: 75, column: 9, scope: !6)
89 !13 = !DILocation(line: 85, column: 1, scope: !6)