summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-12-17 03:15:26 +0000
committerChris Lattner <sabre@nondot.org>2002-12-17 03:15:26 +0000
commiteaf58b03b26ac6a55cd5ca48be6cac7808d27ede (patch)
tree51eeb67e92b022e777ed29e3923cba0efc816230
parentd9c6f2a6d3209b83dd507c617d0f70a01db4e96e (diff)
downloadbcm5719-llvm-eaf58b03b26ac6a55cd5ca48be6cac7808d27ede.tar.gz
bcm5719-llvm-eaf58b03b26ac6a55cd5ca48be6cac7808d27ede.zip
Round number of bytes allocated on the stack up to a multiple of 4 so that the
stack remains aligned llvm-svn: 5095
-rw-r--r--llvm/lib/Target/X86/X86RegisterInfo.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86RegisterInfo.cpp b/llvm/lib/Target/X86/X86RegisterInfo.cpp
index fc87a02e3b3..909a79cee70 100644
--- a/llvm/lib/Target/X86/X86RegisterInfo.cpp
+++ b/llvm/lib/Target/X86/X86RegisterInfo.cpp
@@ -113,10 +113,13 @@ const unsigned* X86RegisterInfo::getCallerSaveRegs() const {
}
void X86RegisterInfo::emitPrologue(MachineFunction &MF,
- unsigned numBytes) const {
+ unsigned NumBytes) const {
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
MachineBasicBlock::iterator MBBI = MBB.begin();
+ // Round stack allocation up to a nice alignment to keep the stack aligned
+ NumBytes = (NumBytes + 3) & ~3;
+
// PUSH ebp
MachineInstr *MI = BuildMI(X86::PUSHr32, 1).addReg(X86::EBP);
MBBI = ++MBB.insert(MBBI, MI);
@@ -126,7 +129,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF,
MBBI = ++MBB.insert(MBBI, MI);
// adjust stack pointer: ESP -= numbytes
- MI = BuildMI(X86::SUBri32, 2, X86::ESP).addReg(X86::ESP).addZImm(numBytes);
+ MI = BuildMI(X86::SUBri32, 2, X86::ESP).addReg(X86::ESP).addZImm(NumBytes);
MBBI = ++MBB.insert(MBBI, MI);
}
OpenPOWER on IntegriCloud