aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2004-11-23 23:38:12 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2004-11-23 18:38:12 -0500
commitceb7eb8f8c513d895c3520637274f21b791dbf06 (patch)
tree51f2ca2fdcb72af01011b01dd31247e044e32f9a /gcc/tree-ssa-dom.c
parent794693c02da2eeb1764eeebe53ad69330ac3478c (diff)
downloadgcc-ceb7eb8f8c513d895c3520637274f21b791dbf06.zip
gcc-ceb7eb8f8c513d895c3520637274f21b791dbf06.tar.gz
gcc-ceb7eb8f8c513d895c3520637274f21b791dbf06.tar.bz2
tree-into-ssa.c (DEF_VEC_MALLOC_P(basic_block)): Declare.
* tree-into-ssa.c (DEF_VEC_MALLOC_P(basic_block)): Declare. (insert_phi_nodes_for): Change third argument to VEC(basic_block). * tree-ssa-dom.c (avail_exprs_stack): Change type to VEC(tree_on_heap). Update all users. (stmts_to_rescan): Likewise. (const_and_copies_stack): Likewise. (nonzero_vars_stack): Likewise. (vrp_variables_stack): Likewise. From-SVN: r91122
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c99
1 files changed, 47 insertions, 52 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index badf23b..d88d683 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -93,7 +93,7 @@ static htab_t avail_exprs;
(null). When we finish processing the block, we pop off entries and
remove the expressions from the global hash table until we hit the
marker. */
-static varray_type avail_exprs_stack;
+static VEC(tree_on_heap) *avail_exprs_stack;
/* Stack of trees used to restore the global currdefs to its original
state after completing optimization of a block and its dominator children.
@@ -106,9 +106,7 @@ static varray_type avail_exprs_stack;
A NULL node is used to mark the last node associated with the
current block. */
-VEC(tree_on_heap) *block_defs_stack;
-
-/* FIXME: The other stacks should also be VEC(tree_on_heap). */
+static VEC(tree_on_heap) *block_defs_stack;
/* Stack of statements we need to rescan during finalization for newly
exposed variables.
@@ -117,7 +115,7 @@ VEC(tree_on_heap) *block_defs_stack;
expressions are removed from AVAIL_EXPRS. Else we may change the
hash code for an expression and be unable to find/remove it from
AVAIL_EXPRS. */
-varray_type stmts_to_rescan;
+static VEC(tree_on_heap) *stmts_to_rescan;
/* Structure for entries in the expression hash table.
@@ -149,7 +147,7 @@ struct expr_hash_elt
A NULL entry is used to mark the end of pairs which need to be
restored during finalization of this block. */
-static varray_type const_and_copies_stack;
+static VEC(tree_on_heap) *const_and_copies_stack;
/* Bitmap of SSA_NAMEs known to have a nonzero value, even if we do not
know their exact value. */
@@ -160,7 +158,7 @@ static bitmap nonzero_vars;
A NULL entry is used to mark the end of names needing their
entry in NONZERO_VARS cleared during finalization of this block. */
-static varray_type nonzero_vars_stack;
+static VEC(tree_on_heap) *nonzero_vars_stack;
/* Track whether or not we have changed the control flow graph. */
static bool cfg_altered;
@@ -238,7 +236,6 @@ static htab_t vrp_data;
/* An entry in the VRP_DATA hash table. We record the variable and a
varray of VRP_ELEMENT records associated with that variable. */
-
struct vrp_hash_elt
{
tree var;
@@ -254,7 +251,7 @@ struct vrp_hash_elt
list to determine which variables need their VRP data updated.
A NULL entry marks the end of the SSA_NAMEs associated with this block. */
-static varray_type vrp_variables_stack;
+static VEC(tree_on_heap) *vrp_variables_stack;
struct eq_expr_value
{
@@ -385,12 +382,12 @@ tree_ssa_dominator_optimize (void)
/* Create our hash tables. */
avail_exprs = htab_create (1024, real_avail_expr_hash, avail_expr_eq, free);
vrp_data = htab_create (ceil_log2 (num_ssa_names), vrp_hash, vrp_eq, free);
- VARRAY_TREE_INIT (avail_exprs_stack, 20, "Available expression stack");
+ avail_exprs_stack = VEC_alloc (tree_on_heap, 20);
block_defs_stack = VEC_alloc (tree_on_heap, 20);
- VARRAY_TREE_INIT (const_and_copies_stack, 20, "Block const_and_copies stack");
- VARRAY_TREE_INIT (nonzero_vars_stack, 20, "Block nonzero_vars stack");
- VARRAY_TREE_INIT (vrp_variables_stack, 20, "Block vrp_variables stack");
- VARRAY_TREE_INIT (stmts_to_rescan, 20, "Statements to rescan");
+ const_and_copies_stack = VEC_alloc (tree_on_heap, 20);
+ nonzero_vars_stack = VEC_alloc (tree_on_heap, 20);
+ vrp_variables_stack = VEC_alloc (tree_on_heap, 20);
+ stmts_to_rescan = VEC_alloc (tree_on_heap, 20);
nonzero_vars = BITMAP_XMALLOC ();
need_eh_cleanup = BITMAP_XMALLOC ();
@@ -506,7 +503,11 @@ tree_ssa_dominator_optimize (void)
}
VEC_free (tree_on_heap, block_defs_stack);
- block_defs_stack = NULL;
+ VEC_free (tree_on_heap, avail_exprs_stack);
+ VEC_free (tree_on_heap, const_and_copies_stack);
+ VEC_free (tree_on_heap, nonzero_vars_stack);
+ VEC_free (tree_on_heap, vrp_variables_stack);
+ VEC_free (tree_on_heap, stmts_to_rescan);
}
static bool
@@ -808,11 +809,11 @@ dom_opt_initialize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
/* Push a marker on the stacks of local information so that we know how
far to unwind when we finalize this block. */
- VARRAY_PUSH_TREE (avail_exprs_stack, NULL_TREE);
+ VEC_safe_push (tree_on_heap, avail_exprs_stack, NULL_TREE);
VEC_safe_push (tree_on_heap, block_defs_stack, NULL_TREE);
- VARRAY_PUSH_TREE (const_and_copies_stack, NULL_TREE);
- VARRAY_PUSH_TREE (nonzero_vars_stack, NULL_TREE);
- VARRAY_PUSH_TREE (vrp_variables_stack, NULL_TREE);
+ VEC_safe_push (tree_on_heap, const_and_copies_stack, NULL_TREE);
+ VEC_safe_push (tree_on_heap, nonzero_vars_stack, NULL_TREE);
+ VEC_safe_push (tree_on_heap, vrp_variables_stack, NULL_TREE);
record_equivalences_from_incoming_edge (bb);
@@ -868,11 +869,10 @@ static void
remove_local_expressions_from_table (void)
{
/* Remove all the expressions made available in this block. */
- while (VARRAY_ACTIVE_SIZE (avail_exprs_stack) > 0)
+ while (VEC_length (tree_on_heap, avail_exprs_stack) > 0)
{
struct expr_hash_elt element;
- tree expr = VARRAY_TOP_TREE (avail_exprs_stack);
- VARRAY_POP (avail_exprs_stack);
+ tree expr = VEC_pop (tree_on_heap, avail_exprs_stack);
if (expr == NULL_TREE)
break;
@@ -888,10 +888,9 @@ remove_local_expressions_from_table (void)
static void
restore_nonzero_vars_to_original_value (void)
{
- while (VARRAY_ACTIVE_SIZE (nonzero_vars_stack) > 0)
+ while (VEC_length (tree_on_heap, nonzero_vars_stack) > 0)
{
- tree name = VARRAY_TOP_TREE (nonzero_vars_stack);
- VARRAY_POP (nonzero_vars_stack);
+ tree name = VEC_pop (tree_on_heap, nonzero_vars_stack);
if (name == NULL)
break;
@@ -907,19 +906,16 @@ restore_nonzero_vars_to_original_value (void)
static void
restore_vars_to_original_value (void)
{
- while (VARRAY_ACTIVE_SIZE (const_and_copies_stack) > 0)
+ while (VEC_length (tree_on_heap, const_and_copies_stack) > 0)
{
tree prev_value, dest;
- dest = VARRAY_TOP_TREE (const_and_copies_stack);
- VARRAY_POP (const_and_copies_stack);
+ dest = VEC_pop (tree_on_heap, const_and_copies_stack);
if (dest == NULL)
break;
- prev_value = VARRAY_TOP_TREE (const_and_copies_stack);
- VARRAY_POP (const_and_copies_stack);
-
+ prev_value = VEC_pop (tree_on_heap, const_and_copies_stack);
SSA_NAME_VALUE (dest) = prev_value;
}
}
@@ -1001,9 +997,9 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb)
/* Push a marker onto the available expression stack so that we
unwind any expressions related to the TRUE arm before processing
the false arm below. */
- VARRAY_PUSH_TREE (avail_exprs_stack, NULL_TREE);
+ VEC_safe_push (tree_on_heap, avail_exprs_stack, NULL_TREE);
VEC_safe_push (tree_on_heap, block_defs_stack, NULL_TREE);
- VARRAY_PUSH_TREE (const_and_copies_stack, NULL_TREE);
+ VEC_safe_push (tree_on_heap, const_and_copies_stack, NULL_TREE);
edge_info = true_edge->aux;
@@ -1105,9 +1101,9 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb)
To be efficient, we note which variables have had their values
constrained in this block. So walk over each variable in the
VRP_VARIABLEs array. */
- while (VARRAY_ACTIVE_SIZE (vrp_variables_stack) > 0)
+ while (VEC_length (tree_on_heap, vrp_variables_stack) > 0)
{
- tree var = VARRAY_TOP_TREE (vrp_variables_stack);
+ tree var = VEC_pop (tree_on_heap, vrp_variables_stack);
struct vrp_hash_elt vrp_hash_elt, *vrp_hash_elt_p;
void **slot;
@@ -1118,8 +1114,6 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb)
we are done. */
varray_type var_vrp_records;
- VARRAY_POP (vrp_variables_stack);
-
if (var == NULL)
break;
@@ -1145,15 +1139,15 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb)
/* If we queued any statements to rescan in this block, then
go ahead and rescan them now. */
- while (VARRAY_ACTIVE_SIZE (stmts_to_rescan) > 0)
+ while (VEC_length (tree_on_heap, stmts_to_rescan) > 0)
{
- tree stmt = VARRAY_TOP_TREE (stmts_to_rescan);
+ tree stmt = VEC_last (tree_on_heap, stmts_to_rescan);
basic_block stmt_bb = bb_for_stmt (stmt);
if (stmt_bb != bb)
break;
- VARRAY_POP (stmts_to_rescan);
+ VEC_pop (tree_on_heap, stmts_to_rescan);
mark_new_vars_to_rename (stmt, vars_to_rename);
}
}
@@ -1388,7 +1382,7 @@ record_var_is_nonzero (tree var)
/* Record this SSA_NAME so that we can reset the global table
when we leave this block. */
- VARRAY_PUSH_TREE (nonzero_vars_stack, var);
+ VEC_safe_push (tree_on_heap, nonzero_vars_stack, var);
}
/* Enter a statement into the true/false expression hash table indicating
@@ -1407,7 +1401,7 @@ record_cond (tree cond, tree value)
if (*slot == NULL)
{
*slot = (void *) element;
- VARRAY_PUSH_TREE (avail_exprs_stack, cond);
+ VEC_safe_push (tree_on_heap, avail_exprs_stack, cond);
}
else
free (element);
@@ -1546,8 +1540,8 @@ record_const_or_copy_1 (tree x, tree y, tree prev_x)
{
SSA_NAME_VALUE (x) = y;
- VARRAY_PUSH_TREE (const_and_copies_stack, prev_x);
- VARRAY_PUSH_TREE (const_and_copies_stack, x);
+ VEC_safe_push (tree_on_heap, const_and_copies_stack, prev_x);
+ VEC_safe_push (tree_on_heap, const_and_copies_stack, x);
}
@@ -1580,7 +1574,7 @@ loop_depth_of_name (tree x)
/* Record that X is equal to Y in const_and_copies. Record undo
- information in the block-local varray. */
+ information in the block-local vector. */
static void
record_const_or_copy (tree x, tree y)
@@ -3059,7 +3053,7 @@ optimize_stmt (struct dom_walk_data *walk_data, basic_block bb,
}
if (may_have_exposed_new_symbols)
- VARRAY_PUSH_TREE (stmts_to_rescan, bsi_stmt (si));
+ VEC_safe_push (tree_on_heap, stmts_to_rescan, bsi_stmt (si));
}
/* Replace the RHS of STMT with NEW_RHS. If RHS can be found in the
@@ -3094,7 +3088,7 @@ update_rhs_and_lookup_avail_expr (tree stmt, tree new_rhs, bool insert)
We know the call in optimize_stmt did not find an existing entry
in the hash table, so a new entry was created. At the same time
- this statement was pushed onto the BLOCK_AVAIL_EXPRS varray.
+ this statement was pushed onto the AVAIL_EXPRS_STACK vector.
If this call failed to find an existing entry on the hash table,
then the new version of this statement was entered into the
@@ -3102,16 +3096,16 @@ update_rhs_and_lookup_avail_expr (tree stmt, tree new_rhs, bool insert)
for the second time. So there are two copies on BLOCK_AVAIL_EXPRs
If this call succeeded, we still have one copy of this statement
- on the BLOCK_AVAIL_EXPRs varray.
+ on the BLOCK_AVAIL_EXPRs vector.
For both cases, we need to pop the most recent entry off the
- BLOCK_AVAIL_EXPRs varray. For the case where we never found this
+ BLOCK_AVAIL_EXPRs vector. For the case where we never found this
statement in the hash tables, that will leave precisely one
copy of this statement on BLOCK_AVAIL_EXPRs. For the case where
we found a copy of this statement in the second hash table lookup
we want _no_ copies of this statement in BLOCK_AVAIL_EXPRs. */
if (insert)
- VARRAY_POP (avail_exprs_stack);
+ VEC_pop (tree_on_heap, avail_exprs_stack);
/* And make sure we record the fact that we modified this
statement. */
@@ -3187,7 +3181,8 @@ lookup_avail_expr (tree stmt, bool insert)
if (*slot == NULL)
{
*slot = (void *) element;
- VARRAY_PUSH_TREE (avail_exprs_stack, stmt ? stmt : element->rhs);
+ VEC_safe_push (tree_on_heap, avail_exprs_stack,
+ stmt ? stmt : element->rhs);
return NULL_TREE;
}
@@ -3319,7 +3314,7 @@ record_range (tree cond, basic_block bb)
VARRAY_GENERIC_PTR_INIT (*vrp_records_p, 2, "vrp records");
VARRAY_PUSH_GENERIC_PTR (*vrp_records_p, element);
- VARRAY_PUSH_TREE (vrp_variables_stack, TREE_OPERAND (cond, 0));
+ VEC_safe_push (tree_on_heap, vrp_variables_stack, TREE_OPERAND (cond, 0));
}
}