From: Eric Botcazou <ebotcazou@adacore.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [C++] Fix PR bootstrap/81926
Date: Mon, 04 Sep 2017 08:08:00 -0000 [thread overview]
Message-ID: <1514184.0xIGq3mKY2@polaris> (raw)
In-Reply-To: <8F5955E0-4B06-4668-9BCC-233E90F6F7A0@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 406 bytes --]
> A solution would be to put them into a global GCed pointer-map or vector,
> freeing that at free-lang-data time.
Here's a version that implements a bona-fide type->offset_type map.
PR bootstrap/81926
* cp-objcp-common.c (struct offset_type_hasher): New class.
(offset_type_hash): New variable.
(cp_get_debug_type): Associate the OFFSET_TYPEs with the types.
--
Eric Botcazou
[-- Attachment #2: pr81926-2.diff --]
[-- Type: text/x-patch, Size: 2188 bytes --]
Index: cp/cp-objcp-common.c
===================================================================
--- cp/cp-objcp-common.c (revision 251538)
+++ cp/cp-objcp-common.c (working copy)
@@ -131,6 +131,20 @@ cxx_types_compatible_p (tree x, tree y)
return same_type_ignoring_top_level_qualifiers_p (x, y);
}
+struct offset_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<offset_type_hasher> *offset_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 (offset_type_hash == NULL)
+ offset_type_hash = hash_table<offset_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 = offset_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;
+ *offset_type_hash->find_slot_with_hash (h, h->hash, INSERT) = h;
+
+ return t;
+ }
return NULL_TREE;
}
next prev parent reply other threads:[~2017-09-04 8:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-02 11:01 Eric Botcazou
2017-09-02 14:33 ` Richard Biener
2017-09-03 8:05 ` Eric Botcazou
2017-09-03 8:43 ` Richard Biener
2017-09-03 14:16 ` Eric Botcazou
2017-09-04 9:08 ` Richard Biener
2017-09-04 8:08 ` Eric Botcazou [this message]
2017-09-09 8:30 ` Jason Merrill
2017-09-22 20:20 ` Eric Botcazou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1514184.0xIGq3mKY2@polaris \
--to=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).