Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions llvm/lib/CodeGen/InitUndef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ bool InitUndef::handleSubReg(MachineFunction &MF, MachineInstr &MI,
TRI->getCoveringSubRegIndexes(*MRI, TargetRegClass, NeedDef,
SubRegIndexNeedInsert);

// It's not possible to create the INIT_UNDEF when there is no register
// class associated for the subreg. This may happen for artificial subregs
// that are not directly addressable.
if (any_of(SubRegIndexNeedInsert,
[&TRI = TRI, &TargetRegClass](unsigned ind) -> bool {
return !TRI->getSubRegisterClass(TargetRegClass, ind);
}))
continue;

Register LatestReg = Reg;
for (auto ind : SubRegIndexNeedInsert) {
Changed = true;
Expand Down
3 changes: 2 additions & 1 deletion llvm/test/CodeGen/AArch64/init-undef.mir
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# RUN: llc -mtriple=aarch64-- -run-pass=init-undef -o - %s | FileCheck %s
# RUN: llc -mtriple=aarch64-- -aarch64-enable-subreg-liveness-tracking=false -run-pass=init-undef -o - %s | FileCheck %s
# RUN: llc -mtriple=aarch64-- -aarch64-enable-subreg-liveness-tracking=true -run-pass=init-undef -o - %s | FileCheck %s

---
name: test_stxp_undef
Expand Down
Loading