mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[GVN] Salvage debug info from dead insts
This preserves an additional 581 unique source variables in a stage2 build of clang (according to `llvm-dwarfdump --statistics`). It increases the size of the .debug_loc section by 0.1% (or 87139 bytes). Differential Revision: https://reviews.llvm.org/D43255 llvm-svn: 325063
This commit is contained in:
parent
dc99a6d842
commit
91ac0024df
@ -2105,6 +2105,7 @@ bool GVN::processBlock(BasicBlock *BB) {
|
||||
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 @@ bool GVN::performScalarPRE(Instruction *CurInst) {
|
||||
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);
|
||||
|
@ -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 @@ critedge.loopexit:
|
||||
; 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 @@ if.end3: ; preds = %if.then2, %if.else,
|
||||
%sub.ptr.div7 = ashr exact i64 %sub.ptr.sub6, 2
|
||||
ret i64 %sub.ptr.div7
|
||||
}
|
||||
|
||||
; CHECK: [[var_p0]] = !DILocalVariable
|
||||
; CHECK: [[var_sub_ptr]] = !DILocalVariable
|
||||
|
@ -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 @test(i32* %addr.i) {
|
||||
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 @@ define i32 @test4(i32* %addr) {
|
||||
; 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
|
||||
|
Loading…
Reference in New Issue
Block a user