Skip to content

Commit 61653f8

Browse files
committed
Reland "[InitUndef] handleSubReg should skip artificial subregs. (#116248)"
This patch can now reland after 318c69d relanded #114827. This reverts commit 1683f84.
1 parent 04a2d50 commit 61653f8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/CodeGen/InitUndef.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ bool InitUndef::handleSubReg(MachineFunction &MF, MachineInstr &MI,
164164
TRI->getCoveringSubRegIndexes(*MRI, TargetRegClass, NeedDef,
165165
SubRegIndexNeedInsert);
166166

167+
// It's not possible to create the INIT_UNDEF when there is no register
168+
// class associated for the subreg. This may happen for artificial subregs
169+
// that are not directly addressable.
170+
if (any_of(SubRegIndexNeedInsert, [&](unsigned Ind) -> bool {
171+
return !TRI->getSubRegisterClass(TargetRegClass, Ind);
172+
}))
173+
continue;
174+
167175
Register LatestReg = Reg;
168176
for (auto ind : SubRegIndexNeedInsert) {
169177
Changed = true;

llvm/test/CodeGen/AArch64/init-undef.mir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2-
# RUN: llc -mtriple=aarch64-- -run-pass=init-undef -o - %s | FileCheck %s
2+
# RUN: llc -mtriple=aarch64-- -aarch64-enable-subreg-liveness-tracking=false -run-pass=init-undef -o - %s | FileCheck %s
3+
# RUN: llc -mtriple=aarch64-- -aarch64-enable-subreg-liveness-tracking=true -run-pass=init-undef -o - %s | FileCheck %s
34

45
---
56
name: test_stxp_undef

0 commit comments

Comments
 (0)