Round up stack to multiple of alignment only if it's a leaf function without alloca.
authorEvan Cheng <evan.cheng@apple.com>
Sat, 20 Jan 2007 10:22:33 +0000 (10:22 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Sat, 20 Jan 2007 10:22:33 +0000 (10:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33401 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMRegisterInfo.cpp

index 767be023a5a0cd50da9f4e48dfaaba71722ca483..979cb513ef94fb2055e129ff526c7f6db2830dc4 100644 (file)
@@ -917,14 +917,17 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
 
   // If necessary, add one more SUBri to account for the call frame
   // and/or local storage, alloca area.
-  if (MFI->hasCalls() && !hasFP(MF))
+  if (MFI->hasCalls() || MF.getFrameInfo()->hasVarSizedObjects()) {
     // We reserve argument space for call sites in the function immediately on
     // entry to the current function.  This eliminates the need for add/sub
     // brackets around call sites.
-    NumBytes += MFI->getMaxCallFrameSize();
+    if (!hasFP(MF))
+      NumBytes += MFI->getMaxCallFrameSize();
+
+    // Round the size to a multiple of the alignment.
+    NumBytes = (NumBytes+Align-1)/Align*Align;
+  }
 
-  // Round the size to a multiple of the alignment.
-  NumBytes = (NumBytes+Align-1)/Align*Align;
   MFI->setStackSize(NumBytes);
 
   // Determine starting offsets of spill areas.