Skip to content

Commit 6cf11f4

Browse files
committed
[GlobalISel][DebugInfo] Salvage trivially dead instructions
Use salvageDebugInfo for instructions erased as trivially dead in GlobalISel. It would be helpful to implement support of G_PTR_ADD and G_FRAME_INDEX in salvageDebugInfo in future in order to preserve more variable location. Reviewed by: arsenm Differential Revision: https://reviews.llvm.org/D133986
1 parent f1a11d7 commit 6cf11f4

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
160160
// If so, erase it.
161161
if (isTriviallyDead(MI, MRI)) {
162162
LLVM_DEBUG(dbgs() << "Is dead; erasing.\n");
163+
salvageDebugInfo(MRI, MI);
163164
MI.eraseFromParent();
164165
continue;
165166
}

llvm/lib/CodeGen/GlobalISel/Legalizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Legalizer::legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI,
225225
assert(isPreISelGenericOpcode(MI.getOpcode()) &&
226226
"Expecting generic opcode");
227227
if (isTriviallyDead(MI, MRI)) {
228+
salvageDebugInfo(MRI, MI);
228229
eraseInstr(MI, MRI, &LocObserver);
229230
continue;
230231
}
@@ -272,6 +273,7 @@ Legalizer::legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI,
272273
assert(isPreISelGenericOpcode(MI.getOpcode()) &&
273274
"Expecting generic opcode");
274275
if (isTriviallyDead(MI, MRI)) {
276+
salvageDebugInfo(MRI, MI);
275277
eraseInstr(MI, MRI, &LocObserver);
276278
continue;
277279
}

llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ body: |
6565
; CHECK-LABEL: name: test_dbg_value_dead
6666
; CHECK: liveins: $w0
6767
; CHECK-NEXT: {{ $}}
68-
; CHECK-NEXT: DBG_VALUE %0:gpr32, $noreg, !7, !DIExpression(), debug-location !9
68+
; CHECK-NEXT: DBG_VALUE %1:gpr64, $noreg, !7, !DIExpression(), debug-location !9
6969
%0:gpr(s32) = COPY $w0
70-
DBG_VALUE %0(s32), $noreg, !7, !DIExpression(), debug-location !9
70+
%1:gpr(s64) = G_ZEXT %0:gpr(s32)
71+
DBG_VALUE %1(s64), $noreg, !7, !DIExpression(), debug-location !9
7172
...

0 commit comments

Comments
 (0)