]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Refactor RPO VN API to allow timevar tracking
authorRichard Biener <rguenther@suse.de>
Fri, 2 Sep 2022 12:10:40 +0000 (14:10 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 2 Sep 2022 12:55:53 +0000 (14:55 +0200)
The following refactors things sligtly so "utility" use of the RPO VN
machinery gets its own timevar when invoked from other passes.

* timevar.def (TV_TREE_RPO_VN): New.
* tree-ssa-sccvn.h (do_rpo_vn): Remove one overload.
* tree-ssa-sccvn.cc (do_rpo_vn_1): Rename the worker.
(do_rpo_vn): Unify the public API, track with TV_TREE_RPO_VN.
(pass_fre::execute): Adjust.
* tree-ssa-uninit.cc (execute_early_warn_uninitialized): Adjust.

gcc/timevar.def
gcc/tree-ssa-sccvn.cc
gcc/tree-ssa-sccvn.h
gcc/tree-ssa-uninit.cc

index 651af19876f00d0c83a457ebe901956828daddfe..eac4370431f019002f818fc4327b6e02aeabed51 100644 (file)
@@ -176,6 +176,7 @@ DEFTIMEVAR (TV_TREE_SPLIT_EDGES      , "tree split crit edges")
 DEFTIMEVAR (TV_TREE_REASSOC          , "tree reassociation")
 DEFTIMEVAR (TV_TREE_PRE                     , "tree PRE")
 DEFTIMEVAR (TV_TREE_FRE                     , "tree FRE")
+DEFTIMEVAR (TV_TREE_RPO_VN          , "tree RPO VN")
 DEFTIMEVAR (TV_TREE_SINK             , "tree code sinking")
 DEFTIMEVAR (TV_TREE_PHIOPT          , "tree linearize phis")
 DEFTIMEVAR (TV_TREE_BACKPROP        , "tree backward propagate")
index 5abc8667ce6045160bdddf7958ab0ce8fc5e56d9..74b8d8d18efcc43382bfb3b1b3358badbe8be597 100644 (file)
@@ -7290,14 +7290,14 @@ eliminate_with_rpo_vn (bitmap inserted_exprs)
   return walker.eliminate_cleanup ();
 }
 
-unsigned
-do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
-          bool iterate, bool eliminate, vn_lookup_kind kind);
+static unsigned
+do_rpo_vn_1 (function *fn, edge entry, bitmap exit_bbs,
+            bool iterate, bool eliminate, vn_lookup_kind kind);
 
 void
 run_rpo_vn (vn_lookup_kind kind)
 {
-  do_rpo_vn (cfun, NULL, NULL, true, false, kind);
+  do_rpo_vn_1 (cfun, NULL, NULL, true, false, kind);
 
   /* ???  Prune requirement of these.  */
   constant_to_value_id = new hash_table<vn_constant_hasher> (23);
@@ -7995,9 +7995,9 @@ do_unwind (unwind_state *to, rpo_elim &avail)
    executed and iterate.  If ELIMINATE is true then perform
    elimination, otherwise leave that to the caller.  */
 
-unsigned
-do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
-          bool iterate, bool eliminate, vn_lookup_kind kind)
+static unsigned
+do_rpo_vn_1 (function *fn, edge entry, bitmap exit_bbs,
+            bool iterate, bool eliminate, vn_lookup_kind kind)
 {
   unsigned todo = 0;
   default_vn_walk_kind = kind;
@@ -8415,12 +8415,18 @@ do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
 /* Region-based entry for RPO VN.  Performs value-numbering and elimination
    on the SEME region specified by ENTRY and EXIT_BBS.  If ENTRY is not
    the only edge into the region at ENTRY->dest PHI nodes in ENTRY->dest
-   are not considered.  */
+   are not considered.
+   If ITERATE is true then treat backedges optimistically as not
+   executed and iterate.  If ELIMINATE is true then perform
+   elimination, otherwise leave that to the caller.
+   KIND specifies the amount of work done for handling memory operations.  */
 
 unsigned
-do_rpo_vn (function *fn, edge entry, bitmap exit_bbs)
+do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
+          bool iterate, bool eliminate, vn_lookup_kind kind)
 {
-  unsigned todo = do_rpo_vn (fn, entry, exit_bbs, false, true, VN_WALKREWRITE);
+  auto_timevar tv (TV_TREE_RPO_VN);
+  unsigned todo = do_rpo_vn_1 (fn, entry, exit_bbs, iterate, eliminate, kind);
   free_rpo_vn ();
   return todo;
 }
@@ -8476,7 +8482,7 @@ pass_fre::execute (function *fun)
   if (iterate_p)
     loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
 
-  todo = do_rpo_vn (fun, NULL, NULL, iterate_p, true, VN_WALKREWRITE);
+  todo = do_rpo_vn_1 (fun, NULL, NULL, iterate_p, true, VN_WALKREWRITE);
   free_rpo_vn ();
 
   if (iterate_p)
index a1b1e6bdd1edc14179f14e247811b639b22ebe70..abcf7e666c2d6e12b7425d7f1d477abfc7e0769e 100644 (file)
@@ -295,8 +295,12 @@ value_id_constant_p (unsigned int v)
 tree fully_constant_vn_reference_p (vn_reference_t);
 tree vn_nary_simplify (vn_nary_op_t);
 
-unsigned do_rpo_vn (function *, edge, bitmap, bool, bool, vn_lookup_kind);
-unsigned do_rpo_vn (function *, edge, bitmap);
+unsigned do_rpo_vn (function *, edge, bitmap,
+                   /* iterate */ bool = false,
+                   /* eliminate */ bool = true,
+                   vn_lookup_kind = VN_WALKREWRITE);
+
+/* Private interface for PRE.  */
 void run_rpo_vn (vn_lookup_kind);
 unsigned eliminate_with_rpo_vn (bitmap);
 void free_rpo_vn (void);
index c25fbe6381e77655b66618416a643b06029252ff..29dc48c4a29e6082c7b158b534422338b1ffdf3a 100644 (file)
@@ -1466,10 +1466,7 @@ execute_early_warn_uninitialized (struct function *fun)
      elimination to compute edge reachability.  Don't bother when
      we only warn for unconditionally executed code though.  */
   if (!optimize)
-    {
-      do_rpo_vn (fun, NULL, NULL, false, false, VN_NOWALK);
-      free_rpo_vn ();
-    }
+    do_rpo_vn (fun, NULL, NULL, false, false, VN_NOWALK);
   else
     set_all_edges_as_executable (fun);