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

Chris Lattner lattner at cs.uiuc.edu
Mon Dec 16 21:16:00 PST 2002


Changes in directory llvm/lib/Target/X86:

X86RegisterInfo.cpp updated: 1.20 -> 1.21

---
Log message:

Round number of bytes allocated on the stack up to a multiple of 4 so that the
stack remains aligned


---
Diffs of the changes:

Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.20 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.21
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.20	Mon Dec 16 20:48:57 2002
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp	Mon Dec 16 21:15:26 2002
@@ -113,10 +113,13 @@
 }
 
 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 @@
   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);
 }
 





More information about the llvm-commits mailing list