-
Notifications
You must be signed in to change notification settings - Fork 14.3k
TwoAddressInstruction: Fix assert on undef operand with -early-live-intervals #125518
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
TwoAddressInstruction: Fix assert on undef operand with -early-live-intervals #125518
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-backend-arm @llvm/pr-subscribers-llvm-regalloc Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/125518.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index fb6274b09919ba..6236268f77ab16 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -489,6 +489,9 @@ MachineInstr *TwoAddressInstructionImpl::findOnlyInterestingUse(
bool &IsDstPhys) const {
MachineOperand *UseOp = nullptr;
for (MachineOperand &MO : MRI->use_nodbg_operands(Reg)) {
+ if (MO.isUndef())
+ continue;
+
MachineInstr *MI = MO.getParent();
if (MI->getParent() != MBB)
return nullptr;
diff --git a/llvm/test/CodeGen/ARM/twoaddress-asserts-liveints-undef-use.mir b/llvm/test/CodeGen/ARM/twoaddress-asserts-liveints-undef-use.mir
new file mode 100644
index 00000000000000..6e33d4be9345da
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/twoaddress-asserts-liveints-undef-use.mir
@@ -0,0 +1,24 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
+# RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve -verify-machineinstrs -run-pass=liveintervals,twoaddressinstruction -o - %s | FileCheck %s
+
+---
+name: undef_use_asserts_lr
+tracksRegLiveness: true
+noPhis: true
+body: |
+ bb.0:
+ liveins: $q0
+
+ ; CHECK-LABEL: name: undef_use_asserts_lr
+ ; CHECK: liveins: $q0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:mqpr = COPY $q0
+ ; CHECK-NEXT: [[DEF:%[0-9]+]]:spr = IMPLICIT_DEF
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:mqpr = COPY [[COPY]]
+ ; CHECK-NEXT: dead [[COPY1:%[0-9]+]].ssub_2:mqpr = COPY [[DEF]]
+ ; CHECK-NEXT: dead [[COPY2:%[0-9]+]]:spr = COPY undef [[COPY1]].ssub_3
+ %0:mqpr = COPY $q0
+ %1:spr = IMPLICIT_DEF
+ %2:mqpr = INSERT_SUBREG %0, %1, %subreg.ssub_2
+ dead %4:spr = COPY undef %2.ssub_3
+...
|
@@ -489,6 +489,9 @@ MachineInstr *TwoAddressInstructionImpl::findOnlyInterestingUse( | |||
bool &IsDstPhys) const { | |||
MachineOperand *UseOp = nullptr; | |||
for (MachineOperand &MO : MRI->use_nodbg_operands(Reg)) { | |||
if (MO.isUndef()) | |||
continue; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to your patch, but should there be a break after line 499?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably should, but I'd need to look exactly at all the implementations of isPlainlyKilled. At least the LiveIntervals one checks there's only one value in the interval
No description provided.