===================================================================
@@ -1311,6 +1311,29 @@ create_stack_guard (void)
crtl->stack_protect_guard = guard;
}
+/* A subroutine of expand_used_vars. Walk down through the BLOCK tree
+ expanding variables. Those variables that can be put into registers
+ are allocated pseudos; those that can't are put on the stack.
+
+ TOPLEVEL is true if this is the outermost BLOCK. */
+
+static HOST_WIDE_INT
+account_used_vars_for_block (tree block, bool toplevel)
+{
+ tree t;
+ HOST_WIDE_INT size = 0;
+
+ /* Expand all variables at this level. */
+ for (t = BLOCK_VARS (block); t ; t = DECL_CHAIN (t))
+ size += expand_one_var (t, toplevel, false);
+
+ /* Expand all variables at containing levels. */
+ for (t = BLOCK_SUBBLOCKS (block); t ; t = BLOCK_CHAIN (t))
+ size += account_used_vars_for_block (t, false);
+
+ return size;
+}
+
/* Prepare for expanding variables. */
static void
init_vars_expansion (void)
@@ -1354,7 +1377,10 @@ HOST_WIDE_INT
estimated_stack_frame_size (tree decl)
{
HOST_WIDE_INT size = 0;
+ HOST_WIDE_INT osize = 0;
+ unsigned ix;
size_t i;
+ tree outer_block = DECL_INITIAL (current_function_decl);
tree var;
tree old_cur_fun_decl = current_function_decl;
referenced_var_iterator rvi;
@@ -1378,6 +1404,11 @@ estimated_stack_frame_size (tree decl)
size += account_stack_vars ();
fini_vars_expansion ();
}
+
+ if (size != osize)
+ error ("est stack size changed from %li to %li",
+ (long)osize, (long)size);
+
pop_cfun ();
current_function_decl = old_cur_fun_decl;
return size;