Skip to content

[InitUndef] handleSubReg should skip artificial subregs. #116248

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 2 commits into from
Nov 14, 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
8 changes: 8 additions & 0 deletions llvm/lib/CodeGen/InitUndef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ 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, [&](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