diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-01-23 09:38:11 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-01-23 09:38:11 +0000 |
commit | 367372a30c36776e31958f0dc38306f32b80aa7c (patch) | |
tree | 79e5f97b48c73da206ac439af53ced76b447fe0b /lib/CodeGen/PrologEpilogInserter.cpp | |
parent | c9708122836670953b7f7b3a86cc263b63fe3e3e (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/CodeGen/PrologEpilogInserter.cpp')
-rw-r--r-- | lib/CodeGen/PrologEpilogInserter.cpp | 17 |
1 files changed, 16 insertions, 1 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 |