Commit 0f443ad0 by Richard Guenther Committed by Richard Biener

gimple.c (gimple_types, [...]): Move to GC memory.

2010-09-08  Richard Guenther  <rguenther@suse.de>

	* gimple.c (gimple_types, type_hash_cache): Move to GC memory.
	(visit): Adjust.
	(iterative_hash_gimple_type): Likewise.
	(gimple_type_hash): Likewise.
	(gimple_register_type): Likewise.
	(print_gimple_types_stats): Likewise.
	(free_gimple_type_tables): Likewise.

	lto/
	* lto.c (read_cgraph_and_symbols): Collect again after each
	file.

From-SVN: r164001
parent 813f2f13
2010-09-08 Richard Guenther <rguenther@suse.de>
* gimple.c (gimple_types, type_hash_cache): Move to GC memory.
(visit): Adjust.
(iterative_hash_gimple_type): Likewise.
(gimple_type_hash): Likewise.
(gimple_register_type): Likewise.
(print_gimple_types_stats): Likewise.
(free_gimple_type_tables): Likewise.
2010-09-08 Michael Matz <matz@suse.de> 2010-09-08 Michael Matz <matz@suse.de>
PR tree-optimization/43430 PR tree-optimization/43430
......
...@@ -36,15 +36,19 @@ along with GCC; see the file COPYING3. If not see ...@@ -36,15 +36,19 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h" #include "flags.h"
#include "alias.h" #include "alias.h"
#include "demangle.h" #include "demangle.h"
#include "langhooks.h"
/* Global type table. FIXME lto, it should be possible to re-use some /* Global type table. FIXME lto, it should be possible to re-use some
of the type hashing routines in tree.c (type_hash_canon, type_hash_lookup, of the type hashing routines in tree.c (type_hash_canon, type_hash_lookup,
etc), but those assume that types were built with the various etc), but those assume that types were built with the various
build_*_type routines which is not the case with the streamer. */ build_*_type routines which is not the case with the streamer. */
static htab_t gimple_types; static GTY((if_marked ("ggc_marked_p"), param_is (union tree_node)))
static struct pointer_map_t *type_hash_cache; htab_t gimple_types;
static GTY((if_marked ("tree_int_map_marked_p"), param_is (struct tree_int_map)))
htab_t type_hash_cache;
/* Global type comparison cache. */ /* Global type comparison cache. This is by TYPE_UID for space efficiency
and thus cannot use and does not need GC. */
static htab_t gtc_visited; static htab_t gtc_visited;
static struct obstack gtc_ob; static struct obstack gtc_ob;
...@@ -3916,12 +3920,15 @@ visit (tree t, struct sccs *state, hashval_t v, ...@@ -3916,12 +3920,15 @@ visit (tree t, struct sccs *state, hashval_t v,
struct obstack *sccstate_obstack) struct obstack *sccstate_obstack)
{ {
struct sccs *cstate = NULL; struct sccs *cstate = NULL;
struct tree_int_map m;
void **slot; void **slot;
/* If there is a hash value recorded for this type then it can't /* If there is a hash value recorded for this type then it can't
possibly be part of our parent SCC. Simply mix in its hash. */ possibly be part of our parent SCC. Simply mix in its hash. */
if ((slot = pointer_map_contains (type_hash_cache, t))) m.base.from = t;
return iterative_hash_hashval_t ((hashval_t) (size_t) *slot, v); if ((slot = htab_find_slot (type_hash_cache, &m, NO_INSERT))
&& *slot)
return iterative_hash_hashval_t (((struct tree_int_map *) *slot)->to, v);
if ((slot = pointer_map_contains (sccstate, t)) != NULL) if ((slot = pointer_map_contains (sccstate, t)) != NULL)
cstate = (struct sccs *)*slot; cstate = (struct sccs *)*slot;
...@@ -3988,9 +3995,8 @@ iterative_hash_gimple_type (tree type, hashval_t val, ...@@ -3988,9 +3995,8 @@ iterative_hash_gimple_type (tree type, hashval_t val,
struct sccs *state; struct sccs *state;
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
/* Not visited during this DFS walk nor during previous walks. */ /* Not visited during this DFS walk. */
gcc_assert (!pointer_map_contains (type_hash_cache, type) gcc_assert (!pointer_map_contains (sccstate, type));
&& !pointer_map_contains (sccstate, type));
#endif #endif
state = XOBNEW (sccstate_obstack, struct sccs); state = XOBNEW (sccstate_obstack, struct sccs);
*pointer_map_insert (sccstate, type) = state; *pointer_map_insert (sccstate, type) = state;
...@@ -4137,12 +4143,15 @@ iterative_hash_gimple_type (tree type, hashval_t val, ...@@ -4137,12 +4143,15 @@ iterative_hash_gimple_type (tree type, hashval_t val,
do do
{ {
struct sccs *cstate; struct sccs *cstate;
struct tree_int_map *m = ggc_alloc_cleared_tree_int_map ();
x = VEC_pop (tree, *sccstack); x = VEC_pop (tree, *sccstack);
gcc_assert (!pointer_map_contains (type_hash_cache, x));
cstate = (struct sccs *)*pointer_map_contains (sccstate, x); cstate = (struct sccs *)*pointer_map_contains (sccstate, x);
cstate->on_sccstack = false; cstate->on_sccstack = false;
slot = pointer_map_insert (type_hash_cache, x); m->base.from = x;
*slot = (void *) (size_t) cstate->u.hash; m->to = cstate->u.hash;
slot = htab_find_slot (type_hash_cache, m, INSERT);
gcc_assert (!*slot);
*slot = (void *) m;
} }
while (x != type); while (x != type);
} }
...@@ -4168,12 +4177,16 @@ gimple_type_hash (const void *p) ...@@ -4168,12 +4177,16 @@ gimple_type_hash (const void *p)
struct obstack sccstate_obstack; struct obstack sccstate_obstack;
hashval_t val; hashval_t val;
void **slot; void **slot;
struct tree_int_map m;
if (type_hash_cache == NULL) if (type_hash_cache == NULL)
type_hash_cache = pointer_map_create (); type_hash_cache = htab_create_ggc (512, tree_int_map_hash,
tree_int_map_eq, NULL);
if ((slot = pointer_map_contains (type_hash_cache, p)) != NULL) m.base.from = CONST_CAST_TREE (t);
return iterative_hash_hashval_t ((hashval_t) (size_t) *slot, 0); if ((slot = htab_find_slot (type_hash_cache, &m, NO_INSERT))
&& *slot)
return iterative_hash_hashval_t (((struct tree_int_map *) *slot)->to, 0);
/* Perform a DFS walk and pre-hash all reachable types. */ /* Perform a DFS walk and pre-hash all reachable types. */
next_dfs_num = 1; next_dfs_num = 1;
...@@ -4226,7 +4239,7 @@ gimple_register_type (tree t) ...@@ -4226,7 +4239,7 @@ gimple_register_type (tree t)
gimple_register_type (TYPE_MAIN_VARIANT (t)); gimple_register_type (TYPE_MAIN_VARIANT (t));
if (gimple_types == NULL) if (gimple_types == NULL)
gimple_types = htab_create (16381, gimple_type_hash, gimple_type_eq, 0); gimple_types = htab_create_ggc (16381, gimple_type_hash, gimple_type_eq, 0);
slot = htab_find_slot (gimple_types, t, INSERT); slot = htab_find_slot (gimple_types, t, INSERT);
if (*slot if (*slot
...@@ -4312,6 +4325,16 @@ print_gimple_types_stats (void) ...@@ -4312,6 +4325,16 @@ print_gimple_types_stats (void)
htab_collisions (gimple_types)); htab_collisions (gimple_types));
else else
fprintf (stderr, "GIMPLE type table is empty\n"); fprintf (stderr, "GIMPLE type table is empty\n");
if (type_hash_cache)
fprintf (stderr, "GIMPLE type hash table: size %ld, %ld elements, "
"%ld searches, %ld collisions (ratio: %f)\n",
(long) htab_size (type_hash_cache),
(long) htab_elements (type_hash_cache),
(long) type_hash_cache->searches,
(long) type_hash_cache->collisions,
htab_collisions (type_hash_cache));
else
fprintf (stderr, "GIMPLE type hash table is empty\n");
if (gtc_visited) if (gtc_visited)
fprintf (stderr, "GIMPLE type comparison table: size %ld, %ld " fprintf (stderr, "GIMPLE type comparison table: size %ld, %ld "
"elements, %ld searches, %ld collisions (ratio: %f)\n", "elements, %ld searches, %ld collisions (ratio: %f)\n",
...@@ -4340,7 +4363,7 @@ free_gimple_type_tables (void) ...@@ -4340,7 +4363,7 @@ free_gimple_type_tables (void)
} }
if (type_hash_cache) if (type_hash_cache)
{ {
pointer_map_destroy (type_hash_cache); htab_delete (type_hash_cache);
type_hash_cache = NULL; type_hash_cache = NULL;
} }
if (gtc_visited) if (gtc_visited)
......
2010-09-08 Richard Guenther <rguenther@suse.de>
* lto.c (read_cgraph_and_symbols): Collect again after each
file.
2010-09-07 Jan Hubicka <jh@suse.cz> 2010-09-07 Jan Hubicka <jh@suse.cz>
* lto.c (promote_var, promote_fn): Set DECL_VISIBILITY_SPECIFIED. * lto.c (promote_var, promote_fn): Set DECL_VISIBILITY_SPECIFIED.
......
...@@ -1789,8 +1789,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) ...@@ -1789,8 +1789,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
lto_obj_file_close (current_lto_file); lto_obj_file_close (current_lto_file);
current_lto_file = NULL; current_lto_file = NULL;
/* ??? We'd want but can't ggc_collect () here as the type merging ggc_collect ();
code in gimple.c uses hashtables that are not ggc aware. */
} }
lto_flatten_files (decl_data, count, last_file_ix); lto_flatten_files (decl_data, count, last_file_ix);
......
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