[PATCH] D43255: [GVN] Salvage debug info from dead insts
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 14:29:24 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325063: [GVN] Salvage debug info from dead insts (authored by vedantk, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43255?vs=134109&id=134120#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43255
Files:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
llvm/trunk/test/Transforms/GVN/PRE/phi-translate-2.ll
llvm/trunk/test/Transforms/GVN/fence.ll
Index: llvm/trunk/test/Transforms/GVN/fence.ll
===================================================================
--- llvm/trunk/test/Transforms/GVN/fence.ll
+++ llvm/trunk/test/Transforms/GVN/fence.ll
@@ -1,4 +1,4 @@
-; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
+; RUN: opt -S -debugify -basicaa -gvn < %s | FileCheck %s
@a = external constant i32
; We can value forward across the fence since we can (semantically)
@@ -19,6 +19,8 @@
define i32 @test2(i32* %addr.i) {
; CHECK-LABEL: @test2
; CHECK-NEXT: fence
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %addr.i, metadata [[var_a:![0-9]+]], metadata !DIExpression(DW_OP_deref))
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %addr.i, metadata [[var_a2:![0-9]+]], metadata !DIExpression(DW_OP_deref))
; CHECK-NOT: load
; CHECK: ret
%a = load i32, i32* %addr.i, align 4
@@ -87,3 +89,5 @@
; Given we chose to forward across the release fence, we clearly can't forward
; across the acquire fence as well.
+; CHECK: [[var_a]] = !DILocalVariable
+; CHECK-NEXT: [[var_a2]] = !DILocalVariable
Index: llvm/trunk/test/Transforms/GVN/PRE/phi-translate-2.ll
===================================================================
--- llvm/trunk/test/Transforms/GVN/PRE/phi-translate-2.ll
+++ llvm/trunk/test/Transforms/GVN/PRE/phi-translate-2.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | FileCheck %s
+; RUN: opt < %s -debugify -gvn -S | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@a = common global [100 x i64] zeroinitializer, align 16
@@ -142,6 +142,8 @@
; CHECK: if.end3:
; CHECK: %[[PREPHI:.*]] = phi i64 [ %sub.ptr.sub, %if.else ], [ %[[SUB]], %if.then2 ], [ %sub.ptr.sub, %entry ]
; CHECK: %[[DIV:.*]] = ashr exact i64 %[[PREPHI]], 2
+; CHECK: call void @llvm.dbg.value(metadata i32* %p.0, metadata [[var_p0:![0-9]+]], metadata !DIExpression())
+; CHECK: call void @llvm.dbg.value(metadata i32* %p.0, metadata [[var_sub_ptr:![0-9]+]], metadata !DIExpression())
; CHECK: ret i64 %[[DIV]]
declare void @bar(...) local_unnamed_addr #1
@@ -174,3 +176,6 @@
%sub.ptr.div7 = ashr exact i64 %sub.ptr.sub6, 2
ret i64 %sub.ptr.div7
}
+
+; CHECK: [[var_p0]] = !DILocalVariable
+; CHECK: [[var_sub_ptr]] = !DILocalVariable
Index: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp
@@ -2105,6 +2105,7 @@
for (auto *I : InstrsToErase) {
assert(I->getParent() == BB && "Removing instruction from wrong block?");
DEBUG(dbgs() << "GVN removed: " << *I << '\n');
+ salvageDebugInfo(*I);
if (MD) MD->removeInstruction(I);
DEBUG(verifyRemoved(I));
if (MaybeFirstICF == I) {
@@ -2320,6 +2321,7 @@
VN.eraseTranslateCacheEntry(ValNo, *CurrentBlock);
addToLeaderTable(ValNo, Phi, CurrentBlock);
Phi->setDebugLoc(CurInst->getDebugLoc());
+ salvageDebugInfo(*CurInst);
CurInst->replaceAllUsesWith(Phi);
if (MD && Phi->getType()->isPtrOrPtrVectorTy())
MD->invalidateCachedPointerInfo(Phi);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43255.134120.patch
Type: text/x-patch
Size: 3109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180213/1055d61d/attachment.bin>
More information about the llvm-commits
mailing list