Another attempt to fix prologue emission
authorAnton Korobeynikov <asl@math.spbu.ru>
Thu, 16 Jul 2009 14:16:26 +0000 (14:16 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Thu, 16 Jul 2009 14:16:26 +0000 (14:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76007 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SystemZ/SystemZInstrInfo.cpp
lib/Target/SystemZ/SystemZRegisterInfo.cpp

index 92418ac11f194f98dfd20db921220e37992d3183..4358a5186b34ec7ccd9025e0cace0571237d22c5 100644 (file)
@@ -265,9 +265,9 @@ SystemZInstrInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
 
 unsigned
 SystemZInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
-                              MachineBasicBlock *FBB,
+                               MachineBasicBlock *FBB,
                             const SmallVectorImpl<MachineOperand> &Cond) const {
-  // FIXME this should probably have a DebugLoc operand
+  // FIXME: this should probably have a DebugLoc operand
   DebugLoc dl = DebugLoc::getUnknownLoc();
   // Shouldn't be a fall through.
   assert(TBB && "InsertBranch must not be told to insert a fallthrough");
index deceb35284ae4c2a5548fbeb2ebafdd9987c84a0..dfd5336a204b8d032e5cd6c72e091a331b77c036 100644 (file)
@@ -143,10 +143,10 @@ SystemZRegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
   // if yes - mark it as 'callee' saved.
   MachineFrameInfo *FFI = MF.getFrameInfo();
 
-  if (FFI->hasCalls()
-      /* FIXME: function is varargs */
-      /* FIXME: function grabs RA */
-      /* FIXME: function calls eh_return */)
+  if (FFI->hasCalls())
+    /* FIXME: function is varargs */
+    /* FIXME: function grabs RA */
+    /* FIXME: function calls eh_return */
     MF.getRegInfo().setPhysRegUsed(SystemZ::R14D);
 
   if (FFI->hasCalls() ||
@@ -193,9 +193,10 @@ void SystemZRegisterInfo::emitPrologue(MachineFunction &MF) const {
   // Get the number of bytes to allocate from the FrameInfo.
   // Note that area for callee-saved stuff is already allocated, thus we need to
   // 'undo' the stack movement.
-  uint64_t StackSize =  MFI->getStackSize();
-  uint64_t NumBytes = StackSize - SystemZMFI->getCalleeSavedFrameSize();
-  NumBytes -= TFI.getOffsetOfLocalArea();
+  uint64_t StackSize = MFI->getStackSize();
+  StackSize -= SystemZMFI->getCalleeSavedFrameSize();
+
+  uint64_t NumBytes = StackSize - TFI.getOffsetOfLocalArea();
 
   // Skip the callee-saved push instructions.
   while (MBBI != MBB.end() &&
@@ -207,8 +208,11 @@ void SystemZRegisterInfo::emitPrologue(MachineFunction &MF) const {
     DL = MBBI->getDebugLoc();
 
   // adjust stack pointer: R15 -= numbytes
-  if (StackSize)
+  if (StackSize || MFI->hasCalls()) {
+    assert(MF.getRegInfo().isPhysRegUsed(SystemZ::R15D) &&
+           "Invalid stack frame calculation!");
     emitSPUpdate(MBB, MBBI, -(int64_t)NumBytes, TII);
+  }
 
   if (hasFP(MF)) {
     // Update R11 with the new base value...