Teach MachineFrameInfo to track maximum alignment while stack objects are being
[oota-llvm.git] / include / llvm / CodeGen / MachineFrameInfo.h
index 968e4eae3a695494ec11d1e04161339323aa9223..043e97f9a7cd3123f55424a4dac70cf9eaa21c2c 100644 (file)
@@ -276,6 +276,7 @@ public:
     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
            "Invalid Object Idx!");
     Objects[ObjectIdx+NumFixedObjects].Alignment = Align;
+    MaxAlignment = std::max(MaxAlignment, Align);
   }
 
   /// getObjectOffset - Return the assigned stack offset of the specified object
@@ -328,19 +329,6 @@ public:
   ///
   void setMaxAlignment(unsigned Align) { MaxAlignment = Align; }
 
-  /// calculateMaxStackAlignment() - If there is a local object which requires
-  /// greater alignment than the current max alignment, adjust accordingly.
-  void calculateMaxStackAlignment() {
-    for (int i = getObjectIndexBegin(),
-         e = getObjectIndexEnd(); i != e; ++i) {
-      if (isDeadObjectIndex(i))
-        continue;
-
-      unsigned Align = getObjectAlignment(i);
-      MaxAlignment = std::max(MaxAlignment, Align);
-    }
-  }
-
   /// hasCalls - Return true if the current function has no function calls.
   /// This is only valid during or after prolog/epilog code emission.
   ///
@@ -402,6 +390,7 @@ public:
     Objects.push_back(StackObject(Size, Alignment, 0, false, isSS));
     int Index = (int)Objects.size()-NumFixedObjects-1;
     assert(Index >= 0 && "Bad frame index!");
+    MaxAlignment = std::max(MaxAlignment, Alignment);
     return Index;
   }
 
@@ -412,6 +401,7 @@ public:
   int CreateSpillStackObject(uint64_t Size, unsigned Alignment) {
     CreateStackObject(Size, Alignment, true);
     int Index = (int)Objects.size()-NumFixedObjects-1;
+    MaxAlignment = std::max(MaxAlignment, Alignment);
     return Index;
   }