return auto_vec from get_loop_hot_path
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Mon, 7 Jun 2021 00:13:38 +0000 (20:13 -0400)
committerTrevor Saunders <tbsaunde@tbsaunde.org>
Thu, 17 Jun 2021 08:43:27 +0000 (04:43 -0400)
This ensures callers take ownership of the returned vector.

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

* cfgloop.h (get_loop_hot_path): Return auto_vec<basic_block>.
* cfgloopanal.c (get_loop_hot_path): Likewise.
* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise.

gcc/cfgloop.h
gcc/cfgloopanal.c
gcc/tree-ssa-loop-ivcanon.c

index 113241d..5e69927 100644 (file)
@@ -840,7 +840,7 @@ enum
 
 extern void doloop_optimize_loops (void);
 extern void move_loop_invariants (void);
-extern vec<basic_block> get_loop_hot_path (const class loop *loop);
+extern auto_vec<basic_block> get_loop_hot_path (const class loop *loop);
 
 /* Returns the outermost loop of the loop nest that contains LOOP.*/
 static inline class loop *
index 54426b5..fdd8d3f 100644 (file)
@@ -500,7 +500,7 @@ single_likely_exit (class loop *loop, vec<edge> exits)
    order against direction of edges from latch.  Specially, if
    header != latch, latch is the 1-st block.  */
 
-vec<basic_block>
+auto_vec<basic_block>
 get_loop_hot_path (const class loop *loop)
 {
   basic_block bb = loop->header;
index 3f9e9d0..b1971f8 100644 (file)
@@ -218,7 +218,7 @@ tree_estimate_loop_size (class loop *loop, edge exit, edge edge_to_cancel,
   gimple_stmt_iterator gsi;
   unsigned int i;
   bool after_exit;
-  vec<basic_block> path = get_loop_hot_path (loop);
+  auto_vec<basic_block> path = get_loop_hot_path (loop);
 
   size->overall = 0;
   size->eliminated_by_peeling = 0;
@@ -342,7 +342,6 @@ tree_estimate_loop_size (class loop *loop, edge exit, edge edge_to_cancel,
              - size->last_iteration_eliminated_by_peeling) > upper_bound)
            {
               free (body);
-             path.release ();
              return true;
            }
        }
@@ -379,7 +378,7 @@ tree_estimate_loop_size (class loop *loop, edge exit, edge edge_to_cancel,
            size->num_branches_on_hot_path++;
        }
     }
-  path.release ();
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     fprintf (dump_file, "size: %i-%i, last_iteration: %i-%i\n", size->overall,
             size->eliminated_by_peeling, size->last_iteration,