[llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp X86RegisterInfo.cpp X86TargetMachine.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jan 15 20:21:00 PST 2003
Changes in directory llvm/lib/Target/X86:
InstSelectSimple.cpp updated: 1.82 -> 1.83
X86RegisterInfo.cpp updated: 1.29 -> 1.30
X86TargetMachine.cpp updated: 1.12 -> 1.13
---
Log message:
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.
---
Diffs of the changes:
Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.82 llvm/lib/Target/X86/InstSelectSimple.cpp:1.83
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.82 Tue Jan 14 15:59:16 2003
+++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Jan 15 20:20:12 2003
@@ -386,7 +386,7 @@
// [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) {
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.29 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.30
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.29 Wed Jan 15 16:57:35 2003
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp Wed Jan 15 20:20:12 2003
@@ -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 @@
// <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 {
@@ -190,6 +198,11 @@
// eliminates the need for add/sub ESP brackets around call sites.
//
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);
Index: llvm/lib/Target/X86/X86TargetMachine.cpp
diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.12 llvm/lib/Target/X86/X86TargetMachine.cpp:1.13
--- llvm/lib/Target/X86/X86TargetMachine.cpp:1.12 Sun Jan 12 18:51:23 2003
+++ llvm/lib/Target/X86/X86TargetMachine.cpp Wed Jan 15 20:20:12 2003
@@ -37,7 +37,7 @@
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
More information about the llvm-commits
mailing list