diff options
author | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-04 00:15:08 +0000 |
---|---|---|
committer | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-04 00:15:08 +0000 |
commit | 961c8f7239d867d8320896dd626796af279903e8 (patch) | |
tree | 6dff999c194db54678145714a827cd983e40b506 /gcc | |
parent | ebdbcbb18eec68aee0796d9198931539b1947bbb (diff) | |
download | gcc-961c8f7239d867d8320896dd626796af279903e8.tar.gz |
PR middle-end/38584
* cfgexpand.c (estimate_stack_frame_size): Simplify the estimate:
Calculate the size of all stack vars assuming no packing of stack
vars will happen, replacing a quadratic algorithm with a linear one.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143040 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cfgexpand.c | 33 |
2 files changed, 22 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ce3c62a5892..2c5a9399979 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-01-04 Steven Bosscher <steven@gcc.gnu.org> + + PR middle-end/38584 + * cfgexpand.c (estimate_stack_frame_size): Simplify the estimate: + Calculate the size of all stack vars assuming no packing of stack + vars will happen, replacing a quadratic algorithm with a linear one. + 2009-01-03 Jakub Jelinek <jakub@redhat.com> PR target/38707 diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 6eaec30c98f..e0c328f3959 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -1392,16 +1392,23 @@ fini_vars_expansion (void) stack_vars_conflict_alloc = 0; } +/* Make a fair guess for the size of the stack frame of the current + function. This doesn't have to be exact, the result is only used + in the inline heuristics. So we don't want to run the full stack + var packing algorithm (which is quadratic in the number of stack + vars). Instead, we calculate the total size of all stack vars. + This turns out to be a pretty fair estimate -- packing of stack + vars doesn't happen very often. */ + HOST_WIDE_INT estimated_stack_frame_size (void) { HOST_WIDE_INT size = 0; + size_t i; tree t, outer_block = DECL_INITIAL (current_function_decl); init_vars_expansion (); - /* At this point all variables on the local_decls with TREE_USED - set are not associated with any block scope. Lay them out. */ for (t = cfun->local_decls; t; t = TREE_CHAIN (t)) { tree var = TREE_VALUE (t); @@ -1411,27 +1418,17 @@ estimated_stack_frame_size (void) TREE_USED (var) = 1; } size += account_used_vars_for_block (outer_block, true); + if (stack_vars_num > 0) { - /* Due to the way alias sets work, no variables with non-conflicting - alias sets may be assigned the same address. Add conflicts to - reflect this. */ - add_alias_set_conflicts (); - - /* If stack protection is enabled, we don't share space between - vulnerable data and non-vulnerable data. */ - if (flag_stack_protect) - add_stack_protection_conflicts (); - - /* Now that we have collected all stack variables, and have computed a - minimal interference graph, attempt to save some stack space. */ - partition_stack_vars (); - if (dump_file) - dump_stack_var_partition (); - + /* Fake sorting the stack vars for account_stack_vars (). */ + stack_vars_sorted = XNEWVEC (size_t, stack_vars_num); + for (i = 0; i < stack_vars_num; ++i) + stack_vars_sorted[i] = i; size += account_stack_vars (); fini_vars_expansion (); } + return size; } |