return auto_vec from more dominance functions
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Sat, 12 Jun 2021 23:36:38 +0000 (19:36 -0400)
committerTrevor Saunders <tbsaunde@tbsaunde.org>
Thu, 17 Jun 2021 08:43:28 +0000 (04:43 -0400)
This ensures the vector gets cleaned up by the caller when appropriate.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
gcc/ChangeLog:

* dominance.c (get_dominated_to_depth): Return auto_vec<basic_block>.
* dominance.h (get_dominated_to_depth): Likewise.
(get_all_dominated_blocks): Likewise.
* cfgcleanup.c (delete_unreachable_blocks): Adjust.
* gcse.c (hoist_code): Likewise.
* tree-cfg.c (remove_edge_and_dominated_blocks): Likewise.
* tree-parloops.c (oacc_entry_exit_ok): Likewise.
* tree-ssa-dce.c (eliminate_unnecessary_stmts): Likewise.
* tree-ssa-phiprop.c (pass_phiprop::execute): Likewise.

gcc/cfgcleanup.c
gcc/dominance.c
gcc/dominance.h
gcc/gcse.c
gcc/tree-cfg.c
gcc/tree-parloops.c
gcc/tree-ssa-dce.c
gcc/tree-ssa-phiprop.c

index 17edc4f..7b1e1ba 100644 (file)
@@ -3027,7 +3027,7 @@ delete_unreachable_blocks (void)
                delete_basic_block (b);
              else
                {
-                 vec<basic_block> h
+                 auto_vec<basic_block> h
                    = get_all_dominated_blocks (CDI_DOMINATORS, b);
 
                  while (h.length ())
@@ -3040,8 +3040,6 @@ delete_unreachable_blocks (void)
 
                      delete_basic_block (b);
                    }
-
-                 h.release ();
                }
 
              changed = true;
index 4943102..6a262ce 100644 (file)
@@ -933,10 +933,10 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region,
    produce a vector containing all dominated blocks.  The vector will be sorted
    in preorder.  */
 
