Skip to content

Commit 3a2b552

Browse files
authored
TwoAddressInstruction: Fix assert on undef operand with -early-live-intervals (#125518)
1 parent 3dc1ef1 commit 3a2b552

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

llvm/lib/CodeGen/TwoAddressInstructionPass.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ MachineInstr *TwoAddressInstructionImpl::findOnlyInterestingUse(
489489
bool &IsDstPhys) const {
490490
MachineOperand *UseOp = nullptr;
491491
for (MachineOperand &MO : MRI->use_nodbg_operands(Reg)) {
492+
if (MO.isUndef())
493+
continue;
494+
492495
MachineInstr *MI = MO.getParent();
493496
if (MI->getParent() != MBB)
494497
return nullptr;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve -verify-machineinstrs -run-pass=liveintervals,twoaddressinstruction -o - %s | FileCheck %s
3+
4+
---
5+
name: undef_use_asserts_lr
6+
tracksRegLiveness: true
7+
noPhis: true
8+
body: |
9+
bb.0:
10+
liveins: $q0
11+
12+
; CHECK-LABEL: name: undef_use_asserts_lr
13+
; CHECK: liveins: $q0
14+
; CHECK-NEXT: {{ $}}
15+
; CHECK-NEXT: [[COPY:%[0-9]+]]:mqpr = COPY $q0
16+
; CHECK-NEXT: [[DEF:%[0-9]+]]:spr = IMPLICIT_DEF
17+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:mqpr = COPY [[COPY]]
18+
; CHECK-NEXT: dead [[COPY1:%[0-9]+]].ssub_2:mqpr = COPY [[DEF]]
19+
; CHECK-NEXT: dead [[COPY2:%[0-9]+]]:spr = COPY undef [[COPY1]].ssub_3
20+
%0:mqpr = COPY $q0
21+
%1:spr = IMPLICIT_DEF
22+
%2:mqpr = INSERT_SUBREG %0, %1, %subreg.ssub_2
23+
dead %4:spr = COPY undef %2.ssub_3
24+
...

0 commit comments

Comments
 (0)