llvm.org GIT mirror llvm / ed02ca3
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325301 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 1 year, 7 months ago
2 changed file(s) with 11 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
4949 for (BasicBlock::iterator DI = BB.begin(); DI != BB.end(); ) {
5050 Instruction *Inst = &*DI++;
5151 if (isInstructionTriviallyDead(Inst, TLI)) {
52 salvageDebugInfo(*Inst);
5253 Inst->eraseFromParent();
5354 Changed = true;
5455 ++DIEEliminated;
7576 SmallSetVector &WorkList,
7677 const TargetLibraryInfo *TLI) {
7778 if (isInstructionTriviallyDead(I, TLI)) {
79 salvageDebugInfo(*I);
80
7881 // Null out all of the instruction's operands to see if any operand becomes
7982 // dead as we go.
8083 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
None ; RUN: opt -dce -S < %s | FileCheck %s
1 ; RUN: opt -passes=dce -S < %s | FileCheck %s
0 ; RUN: opt -debugify -dce -S < %s | FileCheck %s
1 ; RUN: opt -passes='module(debugify),function(dce)' -S < %s | FileCheck %s
22
33 ; CHECK-LABEL: @test
44 define void @test() {
5 ; CHECK-NOT: add
65 %add = add i32 1, 2
7 ; CHECK-NOT: sub
6 ; 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))
87 %sub = sub i32 %add, 1
8 ; 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))
9 ; CHECK-NEXT: ret void
910 ret void
1011 }
12
13 ; CHECK: [[add]] = !DILocalVariable
14 ; CHECK: [[sub]] = !DILocalVariable