Skip to content

Commit 6f14744

Browse files
authored
[RegAlloc] Constrain rematted regclass to use (#164386)
When rematting we create a new virtual register with the original def's register class. However the use may have a different register class if the interval is split, which means we end up with an invalid register class. This fixes #164181 by constraining the newly created register to the use's register class. The test case is reduced as far as it goes. Because this test requires us to reach a certain amount of register pressure in certain conditions I'm not sure if there's an easy way to handwrite this scenario.
1 parent 4903a1f commit 6f14744

File tree

2 files changed

+643
-0
lines changed

2 files changed

+643
-0
lines changed

llvm/lib/CodeGen/InlineSpiller.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,9 @@ bool InlineSpiller::reMaterializeFor(LiveInterval &VirtReg, MachineInstr &MI) {
721721
// Allocate a new register for the remat.
722722
Register NewVReg = Edit->createFrom(Original);
723723

724+
// Constrain it to the register class of MI.
725+
MRI.constrainRegClass(NewVReg, MRI.getRegClass(VirtReg.reg()));
726+
724727
// Finally we can rematerialize OrigMI before MI.
725728
SlotIndex DefIdx =
726729
Edit->rematerializeAt(*MI.getParent(), MI, NewVReg, RM, TRI);

0 commit comments

Comments
 (0)