+2017-05-13 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
+
+ * cfganal.c (inverted_post_order_compute): Change argument type
+ to vec *.
+ * cfganal.h (inverted_post_order_compute): Adjust prototype.
+ * df-core.c (rest_of_handle_df_initialize): Adjust.
+ (rest_of_handle_df_finish): Likewise.
+ (df_analyze_1): Likewise.
+ (df_analyze): Likewise.
+ (loop_inverted_post_order_compute): Change argument to be a vec *.
+ (df_analyze_loop): Adjust.
+ (df_get_n_blocks): Likewise.
+ (df_get_postorder): Likewise.
+ * df.h (struct df_d): Change field to be a vec.
+ * lcm.c (compute_laterin): Adjust.
+ (compute_available): Likewise.
+ * lra-lives.c (lra_create_live_ranges_1): Likewise.
+ * tree-ssa-dce.c (remove_dead_stmt): Likewise.
+ * tree-ssa-pre.c (compute_antic): Likewise.
+
2017-05-13 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* cfganal.c (connect_infinite_loops_to_exit): Adjust.
and start looking for a "dead end" from that block
and do another inverted traversal from that block. */
-int
-inverted_post_order_compute (int *post_order,
+void
+inverted_post_order_compute (vec<int> *post_order,
sbitmap *start_points)
{
basic_block bb;
- int post_order_num = 0;
+ post_order->reserve_exact (n_basic_blocks_for_fn (cfun));
if (flag_checking)
verify_no_unreachable_blocks ();
time, check its predecessors. */
stack.quick_push (ei_start (pred->preds));
else
- post_order[post_order_num++] = pred->index;
+ post_order->quick_push (pred->index);
}
else
{
if (bb != EXIT_BLOCK_PTR_FOR_FN (cfun)
&& ei_one_before_end_p (ei))
- post_order[post_order_num++] = bb->index;
+ post_order->quick_push (bb->index);
if (!ei_one_before_end_p (ei))
ei_next (&stack.last ());
while (!stack.is_empty ());
/* EXIT_BLOCK is always included. */
- post_order[post_order_num++] = EXIT_BLOCK;
-
- return post_order_num;
+ post_order->quick_push (EXIT_BLOCK);
}
/* Compute the depth first search order of FN and store in the array
extern void connect_infinite_loops_to_exit (void);
extern int post_order_compute (int *, bool, bool);
extern basic_block dfs_find_deadend (basic_block);
-extern int inverted_post_order_compute (int *, sbitmap *start_points = 0);
+extern void inverted_post_order_compute (vec<int> *postorder, sbitmap *start_points = 0);
extern int pre_and_rev_post_order_compute_fn (struct function *,
int *, int *, bool);
extern int pre_and_rev_post_order_compute (int *, int *, bool);
df_live_add_problem ();
df->postorder = XNEWVEC (int, last_basic_block_for_fn (cfun));
- df->postorder_inverted = XNEWVEC (int, last_basic_block_for_fn (cfun));
df->n_blocks = post_order_compute (df->postorder, true, true);
- df->n_blocks_inverted = inverted_post_order_compute (df->postorder_inverted);
- gcc_assert (df->n_blocks == df->n_blocks_inverted);
+ inverted_post_order_compute (&df->postorder_inverted);
+ gcc_assert ((unsigned) df->n_blocks == df->postorder_inverted.length ());
df->hard_regs_live_count = XCNEWVEC (unsigned int, FIRST_PSEUDO_REGISTER);
}
free (df->postorder);
- free (df->postorder_inverted);
+ df->postorder_inverted.release ();
free (df->hard_regs_live_count);
free (df);
df = NULL;
int i;
/* These should be the same. */
- gcc_assert (df->n_blocks == df->n_blocks_inverted);
+ gcc_assert ((unsigned) df->n_blocks == df->postorder_inverted.length ());
/* We need to do this before the df_verify_all because this is
not kept incrementally up to date. */
if (dflow->problem->dir == DF_FORWARD)
df_analyze_problem (dflow,
df->blocks_to_analyze,
- df->postorder_inverted,
- df->n_blocks_inverted);
+ df->postorder_inverted.address (),
+ df->postorder_inverted.length ());
else
df_analyze_problem (dflow,
df->blocks_to_analyze,
df_analyze (void)
{
bitmap current_all_blocks = BITMAP_ALLOC (&df_bitmap_obstack);
- int i;
free (df->postorder);
- free (df->postorder_inverted);
df->postorder = XNEWVEC (int, last_basic_block_for_fn (cfun));
- df->postorder_inverted = XNEWVEC (int, last_basic_block_for_fn (cfun));
df->n_blocks = post_order_compute (df->postorder, true, true);
- df->n_blocks_inverted = inverted_post_order_compute (df->postorder_inverted);
+ df->postorder_inverted.truncate (0);
+ inverted_post_order_compute (&df->postorder_inverted);
- for (i = 0; i < df->n_blocks; i++)
+ for (int i = 0; i < df->n_blocks; i++)
bitmap_set_bit (current_all_blocks, df->postorder[i]);
if (flag_checking)
{
/* Verify that POSTORDER_INVERTED only contains blocks reachable from
the ENTRY block. */
- for (i = 0; i < df->n_blocks_inverted; i++)
+ for (unsigned int i = 0; i < df->postorder_inverted.length (); i++)
gcc_assert (bitmap_bit_p (current_all_blocks,
df->postorder_inverted[i]));
}
bitmap_and_into (df->blocks_to_analyze, current_all_blocks);
df->n_blocks = df_prune_to_subcfg (df->postorder,
df->n_blocks, df->blocks_to_analyze);
- df->n_blocks_inverted = df_prune_to_subcfg (df->postorder_inverted,
- df->n_blocks_inverted,
+ unsigned int newlen = df_prune_to_subcfg (df->postorder_inverted.address (),
+ df->postorder_inverted.length (),
df->blocks_to_analyze);
+ df->postorder_inverted.truncate (newlen);
BITMAP_FREE (current_all_blocks);
}
else
/* Compute the reverse top sort order of the inverted sub-CFG specified
by LOOP. Returns the number of blocks which is always loop->num_nodes. */
-static int
-loop_inverted_post_order_compute (int *post_order, struct loop *loop)
+static void
+loop_inverted_post_order_compute (vec<int> *post_order, struct loop *loop)
{
basic_block bb;
edge_iterator *stack;
int sp;
- int post_order_num = 0;
+
+ post_order->reserve_exact (loop->num_nodes);
/* Allocate stack for back-tracking up CFG. */
stack = XNEWVEC (edge_iterator, loop->num_nodes + 1);
time, check its predecessors. */
stack[sp++] = ei_start (pred->preds);
else
- post_order[post_order_num++] = pred->index;
+ post_order->quick_push (pred->index);
}
else
{
if (flow_bb_inside_loop_p (loop, bb)
&& ei_one_before_end_p (ei))
- post_order[post_order_num++] = bb->index;
+ post_order->quick_push (bb->index);
if (!ei_one_before_end_p (ei))
ei_next (&stack[sp - 1]);
}
free (stack);
- return post_order_num;
}
df_analyze_loop (struct loop *loop)
{
free (df->postorder);
- free (df->postorder_inverted);
df->postorder = XNEWVEC (int, loop->num_nodes);
- df->postorder_inverted = XNEWVEC (int, loop->num_nodes);
+ df->postorder_inverted.truncate (0);
df->n_blocks = loop_post_order_compute (df->postorder, loop);
- df->n_blocks_inverted
- = loop_inverted_post_order_compute (df->postorder_inverted, loop);
+ loop_inverted_post_order_compute (&df->postorder_inverted, loop);
gcc_assert ((unsigned) df->n_blocks == loop->num_nodes);
- gcc_assert ((unsigned) df->n_blocks_inverted == loop->num_nodes);
+ gcc_assert (df->postorder_inverted.length () == loop->num_nodes);
bitmap blocks = BITMAP_ALLOC (&df_bitmap_obstack);
for (int i = 0; i < df->n_blocks; ++i)
if (dir == DF_FORWARD)
{
- gcc_assert (df->postorder_inverted);
- return df->n_blocks_inverted;
+ gcc_assert (df->postorder_inverted.length ());
+ return df->postorder_inverted.length ();
}
gcc_assert (df->postorder);
if (dir == DF_FORWARD)
{
- gcc_assert (df->postorder_inverted);
- return df->postorder_inverted;
+ gcc_assert (df->postorder_inverted.length ());
+ return df->postorder_inverted.address ();
}
gcc_assert (df->postorder);
return df->postorder;
bitmap_head insns_to_notes_rescan;
int *postorder; /* The current set of basic blocks
in reverse postorder. */
- int *postorder_inverted; /* The current set of basic blocks
+ vec<int> postorder_inverted; /* The current set of basic blocks
in reverse postorder of inverted CFG. */
int n_blocks; /* The number of blocks in reverse postorder. */
- int n_blocks_inverted; /* The number of blocks
- in reverse postorder of inverted CFG. */
/* An array [FIRST_PSEUDO_REGISTER], indexed by regno, of the number
of refs that qualify as being real hard regs uses. Artificial
/* Add all the blocks to the worklist. This prevents an early exit from
the loop given our optimistic initialization of LATER above. */
- int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
- int postorder_num = inverted_post_order_compute (postorder);
- for (int i = 0; i < postorder_num; ++i)
+ auto_vec<int, 20> postorder;
+ inverted_post_order_compute (&postorder);
+ for (unsigned int i = 0; i < postorder.length (); ++i)
{
bb = BASIC_BLOCK_FOR_FN (cfun, postorder[i]);
if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
*qin++ = bb;
bb->aux = bb;
}
- free (postorder);
/* Note that we do not use the last allocated element for our queue,
as EXIT_BLOCK is never inserted into it. */
/* Put every block on the worklist; this is necessary because of the
optimistic initialization of AVOUT above. Use inverted postorder
to make the dataflow problem require less iterations. */
- int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
- int postorder_num = inverted_post_order_compute (postorder);
- for (int i = 0; i < postorder_num; ++i)
+ auto_vec<int, 20> postorder;
+ inverted_post_order_compute (&postorder);
+ for (unsigned int i = 0; i < postorder.length (); ++i)
{
bb = BASIC_BLOCK_FOR_FN (cfun, postorder[i]);
if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
*qin++ = bb;
bb->aux = bb;
}
- free (postorder);
qin = worklist;
qend = &worklist[n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS];
point_freq_vec.truncate (0);
point_freq_vec.reserve_exact (new_length);
lra_point_freq = point_freq_vec.address ();
- int *post_order_rev_cfg = XNEWVEC (int, last_basic_block_for_fn (cfun));
- int n_blocks_inverted = inverted_post_order_compute (post_order_rev_cfg);
- lra_assert (n_blocks_inverted == n_basic_blocks_for_fn (cfun));
+ auto_vec<int, 20> post_order_rev_cfg;
+ inverted_post_order_compute (&post_order_rev_cfg);
+ lra_assert (post_order_rev_cfg.length () == (unsigned) n_basic_blocks_for_fn (cfun));
bb_live_change_p = false;
- for (i = n_blocks_inverted - 1; i >= 0; --i)
+ for (i = post_order_rev_cfg.length () - 1; i >= 0; --i)
{
bb = BASIC_BLOCK_FOR_FN (cfun, post_order_rev_cfg[i]);
if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb
}
}
}
- free (post_order_rev_cfg);
lra_live_max_point = curr_point;
if (lra_dump_file != NULL)
print_live_ranges (lra_dump_file);
{
if (!bb_postorder)
{
- int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
- int postorder_num
- = inverted_post_order_compute (postorder,
- &bb_contains_live_stmts);
+ auto_vec<int, 20> postorder;
+ inverted_post_order_compute (&postorder,
+ &bb_contains_live_stmts);
bb_postorder = XNEWVEC (int, last_basic_block_for_fn (cfun));
- for (int i = 0; i < postorder_num; ++i)
+ for (unsigned int i = 0; i < postorder.length (); ++i)
bb_postorder[postorder[i]] = i;
- free (postorder);
}
FOR_EACH_EDGE (e2, ei, bb->succs)
if (!e || e2->dest == EXIT_BLOCK_PTR_FOR_FN (cfun)
/* For ANTIC computation we need a postorder that also guarantees that
a block with a single successor is visited after its successor.
RPO on the inverted CFG has this property. */
- int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
- int postorder_num = inverted_post_order_compute (postorder);
+ auto_vec<int, 20> postorder;
+ inverted_post_order_compute (&postorder);
auto_sbitmap worklist (last_basic_block_for_fn (cfun) + 1);
bitmap_ones (worklist);
for PA ANTIC computation. */
num_iterations++;
changed = false;
- for (i = postorder_num - 1; i >= 0; i--)
+ for (i = postorder.length () - 1; i >= 0; i--)
{
if (bitmap_bit_p (worklist, postorder[i]))
{
{
/* For partial antic we ignore backedges and thus we do not need
to perform any iteration when we process blocks in postorder. */
- postorder_num = pre_and_rev_post_order_compute (NULL, postorder, false);
+ int postorder_num = pre_and_rev_post_order_compute (NULL, postorder.address (), false);
for (i = postorder_num - 1 ; i >= 0; i--)
{
basic_block block = BASIC_BLOCK_FOR_FN (cfun, postorder[i]);
}
sbitmap_free (has_abnormal_preds);
- free (postorder);
}