Eastimate required stack alignment early, so we can decide, whether we will need...
authorAnton Korobeynikov <asl@math.spbu.ru>
Wed, 23 Apr 2008 18:20:17 +0000 (18:20 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Wed, 23 Apr 2008 18:20:17 +0000 (18:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50161 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86RegisterInfo.cpp
lib/Target/X86/X86RegisterInfo.h

index 46bf76f75780743fc2dcf7c48208876dbf499a54..2baf3601f01c03fb1f65b24f5cd8b8f0209e7b71 100644 (file)
@@ -371,6 +371,25 @@ void X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
   MI.getOperand(i+3).ChangeToImmediate(Offset);
 }
 
+void
+X86RegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
+                                                      RegScavenger *RS) const {
+  MachineFrameInfo *FFI = MF.getFrameInfo();
+
+  // Calculate and set max stack object alignment early, so we can decide
+  // whether we will need stack realignment (and thus FP).
+  unsigned MaxAlign = 0;
+  for (int i = FFI->getObjectIndexBegin(),
+         e = FFI->getObjectIndexEnd(); i != e; ++i) {
+    if (FFI->isDeadObjectIndex(i))
+      continue;
+    unsigned Align = FFI->getObjectAlignment(i);
+    MaxAlign = std::max(MaxAlign, Align);
+  }
+
+  FFI->setMaxAlignment(MaxAlign);
+}
+
 void
 X86RegisterInfo::processFunctionBeforeFrameFinalized(MachineFunction &MF) const{
   X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
index fdf74b11f56a1dd1fdd8fa1778820df1e1d1b723..40fdfb00e3e9cf6266313a1df3cb4f1f848ca1d6 100644 (file)
@@ -127,6 +127,8 @@ public:
                            int SPAdj, RegScavenger *RS = NULL) const;
 
   void processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
+  void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
+                                            RegScavenger *RS = NULL) const;
 
   void emitPrologue(MachineFunction &MF) const;
   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;