aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/PrologEpilogInserter.cpp8
-rw-r--r--lib/Target/X86/X86RegisterInfo.cpp8
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp
index c52da32..10ba9c0 100644
--- a/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/lib/CodeGen/PrologEpilogInserter.cpp
@@ -459,15 +459,19 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
// 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.
+ // Also do this if we need runtime alignment of the stack. In this case
+ // offsets will be relative to SP not FP; round up the stack size so this
+ // works.
if (!RegInfo->targetHandlesStackFrameRounding() &&
- (FFI->hasCalls() || FFI->hasVarSizedObjects())) {
+ (FFI->hasCalls() || FFI->hasVarSizedObjects() ||
+ RegInfo->needsStackRealignment(Fn))) {
// If we have reserved argument space for call sites in the function
// immediately on entry to the current function, count it as part of the
// overall stack size.
if (RegInfo->hasReservedCallFrame(Fn))
Offset += FFI->getMaxCallFrameSize();
- unsigned AlignMask = TFI.getStackAlignment() - 1;
+ unsigned AlignMask = std::max(TFI.getStackAlignment(),MaxAlign) - 1;
Offset = (Offset + AlignMask) & ~uint64_t(AlignMask);
}
diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp
index 0bac850..b48cee3 100644
--- a/lib/Target/X86/X86RegisterInfo.cpp
+++ b/lib/Target/X86/X86RegisterInfo.cpp
@@ -302,11 +302,9 @@ X86RegisterInfo::getFrameIndexOffset(MachineFunction &MF, int FI) const {
// Skip the saved EBP
Offset += SlotSize;
else {
- unsigned MaxAlign = MF.getFrameInfo()->getMaxAlignment();
- uint64_t FrameSize =
- (StackSize - SlotSize + MaxAlign - 1)/MaxAlign*MaxAlign;
-
- return Offset + FrameSize - SlotSize;
+ unsigned Align = MF.getFrameInfo()->getObjectAlignment(FI);
+ assert( (-(Offset + StackSize)) % Align == 0);
+ return Offset + StackSize;
}
// FIXME: Support tail calls