-vec<basic_block> 
+auto_vec<basic_block> 
 get_dominated_to_depth (enum cdi_direction dir, basic_block bb, int depth)
 {
-  vec<basic_block> bbs = vNULL;
+  auto_vec<basic_block> bbs;
   unsigned i;
   unsigned next_level_start;
 
@@ -965,7 +965,7 @@ get_dominated_to_depth (enum cdi_direction dir, basic_block bb, int depth)
 /* Returns the list of basic blocks including BB dominated by BB, in the
    direction DIR.  The vector will be sorted in preorder.  */
 
-vec<basic_block> 
+auto_vec<basic_block> 
 get_all_dominated_blocks (enum cdi_direction dir, basic_block bb)
 {
   return get_dominated_to_depth (dir, bb, 0);
index c74ad29..1a8c248 100644 (file)
@@ -50,10 +50,10 @@ extern auto_vec<basic_block> get_dominated_by (enum cdi_direction, basic_block);
 extern auto_vec<basic_block> get_dominated_by_region (enum cdi_direction,
                                                         basic_block *,
                                                         unsigned);
-extern vec<basic_block> get_dominated_to_depth (enum cdi_direction,
-                                                       basic_block, int);
-extern vec<basic_block> get_all_dominated_blocks (enum cdi_direction,
-                                                         basic_block);
+extern auto_vec<basic_block> get_dominated_to_depth (enum cdi_direction,
+                                                    basic_block, int);
+extern auto_vec<basic_block> get_all_dominated_blocks (enum cdi_direction,
+                                                      basic_block);
 extern void redirect_immediate_dominators (enum cdi_direction, basic_block,
                                           basic_block);
 extern basic_block nearest_common_dominator (enum cdi_direction,
index 9114f30..ecf7e51 100644 (file)
@@ -3050,9 +3050,7 @@ static int
 hoist_code (void)
 {
   basic_block bb, dominated;
-  vec<basic_block> dom_tree_walk;
   unsigned int dom_tree_walk_index;
-  vec<basic_block> domby;
   unsigned int i, j, k;
   struct gcse_expr **index_map;
   struct gcse_expr *expr;
@@ -3106,15 +3104,16 @@ hoist_code (void)
   if (flag_ira_hoist_pressure)
     hoisted_bbs = BITMAP_ALLOC (NULL);
 
-  dom_tree_walk = get_all_dominated_blocks (CDI_DOMINATORS,
-                                           ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb);
+  auto_vec<basic_block> dom_tree_walk
+  = get_all_dominated_blocks (CDI_DOMINATORS,
+                             ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb);
 
   /* Walk over each basic block looking for potentially hoistable
      expressions, nothing gets hoisted from the entry block.  */
   FOR_EACH_VEC_ELT (dom_tree_walk, dom_tree_walk_index, bb)
     {
-      domby = get_dominated_to_depth (CDI_DOMINATORS, bb,
-                                     param_max_hoist_depth);
+      auto_vec<basic_block> domby
+       = get_dominated_to_depth (CDI_DOMINATORS, bb, param_max_hoist_depth);
 
       if (domby.length () == 0)
        continue;
@@ -3315,10 +3314,8 @@ hoist_code (void)
              bitmap_clear (from_bbs);
            }
        }
-      domby.release ();
     }
 
-  dom_tree_walk.release ();
   BITMAP_FREE (from_bbs);
   if (flag_ira_hoist_pressure)
     BITMAP_FREE (hoisted_bbs);
index c9403de..4c32f83 100644 (file)
@@ -8683,7 +8683,6 @@ gimple_flow_call_edges_add (sbitmap blocks)
 void
 remove_edge_and_dominated_blocks (edge e)
 {
-  vec<basic_block> bbs_to_remove = vNULL;
   vec<basic_block> bbs_to_fix_dom = vNULL;
   edge f;
   edge_iterator ei;
@@ -8734,6 +8733,7 @@ remove_edge_and_dominated_blocks (edge e)
     }
 
   auto_bitmap df, df_idom;
+  auto_vec<basic_block> bbs_to_remove;
   if (none_removed)
     bitmap_set_bit (df_idom,
                    get_immediate_dominator (CDI_DOMINATORS, e->dest)->index);
@@ -8800,7 +8800,6 @@ remove_edge_and_dominated_blocks (edge e)
 
   iterate_fix_dominators (CDI_DOMINATORS, bbs_to_fix_dom, true);
 
-  bbs_to_remove.release ();
   bbs_to_fix_dom.release ();
 }
 
index deff2d5..fe1baef 100644 (file)
@@ -3949,7 +3949,7 @@ oacc_entry_exit_ok (class loop *loop,
                    reduction_info_table_type *reduction_list)
 {
   basic_block *loop_bbs = get_loop_body_in_dom_order (loop);
-  vec<basic_block> region_bbs
+  auto_vec<basic_block> region_bbs
     = get_all_dominated_blocks (CDI_DOMINATORS, ENTRY_BLOCK_PTR_FOR_FN (cfun));
 
   bitmap in_loop_bbs = BITMAP_ALLOC (NULL);
@@ -3972,7 +3972,6 @@ oacc_entry_exit_ok (class loop *loop,
        }
     }
 
-  region_bbs.release ();
   free (loop_bbs);
 
   BITMAP_FREE (in_loop_bbs);
index def6ae6..e2d3b63 100644 (file)
@@ -1275,7 +1275,6 @@ eliminate_unnecessary_stmts (void)
   gimple_stmt_iterator gsi, psi;
   gimple *stmt;
   tree call;
-  vec<basic_block> h;
   auto_vec<edge> to_remove_edges;
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -1306,6 +1305,7 @@ eliminate_unnecessary_stmts (void)
 
      as desired.  */
   gcc_assert (dom_info_available_p (CDI_DOMINATORS));
+  auto_vec<basic_block> h;
   h = get_all_dominated_blocks (CDI_DOMINATORS,
                                single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
 
@@ -1460,7 +1460,6 @@ eliminate_unnecessary_stmts (void)
       something_changed |= remove_dead_phis (bb);
     }
 
-  h.release ();
 
   /* Since we don't track liveness of virtual PHI nodes, it is possible that we
      rendered some PHI nodes unreachable while they are still in use.
index 64d6eda..78b0461 100644 (file)
@@ -484,7 +484,6 @@ public:
 unsigned int
 pass_phiprop::execute (function *fun)
 {
-  vec<basic_block> bbs;
   struct phiprop_d *phivn;
   bool did_something = false;
   basic_block bb;
@@ -499,8 +498,9 @@ pass_phiprop::execute (function *fun)
   phivn = XCNEWVEC (struct phiprop_d, n);
 
   /* Walk the dominator tree in preorder.  */
-  bbs = get_all_dominated_blocks (CDI_DOMINATORS,
-                                 single_succ (ENTRY_BLOCK_PTR_FOR_FN (fun)));
+  auto_vec<basic_block> bbs
+  = get_all_dominated_blocks (CDI_DOMINATORS,
+                             single_succ (ENTRY_BLOCK_PTR_FOR_FN (fun)));
   FOR_EACH_VEC_ELT (bbs, i, bb)
     {
       /* Since we're going to move dereferences across predecessor
@@ -514,7 +514,6 @@ pass_phiprop::execute (function *fun)
   if (did_something)
     gsi_commit_edge_inserts ();
 
-  bbs.release ();
   free (phivn);
 
   free_dominance_info (CDI_POST_DOMINATORS);