aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cp-objcp-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/cp-objcp-common.c')
-rw-r--r--gcc/cp/cp-objcp-common.c61
1 files changed, 20 insertions, 41 deletions
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index e051d66..9a398e0 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -122,19 +122,7 @@ cxx_types_compatible_p (tree x, tree y)
return same_type_ignoring_top_level_qualifiers_p (x, y);
}
-struct debug_type_hasher : ggc_cache_ptr_hash<tree_map>
-{
- static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
- static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }
-
- static int
- keep_cache_entry (tree_map *&e)
- {
- return ggc_marked_p (e->base.from);
- }
-};
-
-static GTY((cache)) hash_table<debug_type_hasher> *debug_type_hash;
+static GTY((cache)) tree_cache_map *debug_type_map;
/* Return a type to use in the debug info instead of TYPE, or NULL_TREE to
keep TYPE. */
@@ -142,38 +130,29 @@ static GTY((cache)) hash_table<debug_type_hasher> *debug_type_hash;
tree
cp_get_debug_type (const_tree type)
{
+ tree dtype = NULL_TREE;
+
if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type))
+ dtype = build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type),
+ TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)));
+
+ /* We cannot simply return the debug type here because the function uses
+ the type canonicalization hashtable, which is GC-ed, so its behavior
+ depends on the actual collection points. Since we are building these
+ types on the fly for the debug info only, they would not be attached
+ to any GC root and always be swept, so we would make the contents of
+ the debug info depend on the collection points. */
+ if (dtype)
{
- if (debug_type_hash == NULL)
- debug_type_hash = hash_table<debug_type_hasher>::create_ggc (512);
-
- /* We cannot simply use build_offset_type here because the function uses
- the type canonicalization hashtable, which is GC-ed, so its behavior
- depends on the actual collection points. Since we are building these
- types on the fly for the debug info only, they would not be attached
- to any GC root and always be swept, so we would make the contents of
- the debug info depend on the collection points. */
- struct tree_map in, *h, **slot;
-
- in.base.from = CONST_CAST_TREE (type);
- in.hash = htab_hash_pointer (type);
- slot = debug_type_hash->find_slot_with_hash (&in, in.hash, INSERT);
- if (*slot)
- return (*slot)->to;
-
- tree t = build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type),
- TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)));
-
- h = ggc_alloc<tree_map> ();
- h->base.from = CONST_CAST_TREE (type);
- h->hash = htab_hash_pointer (type);
- h->to = t;
- *slot = h;
-
- return t;
+ tree ktype = CONST_CAST_TREE (type);
+ if (debug_type_map == NULL)
+ debug_type_map = tree_cache_map::create_ggc (512);
+ else if (tree *slot = debug_type_map->get (ktype))
+ return *slot;
+ debug_type_map->put (ktype, dtype);
}
- return NULL_TREE;
+ return dtype;
}
/* Return -1 if dwarf ATTR shouldn't be added for DECL, or the attribute