mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[DCE] Salvage debug info from dead insts
This results in small increases in the size of the .debug_loc section and the number of unique source variables in a stage2 build of opt. llvm-svn: 325301
This commit is contained in:
parent
42ad8b2929
commit
02a33aae11
@ -50,6 +50,7 @@ namespace {
|
||||
for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
|
||||
Instruction *Inst = &*DI++;
|
||||
if (isInstructionTriviallyDead(Inst, TLI)) {
|
||||
salvageDebugInfo(*Inst);
|
||||
Inst->eraseFromParent();
|
||||
Changed = true;
|
||||
++DIEEliminated;
|
||||
@ -76,6 +77,8 @@ static bool DCEInstruction(Instruction *I,
|
||||
SmallSetVector<Instruction *, 16> &WorkList,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (isInstructionTriviallyDead(I, TLI)) {
|
||||
salvageDebugInfo(*I);
|
||||
|
||||
// Null out all of the instruction's operands to see if any operand becomes
|
||||
// dead as we go.
|
||||
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
|
||||
|
@ -1,11 +1,15 @@
|
||||
; RUN: opt -dce -S < %s | FileCheck %s
|
||||
; RUN: opt -passes=dce -S < %s | FileCheck %s
|
||||
; RUN: opt -debugify -dce -S < %s | FileCheck %s
|
||||
; RUN: opt -passes='module(debugify),function(dce)' -S < %s | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: @test
|
||||
define void @test() {
|
||||
; CHECK-NOT: add
|
||||
%add = add i32 1, 2
|
||||
; CHECK-NOT: sub
|
||||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 1, metadata [[add:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2, DW_OP_stack_value))
|
||||
%sub = sub i32 %add, 1
|
||||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 1, metadata [[sub:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2, DW_OP_constu, 1, DW_OP_minus, DW_OP_stack_value))
|
||||
; CHECK-NEXT: ret void
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: [[add]] = !DILocalVariable
|
||||
; CHECK: [[sub]] = !DILocalVariable
|
||||
|
Loading…
x
Reference in New Issue
Block a user