Skip to content

Commit 117e952

Browse files
authored
[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.
1 parent 652db7e commit 117e952

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

llvm/lib/CodeGen/LiveRangeEdit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
385385
continue;
386386
MI->removeOperand(i-1);
387387
}
388+
MI->dropMemRefs(*MI->getMF());
388389
LLVM_DEBUG(dbgs() << "Converted physregs to:\t" << *MI);
389390
} else {
390391
// If the dest of MI is an original reg and MI is reMaterializable,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# RUN: llc -o /dev/null %s -mtriple=s390x-linux-gnu -mcpu=z16 \
2+
# RUN: -verify-machineinstrs -run-pass=register-coalescer
3+
4+
# The LOCMux below produces a dead definition and will be turned into
5+
# a KILL instruction (by LiveRangeEdit::eliminateDeadDef()). When this
6+
# happens, the MemoryOperand must also be removed as this is required
7+
# by the machine verifier.
8+
9+
---
10+
name: fun
11+
tracksRegLiveness: true
12+
body: |
13+
bb.0:
14+
liveins: $r2d
15+
16+
%3:addr64bit = COPY killed $r2d
17+
18+
bb.1:
19+
%5:grx32bit = LMux killed %3, 0, $noreg :: (load (s32))
20+
CHIMux killed %5, 0, implicit-def $cc
21+
%7:grx32bit = LHIMux 0
22+
%1:grx32bit = COPY killed %7
23+
%1:grx32bit = LOCMux %1, undef %8:addr64bit, 0, 14, 6, implicit killed $cc :: (load (s32))
24+
dead %0:grx32bit = COPY killed %1
25+
26+
bb.2:
27+
J %bb.2
28+
29+
...

0 commit comments

Comments
 (0)