summaryrefslogtreecommitdiff
path: root/gcc/tree-dfa.c
diff options
context:
space:
mode:
authoramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-23 14:07:21 +0000
committeramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-23 14:07:21 +0000
commit987392e58f9c44cc58fce54de611f9a514c3f0dd (patch)
tree2b7049784095c414b53ca43eb183cfd9844c3b8d /gcc/tree-dfa.c
parent5a874b33c21171ec75ff3daac9d4c6c2a4f71d61 (diff)
downloadgcc-987392e58f9c44cc58fce54de611f9a514c3f0dd.tar.gz
2006-05-23 Andrew MacLeod <amacleod@redhat.com>
PR c++/26757 * tree-ssa-loop-im.c (determine_invariantness_stmt): Use add_referenced_var instead of add_referenced_tmp_var. * tree-complex.c (create_one_component_var): Use add_referenced_var. * tree-ssa-loop-manip.c (create_iv, tree_unroll_loop): Use add_referenced_var. * tree-tailcall.c (adjust_accumulator_values, adjust_return_value, tree_optimize_tail_calls_1): Use add_referenced_var. * tree-ssa-loop-ivopts.c (create_new_iv): Use add_referenced_var. * tree-ssa-alias.c (create_memory_tag, create_global_var, create_sft): Use add_referenced_var. * tree-if-conv.c (ifc_temp_var): Use add_referenced_var. * gimplify.c (force_gimple_operand): Use add_referenced_var. * tree-ssa-phiopt.c (conditional_replacement, abs_replacement): Use add_referenced_var. * tree-dfa.c (struct walk_state): Remove. (find_referenced_vars): Remove walk state and vars_found hash table. (make_rename_temp): Use add_referenced_var. (find_vars_r): Pass less parameters to add_referenced_var. (referenced_var_p): New. Is var in referenced_var hash table. (referenced_var_insert): Assert var isn't already in hash table. (add_referenced_var): Don't need walk_state parameter. Add var if it isn't already in the hash table. (add_referenced_tmp_var): Remove. (find_new_referenced_vars_1): Use add_referenced_var. * tree-ssa-pre.c (create_expression_by_pieces, insert_into_preds_of_block, insert_extra_phis, realify_fake_stores): Use add_referenced_var. * tree-vect-patterns.c (vect_pattern_recog_1): Use add_referenced_var. * lambda-code.c (lbv_to_gcc_expression, lle_to_gcc_expression, lambda_loopnest_to_gcc_loopnest, perfect_nestify): Use add_referenced_var. * tree-vect-transform.c (vect_create_addr_base_for_vector_ref, vect_create_data_ref_ptr, vect_create_destination_var, vect_init_vector, vect_build_loop_niters, vect_generate_tmps_on_preheader, vect_update_ivs_after_vectorizer, vect_gen_niters_for_prolog_loop, vect_create_cond_for_align_checks): Use add_referenced_var. * tree-outof-ssa.c (create_temp): Use add_referenced_var. * tree-flow.h (add_referenced_tmp_var): Remove prototype (add_referenced_var): Add prototype. * tree-ssa-structalias.c (get_constraint_for, intra_create_variable_infos): Use add_referenced_var. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114018 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-dfa.c')
-rw-r--r--gcc/tree-dfa.c85
1 files changed, 30 insertions, 55 deletions
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 9ff2bd50e00..621a0d3d330 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -65,19 +65,10 @@ struct dfa_stats_d
};
-/* State information for find_vars_r. */
-struct walk_state
-{
- /* Hash table used to avoid adding the same variable more than once. */
- htab_t vars_found;
-};
-
-
/* Local functions. */
static void collect_dfa_stats (struct dfa_stats_d *);
static tree collect_dfa_stats_r (tree *, int *, void *);
static tree find_vars_r (tree *, int *, void *);
-static void add_referenced_var (tree, struct walk_state *);
/* Global declarations. */
@@ -106,23 +97,16 @@ htab_t default_defs;
static unsigned int
find_referenced_vars (void)
{
- htab_t vars_found;
basic_block bb;
block_stmt_iterator si;
- struct walk_state walk_state;
-
- vars_found = htab_create (50, htab_hash_pointer, htab_eq_pointer, NULL);
- memset (&walk_state, 0, sizeof (walk_state));
- walk_state.vars_found = vars_found;
FOR_EACH_BB (bb)
for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
{
tree *stmt_p = bsi_stmt_ptr (si);
- walk_tree (stmt_p, find_vars_r, &walk_state, NULL);
+ walk_tree (stmt_p, find_vars_r, NULL, NULL);
}
- htab_delete (vars_found);
return 0;
}
@@ -243,7 +227,7 @@ make_rename_temp (tree type, const char *prefix)
if (referenced_vars)
{
- add_referenced_tmp_var (t);
+ add_referenced_var (t);
mark_sym_for_renaming (t);
}
@@ -607,14 +591,12 @@ collect_dfa_stats_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
the function. */
static tree
-find_vars_r (tree *tp, int *walk_subtrees, void *data)
+find_vars_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
{
- struct walk_state *walk_state = (struct walk_state *) data;
-
/* If T is a regular variable that the optimizers are interested
in, add it to the list of variables. */
if (SSA_VAR_P (*tp))
- add_referenced_var (*tp, walk_state);
+ add_referenced_var (*tp);
/* Type, _DECL and constant nodes have no interesting children.
Ignore them. */
@@ -624,6 +606,21 @@ find_vars_r (tree *tp, int *walk_subtrees, void *data)
return NULL_TREE;
}
+/* Lookup VAR in the referenced_vars hashtable and return true if it is
+ present. */
+
+static inline bool
+referenced_var_p (tree var)
+{
+ struct int_tree_map *h, in;
+ in.uid = DECL_UID (var);
+ h = (struct int_tree_map *) htab_find_with_hash (referenced_vars,
+ &in,
+ in.uid);
+ if (h)
+ return h->to != NULL_TREE;
+ return false;
+}
/* Lookup UID in the referenced_vars hashtable and return the associated
variable. */
@@ -652,6 +649,9 @@ referenced_var_insert (unsigned int uid, tree to)
h->uid = uid;
h->to = to;
loc = htab_find_slot_with_hash (referenced_vars, h, uid, INSERT);
+ /* This assert can only trigger if a variable with the same UID has been
+ inserted already. */
+ gcc_assert ((*(struct int_tree_map **)loc) == NULL);
*(struct int_tree_map **) loc = h;
}
@@ -705,33 +705,21 @@ set_default_def (tree var, tree def)
}
}
-/* Add VAR to the list of dereferenced variables.
-
- WALK_STATE contains a hash table used to avoid adding the same
- variable more than once. Note that this function assumes that
- VAR is a valid SSA variable. If WALK_STATE is NULL, no
- duplicate checking is done. */
+/* Add VAR to the list of referenced variables if it isn't already there. */
-static void
-add_referenced_var (tree var, struct walk_state *walk_state)
+void
+add_referenced_var (tree var)
{
- void **slot;
var_ann_t v_ann;
v_ann = get_var_ann (var);
-
- if (walk_state)
- slot = htab_find_slot (walk_state->vars_found, (void *) var, INSERT);
- else
- slot = NULL;
-
- if (slot == NULL || *slot == NULL)
+ gcc_assert (DECL_P (var));
+
+ if (!referenced_var_p (var))
{
/* This is the first time we find this variable, add it to the
REFERENCED_VARS array and annotate it with attributes that are
intrinsic to the variable. */
- if (slot)
- *slot = (void *) var;
referenced_var_insert (DECL_UID (var), var);
@@ -750,7 +738,7 @@ add_referenced_var (tree var, struct walk_state *walk_state)
variables because it cannot be propagated by the
optimizers. */
&& (TREE_CONSTANT (var) || TREE_READONLY (var)))
- walk_tree (&DECL_INITIAL (var), find_vars_r, walk_state, 0);
+ walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0);
}
}
@@ -778,19 +766,6 @@ get_virtual_var (tree var)
return var;
}
-/* Add a temporary variable to REFERENCED_VARS. This is similar to
- add_referenced_var, but is used by passes that need to add new temps to
- the REFERENCED_VARS array after the program has been scanned for
- variables. The variable will just receive a new UID and be added
- to the REFERENCED_VARS array without checking for duplicates. */
-
-void
-add_referenced_tmp_var (tree var)
-{
- add_referenced_var (var, NULL);
-}
-
-
/* Mark all the non-SSA variables found in STMT's operands to be
processed by update_ssa. */
@@ -868,7 +843,7 @@ find_new_referenced_vars_1 (tree *tp, int *walk_subtrees,
if (TREE_CODE (t) == VAR_DECL && !var_ann (t))
{
- add_referenced_tmp_var (t);
+ add_referenced_var (t);
mark_sym_for_renaming (t);
}