[llvm] 117e952 - [LiveRangeEdit] Remove any MemoryOperand on MI when converting it to KILL. (#114407)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 5 09:08:31 PST 2024
Author: Jonas Paulsson
Date: 2024-11-05T18:08:27+01:00
New Revision: 117e952a53ea97680293b7d8d6950090284ef198
URL: https://github.com/llvm/llvm-project/commit/117e952a53ea97680293b7d8d6950090284ef198
DIFF: https://github.com/llvm/llvm-project/commit/117e952a53ea97680293b7d8d6950090284ef198.diff
LOG: [LiveRangeEdit] Remove any MemoryOperand on MI when converting it to KILL. (#114407)
When LiveRangeEdit::eliminateDeadDef() converts an MI to a KILL instruction,
it should also call dropMemRefs() in order to erase any MachineMemOperand
present.
This was discovered in testing as the MachineVerifier does not accept an MMO
without the corresponding MI mayLoad/mayStore flag, which the KILL opcode
lacks.
Added:
llvm/test/CodeGen/SystemZ/liverangeedit-kill-memop.mir
Modified:
llvm/lib/CodeGen/LiveRangeEdit.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp
index c3c581d42236e4..7b630e88b2a604 100644
--- a/llvm/lib/CodeGen/LiveRangeEdit.cpp
+++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp
@@ -385,6 +385,7 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
continue;
MI->removeOperand(i-1);
}
+ MI->dropMemRefs(*MI->getMF());
LLVM_DEBUG(dbgs() << "Converted physregs to:\t" << *MI);
} else {
// If the dest of MI is an original reg and MI is reMaterializable,
diff --git a/llvm/test/CodeGen/SystemZ/liverangeedit-kill-memop.mir b/llvm/test/CodeGen/SystemZ/liverangeedit-kill-memop.mir
new file mode 100644
index 00000000000000..8cfa22d2469e2c
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/liverangeedit-kill-memop.mir
@@ -0,0 +1,29 @@
+# RUN: llc -o /dev/null %s -mtriple=s390x-linux-gnu -mcpu=z16 \
+# RUN: -verify-machineinstrs -run-pass=register-coalescer
+
+# The LOCMux below produces a dead definition and will be turned into
+# a KILL instruction (by LiveRangeEdit::eliminateDeadDef()). When this
+# happens, the MemoryOperand must also be removed as this is required
+# by the machine verifier.
+
+---
+name: fun
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $r2d
+
+ %3:addr64bit = COPY killed $r2d
+
+ bb.1:
+ %5:grx32bit = LMux killed %3, 0, $noreg :: (load (s32))
+ CHIMux killed %5, 0, implicit-def $cc
+ %7:grx32bit = LHIMux 0
+ %1:grx32bit = COPY killed %7
+ %1:grx32bit = LOCMux %1, undef %8:addr64bit, 0, 14, 6, implicit killed $cc :: (load (s32))
+ dead %0:grx32bit = COPY killed %1
+
+ bb.2:
+ J %bb.2
+
+...
More information about the llvm-commits
mailing list