Skip to content

[LiveRangeEdit] Remove any MemoryOperand on MI when converting it to KILL. #114407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/LiveRangeEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 29 additions & 0 deletions llvm/test/CodeGen/SystemZ/liverangeedit-kill-memop.mir
Original file line number Diff line number Diff line change
@@ -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

...
Loading