* tree-dfa.c (struct walk_state): Remove. (add_referenced_var): Change Parameters. (find_referenced_vars): Done use a walk_state. (find_vars_r): Unused parameter and change parms to add_referenced_var. (referenced_var_insert): Assert same UID has not been inserted. (add_referenced_var): Check if var exists via referenced_var table. (get_virtual_var): Call add_referenced_var with new parameter. Index: tree-dfa.c =================================================================== *** tree-dfa.c (revision 112248) --- tree-dfa.c (working copy) *************** struct dfa_stats_d *** 65,83 **** }; - /* 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. */ --- 65,75 ---- }; /* 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, bool); /* Global declarations. */ *************** htab_t referenced_vars; *** 100,122 **** static void 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); } - htab_delete (vars_found); } struct tree_opt_pass pass_referenced_vars = --- 92,107 ---- static void find_referenced_vars (void) { basic_block bb; block_stmt_iterator si; 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, NULL, NULL); } } struct tree_opt_pass pass_referenced_vars = *************** collect_dfa_stats_r (tree *tp, int *walk *** 551,564 **** the function. */ static tree ! find_vars_r (tree *tp, int *walk_subtrees, void *data) { - 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); /* Type, _DECL and constant nodes have no interesting children. Ignore them. */ --- 536,547 ---- the function. */ static tree ! find_vars_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) { /* 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, false); /* Type, _DECL and constant nodes have no interesting children. Ignore them. */ *************** referenced_var_insert (unsigned int uid, *** 610,615 **** --- 593,601 ---- 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; } *************** referenced_var_insert (unsigned int uid, *** 621,645 **** duplicate checking is done. */ static void ! add_referenced_var (tree var, struct walk_state *walk_state) { - 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) { /* 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); --- 607,624 ---- duplicate checking is done. */ static void ! add_referenced_var (tree var, bool always) { var_ann_t v_ann; v_ann = get_var_ann (var); ! gcc_assert (DECL_P (var)); ! ! if (always || referenced_var_lookup_if_exists (DECL_UID (var)) == NULL_TREE) { /* 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. */ referenced_var_insert (DECL_UID (var), var); *************** add_referenced_var (tree var, struct wal *** 658,664 **** 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); } } --- 637,643 ---- variables because it cannot be propagated by the optimizers. */ && (TREE_CONSTANT (var) || TREE_READONLY (var))) ! walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0); } } *************** get_virtual_var (tree var) *** 695,701 **** void add_referenced_tmp_var (tree var) { ! add_referenced_var (var, NULL); } --- 674,680 ---- void add_referenced_tmp_var (tree var) { ! add_referenced_var (var, true); }