aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-01-23 09:38:11 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-01-23 09:38:11 +0000
commit367372a30c36776e31958f0dc38306f32b80aa7c (patch)
tree79e5f97b48c73da206ac439af53ced76b447fe0b /lib
parentc9708122836670953b7f7b3a86cc263b63fe3e3e (diff)
PEI is now responsible for adding MaxCallFrameSize to frame size and align the stack. Each target can further adjust the frame size if necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33460 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/PrologEpilogInserter.cpp17
-rw-r--r--lib/Target/ARM/ARMRegisterInfo.cpp15
-rw-r--r--lib/Target/Alpha/AlphaRegisterInfo.cpp10
-rw-r--r--lib/Target/IA64/IA64RegisterInfo.cpp7
-rw-r--r--lib/Target/X86/X86RegisterInfo.cpp17
5 files changed, 16 insertions, 50 deletions
diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp
index 616e2ac7ef..915fbc252b 100644
--- a/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/lib/CodeGen/PrologEpilogInserter.cpp
@@ -386,7 +386,22 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
}
}
- // Set the final value of the stack pointer...
+ // Round up the size to a multiple of the alignment, but only if there are
+ // calls or alloca's in the function. This ensures that any calls to
+ // subroutines have their stack frames suitable aligned.
+ if (FFI->hasCalls() || FFI->hasVarSizedObjects()) {
+ // When we have no frame pointer, we reserve argument space for call sites
+ // in the function immediately on entry to the current function. This
+ // eliminates the need for add/sub sp brackets around call sites.
+ const MRegisterInfo *RegInfo = Fn.getTarget().getRegisterInfo();
+ if (!RegInfo->hasFP(Fn))
+ Offset += FFI->getMaxCallFrameSize();
+
+ unsigned AlignMask = TFI.getStackAlignment() - 1;
+ Offset = (Offset + AlignMask) & ~AlignMask;
+ }
+
+ // Update frame info to pretend that this is part of the stack...
FFI->setStackSize(Offset+TFI.getOffsetOfLocalArea());
// Remember the required stack alignment in case targets need it to perform
diff --git a/lib/Target/ARM/ARMRegisterInfo.cpp b/lib/Target/ARM/ARMRegisterInfo.cpp
index 2b179cf821..1338a99b0a 100644
--- a/lib/Target/ARM/ARMRegisterInfo.cpp
+++ b/lib/Target/ARM/ARMRegisterInfo.cpp
@@ -915,21 +915,6 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
}
}
- // If necessary, add one more SUBri to account for the call frame
- // and/or local storage, alloca area.
- if (MFI->hasCalls() || MF.getFrameInfo()->hasVarSizedObjects()) {
- // We reserve argument space for call sites in the function immediately on
- // entry to the current function. This eliminates the need for add/sub
- // brackets around call sites.
- if (!hasFP(MF))
- NumBytes += MFI->getMaxCallFrameSize();
-
- // Round the size to a multiple of the alignment.
- NumBytes = (NumBytes+Align-1)/Align*Align;
- }
-
- MFI->setStackSize(NumBytes);
-
// Determine starting offsets of spill areas.
if (AFI->hasStackFrame()) {
unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize);
diff --git a/lib/Target/Alpha/AlphaRegisterInfo.cpp b/lib/Target/Alpha/AlphaRegisterInfo.cpp
index 37d4deed55..bee76a2146 100644
--- a/lib/Target/Alpha/AlphaRegisterInfo.cpp
+++ b/lib/Target/Alpha/AlphaRegisterInfo.cpp
@@ -302,16 +302,6 @@ void AlphaRegisterInfo::emitPrologue(MachineFunction &MF) const {
// Get the number of bytes to allocate from the FrameInfo
long NumBytes = MFI->getStackSize();
- if (MFI->hasCalls() && !FP) {
- // We reserve argument space for call sites in the function immediately on
- // entry to the current function. This eliminates the need for add/sub
- // brackets around call sites.
- //If there is a frame pointer, then we don't do this
- NumBytes += MFI->getMaxCallFrameSize();
- DOUT << "Added " << MFI->getMaxCallFrameSize()
- << " to the stack due to calls\n";
- }
-
if (FP)
NumBytes += 8; //reserve space for the old FP
diff --git a/lib/Target/IA64/IA64RegisterInfo.cpp b/lib/Target/IA64/IA64RegisterInfo.cpp
index bd62852013..cb9918fcb2 100644
--- a/lib/Target/IA64/IA64RegisterInfo.cpp
+++ b/lib/Target/IA64/IA64RegisterInfo.cpp
@@ -256,13 +256,6 @@ void IA64RegisterInfo::emitPrologue(MachineFunction &MF) const {
// Get the number of bytes to allocate from the FrameInfo
unsigned NumBytes = MFI->getStackSize();
- if (MFI->hasCalls() && !FP) {
- // We reserve argument space for call sites in the function immediately on
- // entry to the current function. This eliminates the need for add/sub
- // brackets around call sites.
- NumBytes += MFI->getMaxCallFrameSize();
- }
-
if(FP)
NumBytes += 8; // reserve space for the old FP
diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp
index 1ca0f465ff..1b05c04540 100644
--- a/lib/Target/X86/X86RegisterInfo.cpp
+++ b/lib/Target/X86/X86RegisterInfo.cpp
@@ -991,29 +991,12 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineBasicBlock::iterator MBBI = MBB.begin();
MachineFrameInfo *MFI = MF.getFrameInfo();
unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
- unsigned AlignMask = Align - 1;
const Function* Fn = MF.getFunction();
const X86Subtarget* Subtarget = &MF.getTarget().getSubtarget<X86Subtarget>();
MachineInstr *MI;
// Get the number of bytes to allocate from the FrameInfo
unsigned NumBytes = MFI->getStackSize();
- if (MFI->hasCalls() || MFI->hasVarSizedObjects()) {
- // When we have no frame pointer, we reserve argument space for call sites
- // in the function immediately on entry to the current function. This
- // eliminates the need for add/sub ESP brackets around call sites.
- //
- if (!hasFP(MF))
- NumBytes += MFI->getMaxCallFrameSize();
-
- // Round the size to a multiple of the alignment (don't forget the 4/8 byte
- // offset pushed by the caller though). No need to align the stack if this
- // is a leaf function.
- NumBytes = (((NumBytes+SlotSize) + AlignMask) & ~AlignMask) - SlotSize;
- }
-
- // Update frame info to pretend that this is part of the stack...
- MFI->setStackSize(NumBytes);
if (NumBytes) { // adjust stack pointer: ESP -= numbytes
if (NumBytes >= 4096 && Subtarget->isTargetCygMing()) {