aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-09-09 09:42:39 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2017-09-09 09:42:39 +0000
commita49bf6f0f5b421fda0e44507cbf03c8a570f511b (patch)
treec00e7fecfc9db60837dc9aeece2c8499aa20dc68
parent630e912e68399c711e603d8eaa388b80a8741159 (diff)
downloadgcc-a49bf6f0f5b421fda0e44507cbf03c8a570f511b.zip
gcc-a49bf6f0f5b421fda0e44507cbf03c8a570f511b.tar.gz
gcc-a49bf6f0f5b421fda0e44507cbf03c8a570f511b.tar.bz2
re PR bootstrap/81926 (go/parse.o differs between stage2 and stage3)
PR bootstrap/81926 * cp-objcp-common.c (struct debug_type_hasher): New class. (debug_type_hash): New variable. (cp_get_debug_type): Associate the OFFSET_TYPEs with the types. From-SVN: r251922
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/cp-objcp-common.c45
2 files changed, 50 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 730a2da..fa3e008 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR bootstrap/81926
+ * cp-objcp-common.c (struct debug_type_hasher): New class.
+ (debug_type_hash): New variable.
+ (cp_get_debug_type): Associate the OFFSET_TYPEs with the types.
+
2017-09-08 Jason Merrill <jason@redhat.com>
PR c++/70029 - ICE with ref-qualifier and -flto
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 4475b6c..183e7f7 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -131,6 +131,20 @@ 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;
+
/* Return a type to use in the debug info instead of TYPE, or NULL_TREE to
keep TYPE. */
@@ -138,8 +152,35 @@ tree
cp_get_debug_type (const_tree type)
{
if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type))
- return build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type),
- TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)));
+ {
+ 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;
+
+ in.base.from = CONST_CAST_TREE (type);
+ in.hash = htab_hash_pointer (type);
+ h = debug_type_hash->find_with_hash (&in, in.hash);
+ if (h)
+ return h->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;
+ *debug_type_hash->find_slot_with_hash (h, h->hash, INSERT) = h;
+
+ return t;
+ }
return NULL_TREE;
}