summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
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
commit6730e12ae4cd8ec0dd7d7da44b7c8c2c4e3746c0 (patch)
treeaf4ccf4f72da40dc06599d2bd68c4a4926d29f1c /llvm/lib/CodeGen
parentc4d201ea9a7bacef3833ff654d89130bd47b1855 (diff)
downloadbcm5719-llvm-6730e12ae4cd8ec0dd7d7da44b7c8c2c4e3746c0.tar.gz
bcm5719-llvm-6730e12ae4cd8ec0dd7d7da44b7c8c2c4e3746c0.zip
PEI is now responsible for adding MaxCallFrameSize to frame size and align the stack. Each target can further adjust the frame size if necessary.
llvm-svn: 33460
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/PrologEpilogInserter.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
index 616e2ac7efa..915fbc252bf 100644
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud