llvm.org GIT mirror llvm / 93dd711
[LoopSimplify] Set proper debug location in loop backedge blocks. Set debug location for terminator instruction in loop backedge block (which is an unconditional jump to loop header). We can't copy debug location from original backedges, as there can be several of them, with different debug info locations. So, we follow the approach of SplitBlockPredecessors, and copy the debug info from first non-PHI instruction in the header (i.e. destination block). This is yet another change for PR23837. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240999 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 4 years ago
2 changed file(s) with 29 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
385385
386386 // Create and insert the new backedge block...
387387 BasicBlock *BEBlock = BasicBlock::Create(Header->getContext(),
388 Header->getName()+".backedge", F);
388 Header->getName() + ".backedge", F);
389389 BranchInst *BETerminator = BranchInst::Create(Header, BEBlock);
390 BETerminator->setDebugLoc(Header->getFirstNonPHI()->getDebugLoc());
390391
391392 DEBUG(dbgs() << "LoopSimplify: Inserting unique backedge block "
392393 << BEBlock->getName() << "\n");
44 ; RUN: opt < %s -indvars -S | FileCheck %s
55 ; CHECK: Loop.backedge:
66 ; CHECK-NOT: br
7 ; CHECK: br label %Loop
7 ; CHECK: br label %Loop, !dbg [[BACKEDGE_LOC:![0-9]+]]
8
9 ; CHECK: [[BACKEDGE_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
810
911 define i32 @test(i1 %C) {
1012 ;
11 br label %Loop
12 Loop: ; preds = %BE2, %BE1, %0
13 %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; [#uses=2]
14 store i32 %IV, i32* null
15 %IV2 = add i32 %IV, 2 ; [#uses=2]
16 br i1 %C, label %BE1, label %BE2
17 BE1: ; preds = %Loop
18 br label %Loop
19 BE2: ; preds = %Loop
20 br label %Loop
13 br label %Loop, !dbg !6
14 Loop: ; preds = %BE2, %BE1, %0
15 %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; [#uses=2]
16 store i32 %IV, i32* null, !dbg !7
17 %IV2 = add i32 %IV, 2, !dbg !8 ; [#uses=2]
18 br i1 %C, label %BE1, label %BE2, !dbg !9
19 BE1: ; preds = %Loop
20 br label %Loop, !dbg !10
21 BE2: ; preds = %n br label %Loop
22 br label %Loop, !dbg !11
2123 }
2224
25 !llvm.module.flags = !{!0, !1}
26 !0 = !{i32 2, !"Dwarf Version", i32 4}
27 !1 = !{i32 2, !"Debug Info Version", i32 3}
28
29 !2 = !{}
30 !3 = !DISubroutineType(types: !2)
31 !4 = !DIFile(filename: "atomic.cpp", directory: "/tmp")
32 !5 = !DISubprogram(name: "test", scope: !4, file: !4, line: 99, type: !3, isLocal: false, isDefinition: true, scopeLine: 100, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
33 !6 = !DILocation(line: 100, column: 1, scope: !5)
34 !7 = !DILocation(line: 101, column: 1, scope: !5)
35 !8 = !DILocation(line: 102, column: 1, scope: !5)
36 !9 = !DILocation(line: 103, column: 1, scope: !5)
37 !10 = !DILocation(line: 104, column: 1, scope: !5)
38 !11 = !DILocation(line: 105, column: 1, scope: !5)