From 5ad334fbda276512e492a77601715e8e5e2b188e Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sat, 20 Jan 2007 10:11:56 +0000 Subject: [PATCH] Last check-in was bogus. There is no need to align the stack if the function is a leaf function (and without alloca). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33399 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86RegisterInfo.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index ac1b4ef0b38..477267ad56a 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -991,6 +991,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { MachineBasicBlock::iterator MBBI = MBB.begin(); MachineFrameInfo *MFI = MF.getFrameInfo(); unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); + unsigned AlignMask = Align - 1; const Function* Fn = MF.getFunction(); const X86Subtarget* Subtarget = &MF.getTarget().getSubtarget(); MachineInstr *MI; @@ -1004,9 +1005,11 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { // NumBytes += MFI->getMaxCallFrameSize(); - // Round the size to a multiple of the alignment (don't forget the 4/8 byte - // offset though). - NumBytes = ((NumBytes+SlotSize)+Align-1)/Align*Align - SlotSize; + // Round the size to a multiple of the alignment (don't forget the 4/8 byte + // offset pushed by the caller though). No need to align the stack if this + // is a leaf function. + NumBytes = (((NumBytes+SlotSize) + AlignMask) & ~AlignMask) - SlotSize; + } // Update frame info to pretend that this is part of the stack... MFI->setStackSize(NumBytes);