[llvm-commits] [llvm] r52750 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h lib/CodeGen/PrologEpilogInserter.cpp lib/Target/X86/X86RegisterInfo.cpp utils/TableGen/RegisterInfoEmitter.cpp
Dale Johannesen
dalej at apple.com
Wed Jun 25 18:51:13 PDT 2008
Author: johannes
Date: Wed Jun 25 20:51:13 2008
New Revision: 52750
URL: http://llvm.org/viewvc/llvm-project?rev=52750&view=rev
Log:
Fixes the last x86-64 test failure in compat.exp:
<16 x float> is 64-byte aligned (for some reason),
which gets us into the stack realignment code. The
computation changing FP-relative offsets to SP-relative
was broken, assiging a spill temp to a location
also used for parameter passing. This
fixes it by rounding up the stack frame to a multiple
of the largest alignment (I concluded it wasn't fixable
without doing this, but I'm not very sure.)
Modified:
llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=52750&r1=52749&r2=52750&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Wed Jun 25 20:51:13 2008
@@ -516,6 +516,13 @@
return !hasFP(MF);
}
+ // needsStackRealignment - true if storage within the function requires the
+ // stack pointer to be aligned more than the normal calling convention calls
+ // for.
+ virtual bool needsStackRealignment(const MachineFunction &MF) const {
+ return false;
+ }
+
/// getCallFrameSetup/DestroyOpcode - These methods return the opcode of the
/// frame setup/destroy instructions if they exist (-1 otherwise). Some
/// targets use pseudo instructions in order to abstract away the difference
Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=52750&r1=52749&r2=52750&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
+++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Wed Jun 25 20:51:13 2008
@@ -459,15 +459,19 @@
// 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);
}
Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=52750&r1=52749&r2=52750&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Jun 25 20:51:13 2008
@@ -302,11 +302,9 @@
// 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
Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=52750&r1=52749&r2=52750&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Wed Jun 25 20:51:13 2008
@@ -64,6 +64,8 @@
<< " virtual int getDwarfRegNumFull(unsigned RegNum, "
<< "unsigned Flavour) const;\n"
<< " virtual int getDwarfRegNum(unsigned RegNum, bool isEH) const = 0;\n"
+ << " virtual bool needsStackRealignment(const MachineFunction &) const\n"
+ << " { return false; }\n"
<< " unsigned getSubReg(unsigned RegNo, unsigned Index) const;\n"
<< "};\n\n";
More information about the llvm-commits
mailing list