[PATCH] Allow the register scavenger to spill multiple registers
Richard Sandiford
rdsandiford at googlemail.com
Tue Mar 26 04:40:05 PDT 2013
Hal Finkel <hfinkel-uKDnm65ik8M at public.gmane.org> writes:
> Please review the attached patch which lets the register scavenger make
> use of multiple spill slots in order to guarantee that it will be able
> to provide multiple registers simultaneously. I intend to use this
> capability in the PowerPC backend to handle spills where we need two
> registers (one for indexing and one for transfer) without keeping an
> extra reserved register.
This might have been discussed already, sorry, but: this patch seems to
change the behaviour for targets that use something other than a frame
index as scavenging spill space. (E.g. Thumb 1 uses r12, MIPS16 uses t0.)
Those targets never called setScavengingFrameIndex() and instead left
the ScavengingFrameIndex as -1. They used saveScavengerRegister to do
the saving and restoring.
Targets that don't register a frame index now hit the assert:
assert(SI < Scavenged.size() &&
"Scavenger slots are live, unable to scavenge another register!");
before saveScavengerRegister() is called.
FWIW, a simple hack like calling addScavengingFrameIndex(-1) doesn't work
because:
@@ -631,9 +633,11 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
// stack pointer.
if (RS && (!TFI.hasFP(Fn) || RegInfo->needsStackRealignment(Fn) ||
!RegInfo->useFPForScavengingIndex(Fn))) {
- int SFI = RS->getScavengingFrameIndex();
- if (SFI >= 0)
- AdjustStackOffset(MFI, SFI, StackGrowsDown, Offset, MaxAlign);
+ SmallVector<int, 2> SFIs;
+ RS->getScavengingFrameIndices(SFIs);
+ for (SmallVector<int, 2>::iterator I = SFIs.begin(),
+ IE = SFIs.end(); I != IE; ++I)
+ AdjustStackOffset(MFI, *I, StackGrowsDown, Offset, MaxAlign);
}
if (!TFI.targetHandlesStackFrameRounding()) {
assumes every index is valid.
Richard
More information about the llvm-commits
mailing list