[llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp

Evan Cheng evan.cheng at apple.com
Sat Jan 20 02:12:12 PST 2007



Changes in directory llvm/lib/Target/X86:

X86RegisterInfo.cpp updated: 1.190 -> 1.191
---
Log message:

Last check-in was bogus. There is no need to align the stack if the function is a leaf function (and without alloca).

---
Diffs of the changes:  (+6 -3)

 X86RegisterInfo.cpp |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)


Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.190 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.191
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.190	Fri Jan 19 20:08:16 2007
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp	Sat Jan 20 04:11:56 2007
@@ -991,6 +991,7 @@
   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<X86Subtarget>();
   MachineInstr *MI;
@@ -1004,9 +1005,11 @@
     //
     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);






More information about the llvm-commits mailing list