[llvm] r338391 - [DebugInfo][LCSSA] Preserve debug location in lcssa phis
Anastasis Grammenos via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 31 07:54:52 PDT 2018
Author: gramanas
Date: Tue Jul 31 07:54:52 2018
New Revision: 338391
URL: http://llvm.org/viewvc/llvm-project?rev=338391&view=rev
Log:
[DebugInfo][LCSSA] Preserve debug location in lcssa phis
Summary:
When inserting lcssa Phi Nodes in the exit block
mak sure to preserve the original instructions DL.
Reviewers: vsk
Subscribers: JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D50009
Modified:
llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
llvm/trunk/test/Transforms/LCSSA/basictest.ll
Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=338391&r1=338390&r2=338391&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Tue Jul 31 07:54:52 2018
@@ -144,7 +144,8 @@ bool llvm::formLCSSAForInstructions(Smal
PHINode *PN = PHINode::Create(I->getType(), PredCache.size(ExitBB),
I->getName() + ".lcssa", &ExitBB->front());
-
+ // Get the debug location from the original instruction.
+ PN->setDebugLoc(I->getDebugLoc());
// Add inputs from inside the loop for this PHI.
for (BasicBlock *Pred : PredCache.get(ExitBB)) {
PN->addIncoming(I, Pred);
Modified: llvm/trunk/test/Transforms/LCSSA/basictest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LCSSA/basictest.ll?rev=338391&r1=338390&r2=338391&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LCSSA/basictest.ll (original)
+++ llvm/trunk/test/Transforms/LCSSA/basictest.ll Tue Jul 31 07:54:52 2018
@@ -1,6 +1,6 @@
; RUN: opt < %s -lcssa -S | FileCheck %s
; RUN: opt < %s -passes=lcssa -S | FileCheck %s
-; RUN: opt < %s -debugify -lcssa -S | FileCheck -check-prefix=CHECK2 %s
+; RUN: opt < %s -debugify -lcssa -S | FileCheck -check-prefix=DEBUGIFY %s
define void @lcssa(i1 %S2) {
; CHECK-LABEL: @lcssa
@@ -19,9 +19,12 @@ post.if: ; preds = %if.false, %if.true
br i1 %S2, label %loop.exit, label %loop.interior
loop.exit: ; preds = %post.if
; CHECK: %X3.lcssa = phi i32
-; CHECK2: call void @llvm.dbg.value(metadata i32 %X3.lcssa
+; DEBUGIFY: %X3.lcssa = phi i32 {{.*}}, !dbg ![[DbgLoc:[0-9]+]]
+; DEBUGIFY-NEXT: call void @llvm.dbg.value(metadata i32 %X3.lcssa
; CHECK: %X4 = add i32 3, %X3.lcssa
%X4 = add i32 3, %X3 ; <i32> [#uses=0]
ret void
}
+; Make sure the lcssa phi has %X3's debug location
+; DEBUGIFY: ![[DbgLoc]] = !DILocation(line: 7
More information about the llvm-commits
mailing list