summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-propagate.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-propagate.c')
-rw-r--r--gcc/tree-ssa-propagate.c68
1 files changed, 31 insertions, 37 deletions
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index ca6fc336618..73dfa04ff72 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -128,7 +128,7 @@ static ssa_prop_visit_phi_fn ssa_prop_visit_phi;
static sbitmap executable_blocks;
/* Array of control flow edges on the worklist. */
-static VEC(basic_block,heap) *cfg_blocks;
+static vec<basic_block> cfg_blocks;
static unsigned int cfg_blocks_num = 0;
static int cfg_blocks_tail;
@@ -140,7 +140,7 @@ static sbitmap bb_in_list;
definition has changed. SSA edges are def-use edges in the SSA
web. For each D-U edge, we store the target statement or PHI node
U. */
-static GTY(()) VEC(gimple,gc) *interesting_ssa_edges;
+static GTY(()) vec<gimple, va_gc> *interesting_ssa_edges;
/* Identical to INTERESTING_SSA_EDGES. For performance reasons, the
list of SSA edges is split into two. One contains all SSA edges
@@ -156,7 +156,7 @@ static GTY(()) VEC(gimple,gc) *interesting_ssa_edges;
don't use a separate worklist for VARYING edges, we end up with
situations where lattice values move from
UNDEFINED->INTERESTING->VARYING instead of UNDEFINED->VARYING. */
-static GTY(()) VEC(gimple,gc) *varying_ssa_edges;
+static GTY(()) vec<gimple, va_gc> *varying_ssa_edges;
/* Return true if the block worklist empty. */
@@ -187,37 +187,33 @@ cfg_blocks_add (basic_block bb)
else
{
cfg_blocks_num++;
- if (cfg_blocks_num > VEC_length (basic_block, cfg_blocks))
+ if (cfg_blocks_num > cfg_blocks.length ())
{
/* We have to grow the array now. Adjust to queue to occupy
the full space of the original array. We do not need to
initialize the newly allocated portion of the array
because we keep track of CFG_BLOCKS_HEAD and
CFG_BLOCKS_HEAD. */
- cfg_blocks_tail = VEC_length (basic_block, cfg_blocks);
+ cfg_blocks_tail = cfg_blocks.length ();
cfg_blocks_head = 0;
- VEC_safe_grow (basic_block, heap, cfg_blocks, 2 * cfg_blocks_tail);
+ cfg_blocks.safe_grow (2 * cfg_blocks_tail);
}
/* Minor optimization: we prefer to see blocks with more
predecessors later, because there is more of a chance that
the incoming edges will be executable. */
else if (EDGE_COUNT (bb->preds)
- >= EDGE_COUNT (VEC_index (basic_block, cfg_blocks,
- cfg_blocks_head)->preds))
- cfg_blocks_tail = ((cfg_blocks_tail + 1)
- % VEC_length (basic_block, cfg_blocks));
+ >= EDGE_COUNT (cfg_blocks[cfg_blocks_head]->preds))
+ cfg_blocks_tail = ((cfg_blocks_tail + 1) % cfg_blocks.length ());
else
{
if (cfg_blocks_head == 0)
- cfg_blocks_head = VEC_length (basic_block, cfg_blocks);
+ cfg_blocks_head = cfg_blocks.length ();
--cfg_blocks_head;
head = true;
}
}
- VEC_replace (basic_block, cfg_blocks,
- head ? cfg_blocks_head : cfg_blocks_tail,
- bb);
+ cfg_blocks[head ? cfg_blocks_head : cfg_blocks_tail] = bb;
bitmap_set_bit (bb_in_list, bb->index);
}
@@ -229,13 +225,12 @@ cfg_blocks_get (void)
{
basic_block bb;
- bb = VEC_index (basic_block, cfg_blocks, cfg_blocks_head);
+ bb = cfg_blocks[cfg_blocks_head];
gcc_assert (!cfg_blocks_empty_p ());
gcc_assert (bb);
- cfg_blocks_head = ((cfg_blocks_head + 1)
- % VEC_length (basic_block, cfg_blocks));
+ cfg_blocks_head = ((cfg_blocks_head + 1) % cfg_blocks.length ());
--cfg_blocks_num;
bitmap_clear_bit (bb_in_list, bb->index);
@@ -262,9 +257,9 @@ add_ssa_edge (tree var, bool is_varying)
{
gimple_set_plf (use_stmt, STMT_IN_SSA_EDGE_WORKLIST, true);
if (is_varying)
- VEC_safe_push (gimple, gc, varying_ssa_edges, use_stmt);
+ vec_safe_push (varying_ssa_edges, use_stmt);
else
- VEC_safe_push (gimple, gc, interesting_ssa_edges, use_stmt);
+ vec_safe_push (interesting_ssa_edges, use_stmt);
}
}
}
@@ -360,15 +355,15 @@ simulate_stmt (gimple stmt)
SSA edge is added to it in simulate_stmt. */
static void
-process_ssa_edge_worklist (VEC(gimple,gc) **worklist)
+process_ssa_edge_worklist (vec<gimple, va_gc> **worklist)
{
/* Drain the entire worklist. */
- while (VEC_length (gimple, *worklist) > 0)
+ while ((*worklist)->length () > 0)
{
basic_block bb;
/* Pull the statement to simulate off the worklist. */
- gimple stmt = VEC_pop (gimple, *worklist);
+ gimple stmt = (*worklist)->pop ();
/* If this statement was already visited by simulate_block, then
we don't need to visit it again here. */
@@ -483,8 +478,8 @@ ssa_prop_init (void)
basic_block bb;
/* Worklists of SSA edges. */
- interesting_ssa_edges = VEC_alloc (gimple, gc, 20);
- varying_ssa_edges = VEC_alloc (gimple, gc, 20);
+ vec_alloc (interesting_ssa_edges, 20);
+ vec_alloc (varying_ssa_edges, 20);
executable_blocks = sbitmap_alloc (last_basic_block);
bitmap_clear (executable_blocks);
@@ -495,8 +490,8 @@ ssa_prop_init (void)
if (dump_file && (dump_flags & TDF_DETAILS))
dump_immediate_uses (dump_file);
- cfg_blocks = VEC_alloc (basic_block, heap, 20);
- VEC_safe_grow (basic_block, heap, cfg_blocks, 20);
+ cfg_blocks.create (20);
+ cfg_blocks.safe_grow_cleared (20);
/* Initially assume that every edge in the CFG is not executable.
(including the edges coming out of ENTRY_BLOCK_PTR). */
@@ -526,10 +521,9 @@ ssa_prop_init (void)
static void
ssa_prop_fini (void)
{
- VEC_free (gimple, gc, interesting_ssa_edges);
- VEC_free (gimple, gc, varying_ssa_edges);
- VEC_free (basic_block, heap, cfg_blocks);
- cfg_blocks = NULL;
+ vec_free (interesting_ssa_edges);
+ vec_free (varying_ssa_edges);
+ cfg_blocks.release ();
sbitmap_free (bb_in_list);
sbitmap_free (executable_blocks);
}
@@ -738,21 +732,21 @@ update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
tree fn = CALL_EXPR_FN (expr);
unsigned i;
unsigned nargs = call_expr_nargs (expr);
- VEC(tree, heap) *args = NULL;
+ vec<tree> args = vec<tree>();
gimple new_stmt;
if (nargs > 0)
{
- args = VEC_alloc (tree, heap, nargs);
- VEC_safe_grow (tree, heap, args, nargs);
+ args.create (nargs);
+ args.safe_grow_cleared (nargs);
for (i = 0; i < nargs; i++)
- VEC_replace (tree, args, i, CALL_EXPR_ARG (expr, i));
+ args[i] = CALL_EXPR_ARG (expr, i);
}
new_stmt = gimple_build_call_vec (fn, args);
finish_update_gimple_call (si_p, new_stmt, stmt);
- VEC_free (tree, heap, args);
+ args.release ();
return true;
}
@@ -827,8 +821,8 @@ ssa_propagate (ssa_prop_visit_stmt_fn visit_stmt,
/* Iterate until the worklists are empty. */
while (!cfg_blocks_empty_p ()
- || VEC_length (gimple, interesting_ssa_edges) > 0
- || VEC_length (gimple, varying_ssa_edges) > 0)
+ || interesting_ssa_edges->length () > 0
+ || varying_ssa_edges->length () > 0)
{
if (!cfg_blocks_empty_p ())
{