Include temp. values when computing max. size of stack frame!
authorVikram S. Adve <vadve@cs.uiuc.edu>
Sun, 31 Mar 2002 18:57:49 +0000 (18:57 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Sun, 31 Mar 2002 18:57:49 +0000 (18:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2070 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineCodeForMethod.h
include/llvm/CodeGen/MachineFunction.h
lib/CodeGen/MachineFunction.cpp

index d8f3339e1709bf6b647c9aa1816d4a849cf41979..01c9fd9d24f035c120be3c1af9961d5465776f0f 100644 (file)
@@ -29,6 +29,7 @@ class MachineCodeForMethod : private Annotation {
   unsigned     currentOptionalArgsSize;
   unsigned     maxOptionalArgsSize;
   unsigned     currentTmpValuesSize;
+  unsigned     maxTmpValuesSize;
   std::hash_set<const Constant*> constantsForConstPool;
   std::hash_map<const Value*, int> offsets;
   
@@ -108,6 +109,17 @@ private:
     regSpillsSize+= incr;
     staticStackSize += incr;
   }
+  inline void     incrementTmpAreaSize(int incr) {
+    currentTmpValuesSize += incr;
+    if (maxTmpValuesSize < currentTmpValuesSize)
+      {
+        staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
+        maxTmpValuesSize = currentTmpValuesSize;
+      }
+  }
+  inline void     resetTmpAreaSize() {
+    currentTmpValuesSize = 0;
+  }
   inline void     incrementCurrentOptionalArgsSize(int incr) {
     currentOptionalArgsSize+= incr;     // stack size already includes this!
   }
index d8f3339e1709bf6b647c9aa1816d4a849cf41979..01c9fd9d24f035c120be3c1af9961d5465776f0f 100644 (file)
@@ -29,6 +29,7 @@ class MachineCodeForMethod : private Annotation {
   unsigned     currentOptionalArgsSize;
   unsigned     maxOptionalArgsSize;
   unsigned     currentTmpValuesSize;
+  unsigned     maxTmpValuesSize;
   std::hash_set<const Constant*> constantsForConstPool;
   std::hash_map<const Value*, int> offsets;
   
@@ -108,6 +109,17 @@ private:
     regSpillsSize+= incr;
     staticStackSize += incr;
   }
+  inline void     incrementTmpAreaSize(int incr) {
+    currentTmpValuesSize += incr;
+    if (maxTmpValuesSize < currentTmpValuesSize)
+      {
+        staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
+        maxTmpValuesSize = currentTmpValuesSize;
+      }
+  }
+  inline void     resetTmpAreaSize() {
+    currentTmpValuesSize = 0;
+  }
   inline void     incrementCurrentOptionalArgsSize(int incr) {
     currentOptionalArgsSize+= incr;     // stack size already includes this!
   }
index de3e4f694f3e211875dd705a50fcdff8d59daddd..ef27dbae71c97500dbaf60741dddbabaa39ee549 100644 (file)
@@ -124,7 +124,7 @@ MachineCodeForMethod::MachineCodeForMethod(const Method* _M,
     method(_M), compiledAsLeaf(false), staticStackSize(0),
     automaticVarsSize(0), regSpillsSize(0),
     currentOptionalArgsSize(0), maxOptionalArgsSize(0),
-    currentTmpValuesSize(0)
+    currentTmpValuesSize(0), maxTmpValuesSize(0)
 {
   maxOptionalArgsSize = ComputeMaxOptionalArgsSize(target, method);
   staticStackSize = maxOptionalArgsSize
@@ -284,14 +284,14 @@ MachineCodeForMethod::pushTempValue(const TargetMachine& target,
   
   offset = growUp ? firstTmpOffset + offset : firstTmpOffset - offset;
   
-  currentTmpValuesSize += size;
+  incrementTmpAreaSize(size);
   return offset;
 }
 
 void
 MachineCodeForMethod::popAllTempValues(const TargetMachine& target)
 {
-  currentTmpValuesSize = 0;
+  resetTmpAreaSize();
 }
 
 int