Commit 907dadbd by Trevor Saunders Committed by Trevor Saunders

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.

From-SVN: r217871
parent 9c71e9df
2014-11-20 Trevor Saunders <tsaunders@mozilla.com> 2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* ipa-utils.c, lto-section-in.c, lto-streamer.h,
tree-scalar-evolution.c: Replace htab with hash_table.
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* lto-section-in.c (lto_delete_in_decl_state): Adjust. * lto-section-in.c (lto_delete_in_decl_state): Adjust.
(lto_free_function_in_decl_state): Likewise. (lto_free_function_in_decl_state): Likewise.
* lto-streamer-out.c (copy_function_or_variable): Likewise. * lto-streamer-out.c (copy_function_or_variable): Likewise.
...@@ -438,17 +438,17 @@ ipa_merge_profiles (struct cgraph_node *dst, ...@@ -438,17 +438,17 @@ ipa_merge_profiles (struct cgraph_node *dst,
temporarily inconsistent. */ temporarily inconsistent. */
if (src->decl == dst->decl) if (src->decl == dst->decl)
{ {
void **slot;
struct lto_in_decl_state temp; struct lto_in_decl_state temp;
struct lto_in_decl_state *state; struct lto_in_decl_state *state;
/* We are going to move the decl, we want to remove its file decl data. /* We are going to move the decl, we want to remove its file decl data.
and link these with the new decl. */ and link these with the new decl. */
temp.fn_decl = src->decl; temp.fn_decl = src->decl;
slot = htab_find_slot (src->lto_file_data->function_decl_states, lto_in_decl_state **slot
&temp, NO_INSERT); = src->lto_file_data->function_decl_states->find_slot (&temp,
state = (lto_in_decl_state *)*slot; NO_INSERT);
htab_clear_slot (src->lto_file_data->function_decl_states, slot); state = *slot;
src->lto_file_data->function_decl_states->clear_slot (slot);
gcc_assert (state); gcc_assert (state);
/* Duplicate the decl and be sure it does not link into body of DST. */ /* 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, ...@@ -461,8 +461,8 @@ ipa_merge_profiles (struct cgraph_node *dst,
/* Associate the decl state with new declaration, so LTO streamer /* Associate the decl state with new declaration, so LTO streamer
can look it up. */ can look it up. */
state->fn_decl = src->decl; state->fn_decl = src->decl;
slot = htab_find_slot (src->lto_file_data->function_decl_states, slot
state, INSERT); = src->lto_file_data->function_decl_states->find_slot (state, INSERT);
gcc_assert (!*slot); gcc_assert (!*slot);
*slot = state; *slot = state;
} }
......
...@@ -384,29 +384,6 @@ lto_delete_in_decl_state (struct lto_in_decl_state *state) ...@@ -384,29 +384,6 @@ lto_delete_in_decl_state (struct lto_in_decl_state *state)
ggc_free (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 /* Search the in-decl state of a function FUNC contained in the file
associated with FILE_DATA. Return NULL if not found. */ 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, ...@@ -415,11 +392,11 @@ lto_get_function_in_decl_state (struct lto_file_decl_data *file_data,
tree func) tree func)
{ {
struct lto_in_decl_state temp; struct lto_in_decl_state temp;
void **slot; lto_in_decl_state **slot;
temp.fn_decl = func; temp.fn_decl = func;
slot = htab_find_slot (file_data->function_decl_states, &temp, NO_INSERT); slot = file_data->function_decl_states->find_slot (&temp, NO_INSERT);
return slot? ((struct lto_in_decl_state*) *slot) : NULL; return slot? *slot : NULL;
} }
/* Free decl_states. */ /* Free decl_states. */
...@@ -440,19 +417,18 @@ void ...@@ -440,19 +417,18 @@ void
lto_free_function_in_decl_state_for_node (symtab_node *node) lto_free_function_in_decl_state_for_node (symtab_node *node)
{ {
struct lto_in_decl_state temp; struct lto_in_decl_state temp;
void **slot; lto_in_decl_state **slot;
if (!node->lto_file_data) if (!node->lto_file_data)
return; return;
temp.fn_decl = node->decl; temp.fn_decl = node->decl;
slot = htab_find_slot (node->lto_file_data->function_decl_states, slot
&temp, NO_INSERT); = node->lto_file_data->function_decl_states->find_slot (&temp, NO_INSERT);
if (slot && *slot) if (slot && *slot)
{ {
lto_free_function_in_decl_state ((struct lto_in_decl_state*) *slot); lto_free_function_in_decl_state (*slot);
htab_clear_slot (node->lto_file_data->function_decl_states, node->lto_file_data->function_decl_states->clear_slot (slot);
slot);
} }
node->lto_file_data = NULL; node->lto_file_data = NULL;
} }
......
...@@ -430,7 +430,7 @@ struct lto_tree_ref_encoder ...@@ -430,7 +430,7 @@ struct lto_tree_ref_encoder
/* Structure to hold states of input scope. */ /* 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. */ /* Array of lto_in_decl_buffers to store type and decls streams. */
vec<tree, va_gc> *streams[LTO_N_DECL_STREAMS]; vec<tree, va_gc> *streams[LTO_N_DECL_STREAMS];
...@@ -442,6 +442,20 @@ struct GTY(()) lto_in_decl_state ...@@ -442,6 +442,20 @@ struct GTY(()) lto_in_decl_state
typedef struct lto_in_decl_state *lto_in_decl_state_ptr; typedef struct lto_in_decl_state *lto_in_decl_state_ptr;
struct decl_state_hasher : ggc_hasher<lto_in_decl_state *>
{
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, /* The structure that holds all of the vectors of global types,
decls and cgraph nodes used in the serialization of this file. */ decls and cgraph nodes used in the serialization of this file. */
...@@ -488,7 +502,7 @@ struct GTY(()) lto_file_decl_data ...@@ -488,7 +502,7 @@ struct GTY(()) lto_file_decl_data
lto_symtab_encoder_t GTY((skip)) symtab_node_encoder; lto_symtab_encoder_t GTY((skip)) symtab_node_encoder;
/* Hash table maps lto-related section names to location in file. */ /* 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<decl_state_hasher> *function_decl_states;
/* The .o file that these offsets relate to. */ /* The .o file that these offsets relate to. */
const char *GTY((skip)) file_name; const char *GTY((skip)) file_name;
...@@ -687,8 +701,6 @@ extern const char *lto_get_decl_name_mapping (struct lto_file_decl_data *, ...@@ -687,8 +701,6 @@ extern const char *lto_get_decl_name_mapping (struct lto_file_decl_data *,
const char *); const char *);
extern struct lto_in_decl_state *lto_new_in_decl_state (void); 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 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 ( extern struct lto_in_decl_state *lto_get_function_in_decl_state (
struct lto_file_decl_data *, tree); struct lto_file_decl_data *, tree);
extern void lto_free_function_in_decl_state (struct lto_in_decl_state *); extern void lto_free_function_in_decl_state (struct lto_in_decl_state *);
......
2014-11-20 Trevor Saunders <tsaunders@mozilla.com> 2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* lto.c: Replace htab with hash_table.
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* lto.c (lto_read_in_decl_state): Adjust. * lto.c (lto_read_in_decl_state): Adjust.
(lto_fixup_state): Likewise. (lto_fixup_state): Likewise.
......
...@@ -1980,15 +1980,15 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, ...@@ -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. */ /* Read in per-function decl states and enter them in hash table. */
decl_data->function_decl_states = decl_data->function_decl_states =
htab_create_ggc (37, lto_hash_in_decl_state, lto_eq_in_decl_state, NULL); hash_table<decl_state_hasher>::create_ggc (37);
for (i = 1; i < num_decl_states; i++) for (i = 1; i < num_decl_states; i++)
{ {
struct lto_in_decl_state *state = lto_new_in_decl_state (); 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); 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); gcc_assert (*slot == NULL);
*slot = state; *slot = state;
} }
...@@ -2817,17 +2817,6 @@ lto_fixup_state (struct lto_in_decl_state *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 /* Fix the decls from all FILES. Replaces each decl with the corresponding
prevailing one. */ prevailing one. */
...@@ -2847,7 +2836,11 @@ lto_fixup_decls (struct lto_file_decl_data **files) ...@@ -2847,7 +2836,11 @@ lto_fixup_decls (struct lto_file_decl_data **files)
struct lto_in_decl_state *state = file->global_decl_state; struct lto_in_decl_state *state = file->global_decl_state;
lto_fixup_state (state); lto_fixup_state (state);
htab_traverse (file->function_decl_states, lto_fixup_state_aux, NULL); hash_table<decl_state_hasher>::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);
} }
} }
......
...@@ -307,7 +307,7 @@ static tree analyze_scalar_evolution_for_address_of (struct loop *loop, ...@@ -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 claiming that below basic block with index INSTANTIATED_BELOW, the
value of the SSA name can be expressed as CHREC. */ 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; unsigned int name_version;
int instantiated_below; int instantiated_below;
tree chrec; tree chrec;
...@@ -332,7 +332,13 @@ tree chrec_dont_know; ...@@ -332,7 +332,13 @@ tree chrec_dont_know;
happen, then it qualifies it with chrec_known. */ happen, then it qualifies it with chrec_known. */
tree chrec_known; tree chrec_known;
static GTY ((param_is (struct scev_info_str))) htab_t scalar_evolution_info; struct scev_info_hasher : ggc_hasher<scev_info_str *>
{
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<scev_info_hasher> *scalar_evolution_info;
/* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW. */ /* 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) ...@@ -352,34 +358,21 @@ new_scev_info_str (basic_block instantiated_below, tree var)
/* Computes a hash function for database element ELT. */ /* Computes a hash function for database element ELT. */
static inline hashval_t hashval_t
hash_scev_info (const void *elt_) 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; return elt->name_version ^ elt->instantiated_below;
} }
/* Compares database elements E1 and E2. */ /* Compares database elements E1 and E2. */
static inline int bool
eq_scev_info (const void *e1, const void *e2) 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 return (elt1->name_version == elt2->name_version
&& elt1->instantiated_below == elt2->instantiated_below); && 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. /* Get the scalar evolution of VAR for INSTANTIATED_BELOW basic block.
A first query on VAR returns chrec_not_analyzed_yet. */ A first query on VAR returns chrec_not_analyzed_yet. */
...@@ -388,15 +381,14 @@ find_var_scev_info (basic_block instantiated_below, tree var) ...@@ -388,15 +381,14 @@ find_var_scev_info (basic_block instantiated_below, tree var)
{ {
struct scev_info_str *res; struct scev_info_str *res;
struct scev_info_str tmp; struct scev_info_str tmp;
PTR *slot;
tmp.name_version = SSA_NAME_VERSION (var); tmp.name_version = SSA_NAME_VERSION (var);
tmp.instantiated_below = instantiated_below->index; 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) if (!*slot)
*slot = new_scev_info_str (instantiated_below, var); *slot = new_scev_info_str (instantiated_below, var);
res = (struct scev_info_str *) *slot; res = *slot;
return &res->chrec; return &res->chrec;
} }
...@@ -2209,7 +2201,7 @@ static inline hashval_t ...@@ -2209,7 +2201,7 @@ static inline hashval_t
hash_idx_scev_info (const void *elt_) hash_idx_scev_info (const void *elt_)
{ {
unsigned idx = ((size_t) elt_) - 2; 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. */ /* Compares database elements E1 and E2. */
...@@ -2218,7 +2210,8 @@ static inline int ...@@ -2218,7 +2210,8 @@ static inline int
eq_idx_scev_info (const void *e1, const void *e2) eq_idx_scev_info (const void *e1, const void *e2)
{ {
unsigned idx1 = ((size_t) e1) - 2; 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. */ /* Returns from CACHE the slot number of the cached chrec for NAME. */
...@@ -2237,7 +2230,7 @@ get_instantiated_value_entry (instantiate_cache_type &cache, ...@@ -2237,7 +2230,7 @@ get_instantiated_value_entry (instantiate_cache_type &cache,
e.name_version = SSA_NAME_VERSION (name); e.name_version = SSA_NAME_VERSION (name);
e.instantiated_below = instantiate_below->index; e.instantiated_below = instantiate_below->index;
void **slot = htab_find_slot_with_hash (cache.map, &e, void **slot = htab_find_slot_with_hash (cache.map, &e,
hash_scev_info (&e), INSERT); scev_info_hasher::hash (&e), INSERT);
if (!*slot) if (!*slot)
{ {
e.chrec = chrec_not_analyzed_yet; e.chrec = chrec_not_analyzed_yet;
...@@ -3052,7 +3045,7 @@ dump_chrecs_stats (FILE *file, struct chrec_stats *stats) ...@@ -3052,7 +3045,7 @@ dump_chrecs_stats (FILE *file, struct chrec_stats *stats)
stats->nb_undetermined); stats->nb_undetermined);
fprintf (file, "-----------------------------------------\n"); fprintf (file, "-----------------------------------------\n");
fprintf (file, "%d\tchrecs in the scev database\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\tsets in the scev database\n", nb_set_scev);
fprintf (file, "%d\tgets in the scev database\n", nb_get_scev); fprintf (file, "%d\tgets in the scev database\n", nb_get_scev);
fprintf (file, "-----------------------------------------\n"); fprintf (file, "-----------------------------------------\n");
...@@ -3118,19 +3111,6 @@ gather_chrec_stats (tree chrec, struct chrec_stats *stats) ...@@ -3118,19 +3111,6 @@ gather_chrec_stats (tree chrec, struct chrec_stats *stats)
fprintf (dump_file, ")\n"); 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. */ /* Classify the chrecs of the whole database. */
void void
...@@ -3143,8 +3123,11 @@ gather_stats_on_scev_database (void) ...@@ -3143,8 +3123,11 @@ gather_stats_on_scev_database (void)
reset_chrecs_counters (&stats); reset_chrecs_counters (&stats);
htab_traverse (scalar_evolution_info, gather_stats_on_scev_database_1, hash_table<scev_info_hasher>::iterator iter;
&stats); 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); dump_chrecs_stats (dump_file, &stats);
} }
...@@ -3174,8 +3157,7 @@ scev_initialize (void) ...@@ -3174,8 +3157,7 @@ scev_initialize (void)
{ {
struct loop *loop; struct loop *loop;
scalar_evolution_info = htab_create_ggc (100, hash_scev_info, eq_scev_info, scalar_evolution_info = hash_table<scev_info_hasher>::create_ggc (100);
del_scev_info);
initialize_scalar_evolutions_analyzer (); initialize_scalar_evolutions_analyzer ();
...@@ -3202,7 +3184,7 @@ scev_reset_htab (void) ...@@ -3202,7 +3184,7 @@ scev_reset_htab (void)
if (!scalar_evolution_info) if (!scalar_evolution_info)
return; return;
htab_empty (scalar_evolution_info); scalar_evolution_info->empty ();
} }
/* Cleans up the information cached by the scalar evolutions analysis /* Cleans up the information cached by the scalar evolutions analysis
...@@ -3297,7 +3279,7 @@ scev_finalize (void) ...@@ -3297,7 +3279,7 @@ scev_finalize (void)
{ {
if (!scalar_evolution_info) if (!scalar_evolution_info)
return; return;
htab_delete (scalar_evolution_info); scalar_evolution_info->empty ();
scalar_evolution_info = NULL; scalar_evolution_info = NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment