forked from OSchip/llvm-project
[X86] Remove side-effects from determineCalleeSaves
(Target)FrameLowering::determineCalleeSaves can be called multiple times. I don't think it should have side-effects as creating stack objects and setting global MachineFunctionInfo state as it is doing today (in other back-ends as well). This moves the creation of stack objects from determineCalleeSaves to assignCalleeSavedSpillSlots. Differential Revision: https://reviews.llvm.org/D41703 llvm-svn: 321987
This commit is contained in:
parent
e1689689d8
commit
d52da12822
|
@ -1855,6 +1855,32 @@ bool X86FrameLowering::assignCalleeSavedSpillSlots(
|
|||
unsigned CalleeSavedFrameSize = 0;
|
||||
int SpillSlotOffset = getOffsetOfLocalArea() + X86FI->getTCReturnAddrDelta();
|
||||
|
||||
int64_t TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
|
||||
|
||||
if (TailCallReturnAddrDelta < 0) {
|
||||
// create RETURNADDR area
|
||||
// arg
|
||||
// arg
|
||||
// RETADDR
|
||||
// { ...
|
||||
// RETADDR area
|
||||
// ...
|
||||
// }
|
||||
// [EBP]
|
||||
MFI.CreateFixedObject(-TailCallReturnAddrDelta,
|
||||
TailCallReturnAddrDelta - SlotSize, true);
|
||||
}
|
||||
|
||||
// Spill the BasePtr if it's used.
|
||||
if (this->TRI->hasBasePointer(MF)) {
|
||||
// Allocate a spill slot for EBP if we have a base pointer and EH funclets.
|
||||
if (MF.hasEHFunclets()) {
|
||||
int FI = MFI.CreateSpillStackObject(SlotSize, SlotSize);
|
||||
X86FI->setHasSEHFramePtrSave(true);
|
||||
X86FI->setSEHFramePtrSaveIndex(FI);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasFP(MF)) {
|
||||
// emitPrologue always spills frame register the first thing.
|
||||
SpillSlotOffset -= SlotSize;
|
||||
|
@ -2060,36 +2086,9 @@ void X86FrameLowering::determineCalleeSaves(MachineFunction &MF,
|
|||
RegScavenger *RS) const {
|
||||
TargetFrameLowering::determineCalleeSaves(MF, SavedRegs, RS);
|
||||
|
||||
MachineFrameInfo &MFI = MF.getFrameInfo();
|
||||
|
||||
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
||||
int64_t TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
|
||||
|
||||
if (TailCallReturnAddrDelta < 0) {
|
||||
// create RETURNADDR area
|
||||
// arg
|
||||
// arg
|
||||
// RETADDR
|
||||
// { ...
|
||||
// RETADDR area
|
||||
// ...
|
||||
// }
|
||||
// [EBP]
|
||||
MFI.CreateFixedObject(-TailCallReturnAddrDelta,
|
||||
TailCallReturnAddrDelta - SlotSize, true);
|
||||
}
|
||||
|
||||
// Spill the BasePtr if it's used.
|
||||
if (TRI->hasBasePointer(MF)) {
|
||||
if (TRI->hasBasePointer(MF))
|
||||
SavedRegs.set(TRI->getBaseRegister());
|
||||
|
||||
// Allocate a spill slot for EBP if we have a base pointer and EH funclets.
|
||||
if (MF.hasEHFunclets()) {
|
||||
int FI = MFI.CreateSpillStackObject(SlotSize, SlotSize);
|
||||
X86FI->setHasSEHFramePtrSave(true);
|
||||
X86FI->setSEHFramePtrSaveIndex(FI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
Loading…
Reference in New Issue