From: tbsaunde Date: Thu, 20 Nov 2014 15:10:49 +0000 (+0000) Subject: remove more ggc htabs X-Git-Tag: upstream/5.3.0~3867 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f9f871f6cb738b7ce11633bd9a2e7336b136786;p=platform%2Fupstream%2Flinaro-gcc.git remove more ggc htabs gcc/ * ipa-utils.c, lto-section-in.c, lto-streamer.h, tree-scalar-evolution.c: Replace htab with hash_table. lto/ * lto.c: Replace htab with hash_table. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217871 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c99757b..8c70fad 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2014-11-20 Trevor Saunders + * ipa-utils.c, lto-section-in.c, lto-streamer.h, + tree-scalar-evolution.c: Replace htab with hash_table. + +2014-11-20 Trevor Saunders + * lto-section-in.c (lto_delete_in_decl_state): Adjust. (lto_free_function_in_decl_state): Likewise. * lto-streamer-out.c (copy_function_or_variable): Likewise. diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c index 22900cc..7613205 100644 --- a/gcc/ipa-utils.c +++ b/gcc/ipa-utils.c @@ -438,17 +438,17 @@ ipa_merge_profiles (struct cgraph_node *dst, temporarily inconsistent. */ if (src->decl == dst->decl) { - void **slot; struct lto_in_decl_state temp; struct lto_in_decl_state *state; /* We are going to move the decl, we want to remove its file decl data. and link these with the new decl. */ temp.fn_decl = src->decl; - slot = htab_find_slot (src->lto_file_data->function_decl_states, - &temp, NO_INSERT); - state = (lto_in_decl_state *)*slot; - htab_clear_slot (src->lto_file_data->function_decl_states, slot); + lto_in_decl_state **slot + = src->lto_file_data->function_decl_states->find_slot (&temp, + NO_INSERT); + state = *slot; + src->lto_file_data->function_decl_states->clear_slot (slot); gcc_assert (state); /* Duplicate the decl and be sure it does not link into body of DST. */ @@ -461,8 +461,8 @@ ipa_merge_profiles (struct cgraph_node *dst, /* Associate the decl state with new declaration, so LTO streamer can look it up. */ state->fn_decl = src->decl; - slot = htab_find_slot (src->lto_file_data->function_decl_states, - state, INSERT); + slot + = src->lto_file_data->function_decl_states->find_slot (state, INSERT); gcc_assert (!*slot); *slot = state; } diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c index d0bb4bd..3ccdfb9 100644 --- a/gcc/lto-section-in.c +++ b/gcc/lto-section-in.c @@ -384,29 +384,6 @@ lto_delete_in_decl_state (struct lto_in_decl_state *state) ggc_free (state); } -/* Hashtable helpers. lto_in_decl_states are hash by their function decls. */ - -hashval_t -lto_hash_in_decl_state (const void *p) -{ - const struct lto_in_decl_state *state = (const struct lto_in_decl_state *) p; - return htab_hash_pointer (state->fn_decl); -} - -/* Return true if the fn_decl field of the lto_in_decl_state pointed to by - P1 equals to the function decl P2. */ - -int -lto_eq_in_decl_state (const void *p1, const void *p2) -{ - const struct lto_in_decl_state *state1 = - (const struct lto_in_decl_state *) p1; - const struct lto_in_decl_state *state2 = - (const struct lto_in_decl_state *) p2; - return state1->fn_decl == state2->fn_decl; -} - - /* Search the in-decl state of a function FUNC contained in the file associated with FILE_DATA. Return NULL if not found. */ @@ -415,11 +392,11 @@ lto_get_function_in_decl_state (struct lto_file_decl_data *file_data, tree func) { struct lto_in_decl_state temp; - void **slot; + lto_in_decl_state **slot; temp.fn_decl = func; - slot = htab_find_slot (file_data->function_decl_states, &temp, NO_INSERT); - return slot? ((struct lto_in_decl_state*) *slot) : NULL; + slot = file_data->function_decl_states->find_slot (&temp, NO_INSERT); + return slot? *slot : NULL; } /* Free decl_states. */ @@ -440,19 +417,18 @@ void lto_free_function_in_decl_state_for_node (symtab_node *node) { struct lto_in_decl_state temp; - void **slot; + lto_in_decl_state **slot; if (!node->lto_file_data) return; temp.fn_decl = node->decl; - slot = htab_find_slot (node->lto_file_data->function_decl_states, - &temp, NO_INSERT); + slot + = node->lto_file_data->function_decl_states->find_slot (&temp, NO_INSERT); if (slot && *slot) { - lto_free_function_in_decl_state ((struct lto_in_decl_state*) *slot); - htab_clear_slot (node->lto_file_data->function_decl_states, - slot); + lto_free_function_in_decl_state (*slot); + node->lto_file_data->function_decl_states->clear_slot (slot); } node->lto_file_data = NULL; } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 8129171..d67f058 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -430,7 +430,7 @@ struct lto_tree_ref_encoder /* Structure to hold states of input scope. */ -struct GTY(()) lto_in_decl_state +struct GTY((for_user)) lto_in_decl_state { /* Array of lto_in_decl_buffers to store type and decls streams. */ vec *streams[LTO_N_DECL_STREAMS]; @@ -442,6 +442,20 @@ struct GTY(()) lto_in_decl_state typedef struct lto_in_decl_state *lto_in_decl_state_ptr; +struct decl_state_hasher : ggc_hasher +{ + static hashval_t + hash (lto_in_decl_state *s) + { + return htab_hash_pointer (s->fn_decl); + } + + static bool + equal (lto_in_decl_state *a, lto_in_decl_state *b) + { + return a->fn_decl == b->fn_decl; + } +}; /* The structure that holds all of the vectors of global types, decls and cgraph nodes used in the serialization of this file. */ @@ -488,7 +502,7 @@ struct GTY(()) lto_file_decl_data lto_symtab_encoder_t GTY((skip)) symtab_node_encoder; /* Hash table maps lto-related section names to location in file. */ - htab_t GTY((param_is (struct lto_in_decl_state))) function_decl_states; + hash_table *function_decl_states; /* The .o file that these offsets relate to. */ const char *GTY((skip)) file_name; @@ -687,8 +701,6 @@ extern const char *lto_get_decl_name_mapping (struct lto_file_decl_data *, const char *); extern struct lto_in_decl_state *lto_new_in_decl_state (void); extern void lto_delete_in_decl_state (struct lto_in_decl_state *); -extern hashval_t lto_hash_in_decl_state (const void *); -extern int lto_eq_in_decl_state (const void *, const void *); extern struct lto_in_decl_state *lto_get_function_in_decl_state ( struct lto_file_decl_data *, tree); extern void lto_free_function_in_decl_state (struct lto_in_decl_state *); diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 329da66..fa96f48 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,5 +1,9 @@ 2014-11-20 Trevor Saunders + * lto.c: Replace htab with hash_table. + +2014-11-20 Trevor Saunders + * lto.c (lto_read_in_decl_state): Adjust. (lto_fixup_state): Likewise. diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 4cb99f1..a1cd958 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -1980,15 +1980,15 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, /* Read in per-function decl states and enter them in hash table. */ decl_data->function_decl_states = - htab_create_ggc (37, lto_hash_in_decl_state, lto_eq_in_decl_state, NULL); + hash_table::create_ggc (37); for (i = 1; i < num_decl_states; i++) { struct lto_in_decl_state *state = lto_new_in_decl_state (); - void **slot; data_ptr = lto_read_in_decl_state (data_in, data_ptr, state); - slot = htab_find_slot (decl_data->function_decl_states, state, INSERT); + lto_in_decl_state **slot + = decl_data->function_decl_states->find_slot (state, INSERT); gcc_assert (*slot == NULL); *slot = state; } @@ -2817,17 +2817,6 @@ lto_fixup_state (struct lto_in_decl_state *state) } } -/* A callback of htab_traverse. Just extracts a state from SLOT - and calls lto_fixup_state. */ - -static int -lto_fixup_state_aux (void **slot, void *aux ATTRIBUTE_UNUSED) -{ - struct lto_in_decl_state *state = (struct lto_in_decl_state *) *slot; - lto_fixup_state (state); - return 1; -} - /* Fix the decls from all FILES. Replaces each decl with the corresponding prevailing one. */ @@ -2847,7 +2836,11 @@ lto_fixup_decls (struct lto_file_decl_data **files) struct lto_in_decl_state *state = file->global_decl_state; lto_fixup_state (state); - htab_traverse (file->function_decl_states, lto_fixup_state_aux, NULL); + hash_table::iterator iter; + lto_in_decl_state *elt; + FOR_EACH_HASH_TABLE_ELEMENT (*file->function_decl_states, elt, + lto_in_decl_state *, iter) + lto_fixup_state (elt); } } diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 4646315..5183cb8 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -307,7 +307,7 @@ static tree analyze_scalar_evolution_for_address_of (struct loop *loop, claiming that below basic block with index INSTANTIATED_BELOW, the value of the SSA name can be expressed as CHREC. */ -struct GTY(()) scev_info_str { +struct GTY((for_user)) scev_info_str { unsigned int name_version; int instantiated_below; tree chrec; @@ -332,7 +332,13 @@ tree chrec_dont_know; happen, then it qualifies it with chrec_known. */ tree chrec_known; -static GTY ((param_is (struct scev_info_str))) htab_t scalar_evolution_info; +struct scev_info_hasher : ggc_hasher +{ + static hashval_t hash (scev_info_str *i); + static bool equal (const scev_info_str *a, const scev_info_str *b); +}; + +static GTY (()) hash_table *scalar_evolution_info; /* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW. */ @@ -352,34 +358,21 @@ new_scev_info_str (basic_block instantiated_below, tree var) /* Computes a hash function for database element ELT. */ -static inline hashval_t -hash_scev_info (const void *elt_) +hashval_t +scev_info_hasher::hash (scev_info_str *elt) { - const struct scev_info_str *elt = (const struct scev_info_str *) elt_; return elt->name_version ^ elt->instantiated_below; } /* Compares database elements E1 and E2. */ -static inline int -eq_scev_info (const void *e1, const void *e2) +bool +scev_info_hasher::equal (const scev_info_str *elt1, const scev_info_str *elt2) { - const struct scev_info_str *elt1 = (const struct scev_info_str *) e1; - const struct scev_info_str *elt2 = (const struct scev_info_str *) e2; - return (elt1->name_version == elt2->name_version && elt1->instantiated_below == elt2->instantiated_below); } -/* Deletes database element E. */ - -static void -del_scev_info (void *e) -{ - ggc_free (e); -} - - /* Get the scalar evolution of VAR for INSTANTIATED_BELOW basic block. A first query on VAR returns chrec_not_analyzed_yet. */ @@ -388,15 +381,14 @@ find_var_scev_info (basic_block instantiated_below, tree var) { struct scev_info_str *res; struct scev_info_str tmp; - PTR *slot; tmp.name_version = SSA_NAME_VERSION (var); tmp.instantiated_below = instantiated_below->index; - slot = htab_find_slot (scalar_evolution_info, &tmp, INSERT); + scev_info_str **slot = scalar_evolution_info->find_slot (&tmp, INSERT); if (!*slot) *slot = new_scev_info_str (instantiated_below, var); - res = (struct scev_info_str *) *slot; + res = *slot; return &res->chrec; } @@ -2209,7 +2201,7 @@ static inline hashval_t hash_idx_scev_info (const void *elt_) { unsigned idx = ((size_t) elt_) - 2; - return hash_scev_info (&global_cache->entries[idx]); + return scev_info_hasher::hash (&global_cache->entries[idx]); } /* Compares database elements E1 and E2. */ @@ -2218,7 +2210,8 @@ static inline int eq_idx_scev_info (const void *e1, const void *e2) { unsigned idx1 = ((size_t) e1) - 2; - return eq_scev_info (&global_cache->entries[idx1], e2); + return scev_info_hasher::equal (&global_cache->entries[idx1], + (const scev_info_str *) e2); } /* Returns from CACHE the slot number of the cached chrec for NAME. */ @@ -2237,7 +2230,7 @@ get_instantiated_value_entry (instantiate_cache_type &cache, e.name_version = SSA_NAME_VERSION (name); e.instantiated_below = instantiate_below->index; void **slot = htab_find_slot_with_hash (cache.map, &e, - hash_scev_info (&e), INSERT); + scev_info_hasher::hash (&e), INSERT); if (!*slot) { e.chrec = chrec_not_analyzed_yet; @@ -3052,7 +3045,7 @@ dump_chrecs_stats (FILE *file, struct chrec_stats *stats) stats->nb_undetermined); fprintf (file, "-----------------------------------------\n"); fprintf (file, "%d\tchrecs in the scev database\n", - (int) htab_elements (scalar_evolution_info)); + (int) scalar_evolution_info->elements ()); fprintf (file, "%d\tsets in the scev database\n", nb_set_scev); fprintf (file, "%d\tgets in the scev database\n", nb_get_scev); fprintf (file, "-----------------------------------------\n"); @@ -3118,19 +3111,6 @@ gather_chrec_stats (tree chrec, struct chrec_stats *stats) fprintf (dump_file, ")\n"); } -/* Callback for htab_traverse, gathers information on chrecs in the - hashtable. */ - -static int -gather_stats_on_scev_database_1 (void **slot, void *stats) -{ - struct scev_info_str *entry = (struct scev_info_str *) *slot; - - gather_chrec_stats (entry->chrec, (struct chrec_stats *) stats); - - return 1; -} - /* Classify the chrecs of the whole database. */ void @@ -3143,8 +3123,11 @@ gather_stats_on_scev_database (void) reset_chrecs_counters (&stats); - htab_traverse (scalar_evolution_info, gather_stats_on_scev_database_1, - &stats); + hash_table::iterator iter; + scev_info_str *elt; + FOR_EACH_HASH_TABLE_ELEMENT (*scalar_evolution_info, elt, scev_info_str *, + iter) + gather_chrec_stats (elt->chrec, &stats); dump_chrecs_stats (dump_file, &stats); } @@ -3174,8 +3157,7 @@ scev_initialize (void) { struct loop *loop; - scalar_evolution_info = htab_create_ggc (100, hash_scev_info, eq_scev_info, - del_scev_info); + scalar_evolution_info = hash_table::create_ggc (100); initialize_scalar_evolutions_analyzer (); @@ -3202,7 +3184,7 @@ scev_reset_htab (void) if (!scalar_evolution_info) return; - htab_empty (scalar_evolution_info); + scalar_evolution_info->empty (); } /* Cleans up the information cached by the scalar evolutions analysis @@ -3297,7 +3279,7 @@ scev_finalize (void) { if (!scalar_evolution_info) return; - htab_delete (scalar_evolution_info); + scalar_evolution_info->empty (); scalar_evolution_info = NULL; }