Include temp. values when computing max. size of stack frame!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2070 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/CodeGen/MachineCodeForMethod.h b/include/llvm/CodeGen/MachineCodeForMethod.h
index d8f3339..01c9fd9 100644
--- a/include/llvm/CodeGen/MachineCodeForMethod.h
+++ b/include/llvm/CodeGen/MachineCodeForMethod.h
@@ -29,6 +29,7 @@
   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 @@
     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!
   }
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index d8f3339..01c9fd9 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -29,6 +29,7 @@
   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 @@
     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!
   }
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index de3e4f6..ef27dba 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -124,7 +124,7 @@
     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 @@
   
   offset = growUp ? firstTmpOffset + offset : firstTmpOffset - offset;
   
-  currentTmpValuesSize += size;
+  incrementTmpAreaSize(size);
   return offset;
 }
 
 void
 MachineCodeForMethod::popAllTempValues(const TargetMachine& target)
 {
-  currentTmpValuesSize = 0;
+  resetTmpAreaSize();
 }
 
 int