diff mbox

Call flush_ssaname_freelist more often

Message ID 562AB5F1.3070701@redhat.com
State New
Headers show

Commit Message

Jeff Law Oct. 23, 2015, 10:34 p.m. UTC
As requested by Richi, this makes flushing more frequent by always 
flushing in execute_todo rather than flushing only after cleaning the CFG.

This slightly improves how often we re-use SSA_NAMEs rather than 
allocating new ones.  It also allows us to slightly simplify the 
release_ssa_names pass.

This patch also makes gathering of statistics unconditional in the name 
manager.  It's kindof silly to have to rebuild the compiler to get such 
simple data.

Bootstrapped and regression tested on x86_64-linux-gnu.  Installed on 
the trunk.

Jeff
commit cc47fe9e7be7c06be08d7fe034f16d1e32873104
Author: Jeff Law <law@redhat.com>
Date:   Fri Oct 23 16:33:27 2015 -0600

    [PATCH] Call flush_ssaname_freelist more often
           * passes.c (execute_function_todo): Do not call flush_ssaname_freelist
            here.  Instead...
            (execute_todo): Call it here.
            * tree-ssanames.c (make_ssa_name_fn): Unconditionally gather reuse
            statistics
            (pass_release_ssa_names::execute): Do not call flusH_ssaname_freelist.
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7234019..77fe678 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@ 
+2015-10-23  Jeff Law  <law@redhat.com>
+
+	* passes.c (execute_function_todo): Do not call flush_ssaname_freelist
+	here.  Instead...
+	(execute_todo): Call it here.
+	* tree-ssanames.c (make_ssa_name_fn): Unconditionally gather reuse
+	statistics
+	(pass_release_ssa_names::execute): Do not call flusH_ssaname_freelist.
+
 2015-10-23  Gregor Richards  <gregor.richards@uwaterloo.ca>
 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
 
diff --git a/gcc/passes.c b/gcc/passes.c
index 6ef6d2e..0d147fd 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1919,14 +1919,6 @@  execute_function_todo (function *fn, void *data)
     {
       cleanup_tree_cfg ();
 
-      /* Once unreachable nodes have been removed from the CFG,
-	 there can't be any lingering references to released
-	 SSA_NAMES (because there is no more unreachable code).
-
-	 Thus, now is the time to flush the SSA_NAMEs freelist.  */
-      if (fn->gimple_df)
-	flush_ssaname_freelist ();
-
       /* When cleanup_tree_cfg merges consecutive blocks, it may
 	 perform some simplistic propagation when removing single
 	 valued PHI nodes.  This propagation may, in turn, cause the
@@ -2032,6 +2024,11 @@  execute_todo (unsigned int flags)
   if (flags)
     do_per_function (execute_function_todo, (void *)(size_t) flags);
 
+  /* At this point we should not have any unreachable code in the
+     CFG, so it is safe to flush the pending freelist for SSA_NAMES.  */
+  if (cfun && cfun->gimple_df)
+    flush_ssaname_freelist ();
+
   /* Always remove functions just as before inlining: IPA passes might be
      interested to see bodies of extern inline functions that are not inlined
      to analyze side effects.  The full removal is done just at the end
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 82fd4a1..4be0e53 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -151,8 +151,7 @@  make_ssa_name_fn (struct function *fn, tree var, gimple *stmt)
   if (!vec_safe_is_empty (FREE_SSANAMES (fn)))
     {
       t = FREE_SSANAMES (fn)->pop ();
-      if (GATHER_STATISTICS)
-	ssa_name_nodes_reused++;
+      ssa_name_nodes_reused++;
 
       /* The node was cleared out when we put it on the free list, so
 	 there is no need to do so again here.  */
@@ -164,8 +163,7 @@  make_ssa_name_fn (struct function *fn, tree var, gimple *stmt)
       t = make_node (SSA_NAME);
       SSA_NAME_VERSION (t) = SSANAMES (fn)->length ();
       vec_safe_push (SSANAMES (fn), t);
-      if (GATHER_STATISTICS)
-	ssa_name_nodes_created++;
+      ssa_name_nodes_created++;
     }
 
   if (TYPE_P (var))
@@ -646,7 +644,6 @@  unsigned int
 pass_release_ssa_names::execute (function *fun)
 {
   unsigned i, j;
-  flush_ssaname_freelist ();
   int n = vec_safe_length (FREE_SSANAMES (fun));
 
   /* Now release the freelist.  */