summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-01-16 02:20:12 +0000
committerChris Lattner <sabre@nondot.org>2003-01-16 02:20:12 +0000
commitb2809dc6b59f5c14f5d57278d21ad182cc8b1180 (patch)
tree86657bbf1763fdb285a78ff154333db02239685a /llvm/lib
parent9e75444c8b92916a1afeee58fdab0085ad906c5e (diff)
downloadbcm5719-llvm-b2809dc6b59f5c14f5d57278d21ad182cc8b1180.tar.gz
bcm5719-llvm-b2809dc6b59f5c14f5d57278d21ad182cc8b1180.zip
Implement code to keep the stack pointer aligned to an 8 byte boundary.
This improves the performance of the power benchmark by a few percent. This will be neccesary for SSE code, which requires 16 byte alignment of the stack. llvm-svn: 5320
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/InstSelectSimple.cpp2
-rw-r--r--llvm/lib/Target/X86/X86RegisterInfo.cpp13
-rw-r--r--llvm/lib/Target/X86/X86TargetMachine.cpp2
3 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/InstSelectSimple.cpp b/llvm/lib/Target/X86/InstSelectSimple.cpp
index ee8318f22d6..8351f09a07f 100644
--- a/llvm/lib/Target/X86/InstSelectSimple.cpp
+++ b/llvm/lib/Target/X86/InstSelectSimple.cpp
@@ -386,7 +386,7 @@ void ISel::LoadArgumentsToVirtualRegs(Function &Fn) {
// [ESP + 8] -- second argument, if first argument is four bytes in size
// ...
//
- unsigned ArgOffset = 4;
+ unsigned ArgOffset = 0; // Frame mechanisms handle retaddr slot
MachineFrameInfo *MFI = F->getFrameInfo();
for (Function::aiterator I = Fn.abegin(), E = Fn.aend(); I != E; ++I) {
diff --git a/llvm/lib/Target/X86/X86RegisterInfo.cpp b/llvm/lib/Target/X86/X86RegisterInfo.cpp
index ed347c21a0b..617c2d1efa7 100644
--- a/llvm/lib/Target/X86/X86RegisterInfo.cpp
+++ b/llvm/lib/Target/X86/X86RegisterInfo.cpp
@@ -13,6 +13,8 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetFrameInfo.h"
#include "Support/CommandLine.h"
namespace {
@@ -105,6 +107,12 @@ void X86RegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF,
// <amt>'
unsigned Amount = Old->getOperand(0).getImmedValue();
if (Amount != 0) {
+ // We need to keep the stack aligned properly. To do this, we round the
+ // amount of space needed for the outgoing arguments up to the next
+ // alignment boundary.
+ unsigned Align = MF.getTarget().getFrameInfo().getStackAlignment();
+ Amount = (Amount+Align-1)/Align*Align;
+
if (Old->getOpcode() == X86::ADJCALLSTACKDOWN) {
New=BuildMI(X86::SUBri32, 2, X86::ESP).addReg(X86::ESP).addZImm(Amount);
} else {
@@ -191,6 +199,11 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
//
NumBytes += MFI->getMaxCallFrameSize();
+ // Round the size to a multiple of the alignment (don't forget the 4 byte
+ // offset though).
+ unsigned Align = MF.getTarget().getFrameInfo().getStackAlignment();
+ NumBytes = ((NumBytes+4)+Align-1)/Align*Align - 4;
+
// Update frame info to pretend that this is part of the stack...
MFI->setStackSize(NumBytes);
}
diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index db846651fc2..c578ba83a67 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -37,7 +37,7 @@ X86TargetMachine::X86TargetMachine(unsigned Config)
1, 4,
(Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4,
(Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4),
- FrameInfo(TargetFrameInfo::StackGrowsDown, 1/*16*/, 0) {
+ FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4) {
}
/// addPassesToJITCompile - Add passes to the specified pass manager to
OpenPOWER on IntegriCloud