diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-14 18:39:45 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-14 18:39:45 +0000 |
commit | 1fc0af1209891531516366bd3b4721982227583f (patch) | |
tree | b6002d111b4e1d8083bf800bf3164b9501f35a06 /gcc/gimple.c | |
parent | 33a972d7680112a00bb54fe154b8d90811172547 (diff) | |
download | gcc-1fc0af1209891531516366bd3b4721982227583f.tar.gz |
2009-10-14 Richard Guenther <rguenther@suse.de>
* gimple.c (gtc_ob): New global.
(struct type_pair_d): Replace pointers with type UIDs.
(type_pair_hash): Adjust.
(type_pair_eq): Likewise.
(lookup_type_pair): Likewise. Allocate from an obstack.
(gimple_force_type_merge): Adjust.
(gimple_types_compatible_p): Likewise.
(free_gimple_type_tables): Free the obstack.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152776 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r-- | gcc/gimple.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index 29eec519b7d..519b41cb9f0 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -46,6 +46,7 @@ static struct pointer_map_t *type_hash_cache; /* Global type comparison cache. */ static htab_t gtc_visited; +static struct obstack gtc_ob; /* All the tuples have their operand vector (if present) at the very bottom of the structure. Therefore, the offset required to find the @@ -3025,8 +3026,8 @@ static hashval_t gimple_type_hash (const void *); infinite recursion due to self-referential types. */ struct type_pair_d { - tree t1; - tree t2; + unsigned int uid1; + unsigned int uid2; int same_p; }; typedef struct type_pair_d *type_pair_t; @@ -3037,8 +3038,8 @@ static hashval_t type_pair_hash (const void *p) { const struct type_pair_d *pair = (const struct type_pair_d *) p; - hashval_t val1 = iterative_hash_hashval_t (htab_hash_pointer (pair->t1), 0); - hashval_t val2 = iterative_hash_hashval_t (htab_hash_pointer (pair->t2), 0); + hashval_t val1 = pair->uid1; + hashval_t val2 = pair->uid2; return (iterative_hash_hashval_t (val2, val1) ^ iterative_hash_hashval_t (val1, val2)); } @@ -3050,34 +3051,37 @@ type_pair_eq (const void *p1, const void *p2) { const struct type_pair_d *pair1 = (const struct type_pair_d *) p1; const struct type_pair_d *pair2 = (const struct type_pair_d *) p2; - return ((pair1->t1 == pair2->t1 && pair1->t2 == pair2->t2) - || (pair1->t1 == pair2->t2 && pair1->t2 == pair2->t1)); + return ((pair1->uid1 == pair2->uid1 && pair1->uid2 == pair2->uid2) + || (pair1->uid1 == pair2->uid2 && pair1->uid2 == pair2->uid1)); } /* Lookup the pair of types T1 and T2 in *VISITED_P. Insert a new entry if none existed. */ static type_pair_t -lookup_type_pair (tree t1, tree t2, htab_t *visited_p) +lookup_type_pair (tree t1, tree t2, htab_t *visited_p, struct obstack *ob_p) { struct type_pair_d pair; type_pair_t p; void **slot; if (*visited_p == NULL) - *visited_p = htab_create (251, type_pair_hash, type_pair_eq, free); + { + *visited_p = htab_create (251, type_pair_hash, type_pair_eq, NULL); + gcc_obstack_init (ob_p); + } - pair.t1 = t1; - pair.t2 = t2; + pair.uid1 = TYPE_UID (t1); + pair.uid2 = TYPE_UID (t2); slot = htab_find_slot (*visited_p, &pair, INSERT); if (*slot) p = *((type_pair_t *) slot); else { - p = XNEW (struct type_pair_d); - p->t1 = t1; - p->t2 = t2; + p = XOBNEW (ob_p, struct type_pair_d); + p->uid1 = TYPE_UID (t1); + p->uid2 = TYPE_UID (t2); p->same_p = -2; *slot = (void *) p; } @@ -3110,7 +3114,7 @@ gimple_force_type_merge (tree t1, tree t2) /* Adjust cached comparison results for T1 and T2 to make sure they now compare compatible. */ - p = lookup_type_pair (t1, t2, >c_visited); + p = lookup_type_pair (t1, t2, >c_visited, >c_ob); p->same_p = 1; } @@ -3220,7 +3224,7 @@ gimple_types_compatible_p (tree t1, tree t2) /* If we've visited this type pair before (in the case of aggregates with self-referential types), and we made a decision, return it. */ - p = lookup_type_pair (t1, t2, >c_visited); + p = lookup_type_pair (t1, t2, >c_visited, >c_ob); if (p->same_p == 0 || p->same_p == 1) { /* We have already decided whether T1 and T2 are the @@ -3917,6 +3921,7 @@ free_gimple_type_tables (void) if (gtc_visited) { htab_delete (gtc_visited); + obstack_free (>c_ob, NULL); gtc_visited = NULL; } } |