forked from OSchip/llvm-project
Improve the effectiveness of ADCE's debug info salvaging
This patch improves the effectiveness of ADCE's debug info salvaging by processing the instructions in reverse order and delaying dropAllReferences until after debug info salvaging. This allows salvaging of entire chains of deleted instructions! Previously we would remove all references from an instruction, which would make it impossible to use that instruction to salvage a later instruction in the instruction stream, because its operands were already removed. Differential Revision: https://reviews.llvm.org/D110462
This commit is contained in:
parent
1b998a5f0c
commit
9637b045e6
|
@ -538,7 +538,7 @@ bool AggressiveDeadCodeElimination::removeDeadInstructions() {
|
|||
// that have no side effects and do not influence the control flow or return
|
||||
// value of the function, and may therefore be deleted safely.
|
||||
// NOTE: We reuse the Worklist vector here for memory efficiency.
|
||||
for (Instruction &I : instructions(F)) {
|
||||
for (Instruction &I : llvm::reverse(instructions(F))) {
|
||||
// Check if the instruction is alive.
|
||||
if (isLive(&I))
|
||||
continue;
|
||||
|
@ -554,9 +554,11 @@ bool AggressiveDeadCodeElimination::removeDeadInstructions() {
|
|||
// Prepare to delete.
|
||||
Worklist.push_back(&I);
|
||||
salvageDebugInfo(I);
|
||||
I.dropAllReferences();
|
||||
}
|
||||
|
||||
for (Instruction *&I : Worklist)
|
||||
I->dropAllReferences();
|
||||
|
||||
for (Instruction *&I : Worklist) {
|
||||
++NumRemoved;
|
||||
I->eraseFromParent();
|
||||
|
|
|
@ -5,8 +5,10 @@ define void @f(i32) !dbg !8 {
|
|||
entry:
|
||||
%p_x = inttoptr i32 %0 to i8*
|
||||
%i_x = ptrtoint i8* %p_x to i32
|
||||
; CHECK: call void @llvm.dbg.value(metadata i8* undef,
|
||||
; CHECK-SAME: !DIExpression(DW_OP_LLVM_convert, 64, DW_ATE_unsigned,
|
||||
; CHECK: call void @llvm.dbg.value(metadata i32 %0,
|
||||
; CHECK-SAME: !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned,
|
||||
; CHECK-SAME: DW_OP_LLVM_convert, 64, DW_ATE_unsigned,
|
||||
; CHECK-SAME: DW_OP_LLVM_convert, 64, DW_ATE_unsigned,
|
||||
; CHECK-SAME: DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value))
|
||||
call void @llvm.dbg.value(metadata i32 %i_x, metadata !11, metadata !DIExpression()), !dbg !13
|
||||
ret void, !dbg !13
|
||||
|
|
Loading…
Reference in New Issue