summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp2
-rw-r--r--llvm/lib/CodeGen/GlobalISel/Utils.cpp4
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir36
3 files changed, 32 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index 69ad59ade08..26454c1ef00 100644
--- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -123,7 +123,7 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
// If so, erase it.
if (isTriviallyDead(MI, MRI)) {
DEBUG(dbgs() << "Is dead; erasing.\n");
- MI.eraseFromParent();
+ MI.eraseFromParentAndMarkDBGValuesForRemoval();
continue;
}
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 2e2f519ab2b..606a59680a3 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -61,8 +61,8 @@ bool llvm::isTriviallyDead(const MachineInstr &MI,
continue;
unsigned Reg = MO.getReg();
- // Keep Debug uses live: we don't want to have an effect on debug info.
- if (TargetRegisterInfo::isPhysicalRegister(Reg) || !MRI.use_empty(Reg))
+ if (TargetRegisterInfo::isPhysicalRegister(Reg) ||
+ !MRI.use_nodbg_empty(Reg))
return false;
}
return true;
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir b/llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir
index cbc7ec88a67..2f36ec8d2aa 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir
@@ -3,8 +3,13 @@
--- |
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
- define void @test_dbg_value() !dbg !5 {
- ; Keep the dbg metadata live by referencing it in the IR.
+ define void @test_dbg_value(i32 %a) !dbg !5 {
+ %tmp0 = add i32 %a, %a
+ call void @llvm.dbg.value(metadata i32 %tmp0, i64 0, metadata !7, metadata !9), !dbg !10
+ ret void
+ }
+
+ define void @test_dbg_value_dead(i32 %a) !dbg !5 {
call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !7, metadata !9), !dbg !10
ret void
}
@@ -32,16 +37,33 @@
name: test_dbg_value
legalized: true
regBankSelected: true
-# CHECK: registers:
-# CHECK-NEXT: - { id: 0, class: gpr32all }
+body: |
+ bb.0:
+ liveins: %w0
+ %0:gpr(s32) = COPY %w0
+ %1:gpr(s32) = G_ADD %0, %0
+ %w0 = COPY %1(s32)
+
+ ; CHECK: %0 = COPY %w0
+ ; CHECK-NEXT: %1 = ADDWrr %0, %0
+ ; CHECK-NEXT: %w0 = COPY %1
+ ; CHECK-NEXT: DBG_VALUE debug-use %1, debug-use _, !7, !9, debug-location !10
+
+ DBG_VALUE debug-use %1(s32), debug-use _, !7, !9, debug-location !10
+...
+
+---
+# CHECK-LABEL: name: test_dbg_value_dead
+name: test_dbg_value_dead
+legalized: true
+regBankSelected: true
body: |
bb.0:
liveins: %w0
%0:gpr(s32) = COPY %w0
- ; CHECK: DBG_VALUE debug-use %0, debug-use _, !7, !9, debug-location !10
- ; CHECK: DBG_VALUE _, 0, !7, !9, debug-location !10
+ ; CHECK-NOT: COPY
+ ; CHECK: DBG_VALUE debug-use _, debug-use _, !7, !9, debug-location !10
DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10
- DBG_VALUE _, 0, !7, !9, debug-location !10
...
OpenPOWER on IntegriCloud