]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/38584 (Inline heuristics run even at -O0)
authorSteven Bosscher <steven@gcc.gnu.org>
Sun, 4 Jan 2009 00:15:08 +0000 (00:15 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Sun, 4 Jan 2009 00:15:08 +0000 (00:15 +0000)
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.

From-SVN: r143040

gcc/ChangeLog
gcc/cfgexpand.c

index ce3c62a58921be42320e20c30459ad4ac7cdcf36..2c5a9399979a5bcae2ad47d5c230e9497bc1df53 100644 (file)
@@ -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
index 6eaec30c98f6d5ad629acde4cf1793219b764ca0..e0c328f3959170ae5e30200c52bc8dd82827f7b6 100644 (file)
@@ -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;
 }