diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c8b1e2f146e..976022755d8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2007-10-18 Richard Guenther + + * tree-flow.h (struct gimple_df): Make referenced_vars + a uid_decl_map. + (uid_decl_map_eq): Declare. + (uid_decl_map_hash): Likewise. + * tree-ssa.c (uid_decl_map_eq): New function. + (uid_decl_map_hash): Likewise. + (init_tree_ssa): Make referenced_vars a uid_decl_map. + * tree-flow-inline.h (first_referenced_var): Deal with + the referenced_vars representation change. + (next_referenced_var): Likewise. + * tree-dfa.c (referenced_var_lookup): Likewise. + (referenced_var_check_and_insert): Likewise. + (remove_referenced_var): Likewise. + 2007-10-18 Daniel Jacobowitz * config/mips/mips.c (mips_dwarf_register_span): New. diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index e6b593e7214..26e87c173b4 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -635,14 +635,12 @@ find_vars_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) tree referenced_var_lookup (unsigned int uid) { - struct int_tree_map *h, in; + tree h; + struct tree_decl_minimal in; in.uid = uid; - h = (struct int_tree_map *) - htab_find_with_hash (gimple_referenced_vars (cfun), &in, uid); + h = (tree) htab_find_with_hash (gimple_referenced_vars (cfun), &in, uid); gcc_assert (h || uid == 0); - if (h) - return h->to; - return NULL_TREE; + return h; } /* Check if TO is in the referenced_vars hash table and insert it if not. @@ -651,29 +649,23 @@ referenced_var_lookup (unsigned int uid) bool referenced_var_check_and_insert (tree to) { - struct int_tree_map *h, in; - void **loc; + tree h, *loc; + struct tree_decl_minimal in; unsigned int uid = DECL_UID (to); in.uid = uid; - in.to = to; - h = (struct int_tree_map *) htab_find_with_hash (gimple_referenced_vars (cfun), - &in, uid); - + h = (tree) htab_find_with_hash (gimple_referenced_vars (cfun), &in, uid); if (h) { /* DECL_UID has already been entered in the table. Verify that it is the same entry as TO. See PR 27793. */ - gcc_assert (h->to == to); + gcc_assert (h == to); return false; } - h = GGC_NEW (struct int_tree_map); - h->uid = uid; - h->to = to; - loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), - h, uid, INSERT); - *(struct int_tree_map **) loc = h; + loc = (tree *) htab_find_slot_with_hash (gimple_referenced_vars (cfun), + &in, uid, INSERT); + *loc = to; return true; } @@ -774,7 +766,7 @@ void remove_referenced_var (tree var) { var_ann_t v_ann; - struct int_tree_map in; + struct tree_decl_minimal in; void **loc; unsigned int uid = DECL_UID (var); @@ -784,10 +776,8 @@ remove_referenced_var (tree var) var->base.ann = NULL; gcc_assert (DECL_P (var)); in.uid = uid; - in.to = var; loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid, NO_INSERT); - ggc_free (*loc); htab_clear_slot (gimple_referenced_vars (cfun), loc); } diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h index 71e607bddce..7f47bba4c7d 100644 --- a/gcc/tree-flow-inline.h +++ b/gcc/tree-flow-inline.h @@ -151,13 +151,8 @@ next_htab_element (htab_iterator *hti) static inline tree first_referenced_var (referenced_var_iterator *iter) { - struct int_tree_map *itm; - itm = (struct int_tree_map *) first_htab_element (&iter->hti, - gimple_referenced_vars - (cfun)); - if (!itm) - return NULL; - return itm->to; + return (tree) first_htab_element (&iter->hti, + gimple_referenced_vars (cfun)); } /* Return true if we have hit the end of the referenced variables ITER is @@ -175,11 +170,7 @@ end_referenced_vars_p (const referenced_var_iterator *iter) static inline tree next_referenced_var (referenced_var_iterator *iter) { - struct int_tree_map *itm; - itm = (struct int_tree_map *) next_htab_element (&iter->hti); - if (!itm) - return NULL; - return itm->to; + return (tree) next_htab_element (&iter->hti); } /* Fill up VEC with the variables in the referenced vars hashtable. */ diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 518e4f2236e..b004ad9b3b6 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -120,7 +120,7 @@ struct mem_ref_stats_d GTY(()) struct gimple_df GTY(()) { /* Array of all variables referenced in the function. */ - htab_t GTY((param_is (struct int_tree_map))) referenced_vars; + htab_t GTY((param_is (union tree_node))) referenced_vars; /* A list of all the noreturn calls passed to modify_stmt. cleanup_control_flow uses it to detect cases where a mid-block @@ -561,6 +561,9 @@ struct int_tree_map GTY(()) extern unsigned int int_tree_map_hash (const void *); extern int int_tree_map_eq (const void *, const void *); +extern unsigned int uid_decl_map_hash (const void *); +extern int uid_decl_map_eq (const void *, const void *); + typedef struct { htab_iterator hti; diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 9723afb0eec..e325953884c 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -774,6 +774,24 @@ int_tree_map_hash (const void *item) return ((const struct int_tree_map *)item)->uid; } +/* Return true if the DECL_UID in both trees are equal. */ + +int +uid_decl_map_eq (const void *va, const void *vb) +{ + const_tree a = (const_tree) va; + const_tree b = (const_tree) vb; + return (a->decl_minimal.uid == b->decl_minimal.uid); +} + +/* Hash a tree in a uid_decl_map. */ + +unsigned int +uid_decl_map_hash (const void *item) +{ + return ((const_tree)item)->decl_minimal.uid; +} + /* Return true if the uid in both int tree maps are equal. */ static int @@ -799,8 +817,8 @@ void init_tree_ssa (void) { cfun->gimple_df = GGC_CNEW (struct gimple_df); - cfun->gimple_df->referenced_vars = htab_create_ggc (20, int_tree_map_hash, - int_tree_map_eq, NULL); + cfun->gimple_df->referenced_vars = htab_create_ggc (20, uid_decl_map_hash, + uid_decl_map_eq, NULL); cfun->gimple_df->default_defs = htab_create_ggc (20, int_tree_map_hash, int_tree_map_eq, NULL); cfun->gimple_df->var_anns = htab_create_ggc (20, var_ann_hash,