[llvm] r240999 - [LoopSimplify] Set proper debug location in loop backedge blocks.
Alexey Samsonov
vonosmas at gmail.com
Mon Jun 29 14:30:14 PDT 2015
Author: samsonov
Date: Mon Jun 29 16:30:14 2015
New Revision: 240999
URL: http://llvm.org/viewvc/llvm-project?rev=240999&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
llvm/trunk/test/Transforms/LoopSimplify/single-backedge.ll
Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=240999&r1=240998&r2=240999&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Mon Jun 29 16:30:14 2015
@@ -386,8 +386,9 @@ static BasicBlock *insertUniqueBackedgeB
// Create and insert the new backedge block...
BasicBlock *BEBlock = BasicBlock::Create(Header->getContext(),
- Header->getName()+".backedge", F);
+ Header->getName() + ".backedge", F);
BranchInst *BETerminator = BranchInst::Create(Header, BEBlock);
+ BETerminator->setDebugLoc(Header->getFirstNonPHI()->getDebugLoc());
DEBUG(dbgs() << "LoopSimplify: Inserting unique backedge block "
<< BEBlock->getName() << "\n");
Modified: llvm/trunk/test/Transforms/LoopSimplify/single-backedge.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplify/single-backedge.ll?rev=240999&r1=240998&r2=240999&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopSimplify/single-backedge.ll (original)
+++ llvm/trunk/test/Transforms/LoopSimplify/single-backedge.ll Mon Jun 29 16:30:14 2015
@@ -5,19 +5,35 @@
; RUN: opt < %s -indvars -S | FileCheck %s
; CHECK: Loop.backedge:
; CHECK-NOT: br
-; CHECK: br label %Loop
+; CHECK: br label %Loop, !dbg [[BACKEDGE_LOC:![0-9]+]]
+
+; CHECK: [[BACKEDGE_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
define i32 @test(i1 %C) {
; <label>:0
- br label %Loop
-Loop: ; preds = %BE2, %BE1, %0
- %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; <i32> [#uses=2]
- store i32 %IV, i32* null
- %IV2 = add i32 %IV, 2 ; <i32> [#uses=2]
- br i1 %C, label %BE1, label %BE2
-BE1: ; preds = %Loop
- br label %Loop
-BE2: ; preds = %Loop
- br label %Loop
+ br label %Loop, !dbg !6
+Loop: ; preds = %BE2, %BE1, %0
+ %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; <i32> [#uses=2]
+ store i32 %IV, i32* null, !dbg !7
+ %IV2 = add i32 %IV, 2, !dbg !8 ; <i32> [#uses=2]
+ br i1 %C, label %BE1, label %BE2, !dbg !9
+BE1: ; preds = %Loop
+ br label %Loop, !dbg !10
+BE2: ; preds = %n br label %Loop
+ br label %Loop, !dbg !11
}
+!llvm.module.flags = !{!0, !1}
+!0 = !{i32 2, !"Dwarf Version", i32 4}
+!1 = !{i32 2, !"Debug Info Version", i32 3}
+
+!2 = !{}
+!3 = !DISubroutineType(types: !2)
+!4 = !DIFile(filename: "atomic.cpp", directory: "/tmp")
+!5 = !DISubprogram(name: "test", scope: !4, file: !4, line: 99, type: !3, isLocal: false, isDefinition: true, scopeLine: 100, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
+!6 = !DILocation(line: 100, column: 1, scope: !5)
+!7 = !DILocation(line: 101, column: 1, scope: !5)
+!8 = !DILocation(line: 102, column: 1, scope: !5)
+!9 = !DILocation(line: 103, column: 1, scope: !5)
+!10 = !DILocation(line: 104, column: 1, scope: !5)
+!11 = !DILocation(line: 105, column: 1, scope: !5)
More information about the llvm-commits
mailing list