Implement Red Zone utilization on x86-64. This is currently

disabled by default; I'll enable it when I hook it up with
the llvm-gcc flag which controls it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63056 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-01-26 22:22:31 +00:00
parent 609eef258f
commit 92f4f16a19
3 changed files with 23 additions and 0 deletions

View File

@ -107,6 +107,10 @@ namespace llvm {
/// wth earlier copy coalescing.
extern bool StrongPHIElim;
/// DisableRedZone - This flag disables use of the "Red Zone" on
/// targets which would otherwise have one.
extern bool DisableRedZone;
} // End llvm namespace
#endif

View File

@ -40,6 +40,7 @@ namespace llvm {
bool VerboseAsm;
bool DisableJumpTables;
bool StrongPHIElim;
bool DisableRedZone;
}
static cl::opt<bool, true> PrintCode("print-machineinstrs",
@ -164,6 +165,12 @@ EnableStrongPHIElim(cl::Hidden, "strong-phi-elim",
cl::location(StrongPHIElim),
cl::init(false));
static cl::opt<bool, true>
DisableRedZoneOption("disable-red-zone",
cl::desc("Do not emit code that uses the red zone."),
cl::location(DisableRedZone),
cl::init(true));
//---------------------------------------------------------------------------
// TargetMachine Class
//

View File

@ -721,6 +721,18 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
// Get desired stack alignment
uint64_t MaxAlign = MFI->getMaxAlignment();
// If this is x86-64 and the Red Zone is not disabled, if we are a leaf
// function, and use up to 128 bytes of stack space, don't have a frame
// pointer, calls, or dynamic alloca then we do not need to adjust the
// stack pointer (we fit in the Red Zone).
if (Is64Bit && !DisableRedZone &&
!MFI->hasVarSizedObjects() && // No dynamic alloca.
!MFI->hasCalls()) { // No calls.
StackSize = std::max((uint64_t)X86FI->getCalleeSavedFrameSize(),
StackSize > 128 ? StackSize - 128 : 0);
MFI->setStackSize(StackSize);
}
// Add RETADDR move area to callee saved frame size.
int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
if (TailCallReturnAddrDelta < 0)