aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-10-30 14:30:43 +0100
committerJan Hubicka <jh@suse.cz>2020-10-30 14:30:43 +0100
commitaa701610e51ca9e15573ba080cb93ef726252cfc (patch)
treedf843230a64856ebefdf8d5a021f3ee7d11851b5 /gcc
parent40cb3f8ac875c6cf6610a5f93da571cfdd2a1513 (diff)
downloadgcc-aa701610e51ca9e15573ba080cb93ef726252cfc.zip
gcc-aa701610e51ca9e15573ba080cb93ef726252cfc.tar.gz
gcc-aa701610e51ca9e15573ba080cb93ef726252cfc.tar.bz2
Fix thunk info WRT PCH
PR pch/97593 * cgraph.c (cgraph_node::create_thunk): Register thunk as early during parsing. * cgraphunit.c (analyze_functions): Call thunk_info::process_early_thunks. * symtab-thunks.cc (struct unprocessed_thunk): New struct. (thunks): New static variable. (thunk_info::register_early): New member function. (thunk_info::process_early_thunks): New member function. * symtab-thunks.h (thunk_info::register_early): Declare. (thunk_info::process_early_thunks): Declare.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cgraph.c9
-rw-r--r--gcc/cgraphunit.c2
-rw-r--r--gcc/symtab-thunks.cc35
-rw-r--r--gcc/symtab-thunks.h7
4 files changed, 52 insertions, 1 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d1a773d..9129bcf 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -633,13 +633,20 @@ cgraph_node::create_thunk (tree alias, tree, bool this_adjusting,
node->thunk = true;
node->definition = true;
- thunk_info *i = thunk_info::get_create (node);
+ thunk_info *i;
+ thunk_info local_info;
+ if (symtab->state < CONSTRUCTION)
+ i = &local_info;
+ else
+ i = thunk_info::get_create (node);
i->fixed_offset = fixed_offset;
i->virtual_value = virtual_value;
i->indirect_offset = indirect_offset;
i->alias = real_alias;
i->this_adjusting = this_adjusting;
i->virtual_offset_p = virtual_offset != NULL;
+ if (symtab->state < CONSTRUCTION)
+ i->register_early (node);
return node;
}
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 08b93cb..3a98958 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1155,6 +1155,8 @@ analyze_functions (bool first_time)
symtab->state = CONSTRUCTION;
input_location = UNKNOWN_LOCATION;
+ thunk_info::process_early_thunks ();
+
/* Ugly, but the fixup cannot happen at a time same body alias is created;
C++ FE is confused about the COMDAT groups being right. */
if (symtab->cpp_implicit_aliases_done)
diff --git a/gcc/symtab-thunks.cc b/gcc/symtab-thunks.cc
index 1a4aaa2..2199f4e 100644
--- a/gcc/symtab-thunks.cc
+++ b/gcc/symtab-thunks.cc
@@ -52,6 +52,14 @@ along with GCC; see the file COPYING3. If not see
/* Used for vtable lookup in thunk adjusting. */
static GTY (()) tree vtable_entry_type;
+struct GTY (()) unprocessed_thunk
+{
+ cgraph_node *node;
+ thunk_info *info;
+};
+/* To be PCH safe we store thunks into a vector before end of compilation
+ unit. */
+static GTY (()) vec<unprocessed_thunk, va_gc> *thunks;
namespace {
@@ -147,6 +155,33 @@ thunk_info::hash ()
return hstate.end ();
}
+/* Add unprocessed thunk. */
+void
+thunk_info::register_early (cgraph_node *node)
+{
+ unprocessed_thunk entry = {node, new (ggc_alloc <thunk_info> ()) thunk_info};
+ *entry.info = *this;
+ vec_safe_push (thunks, entry);
+}
+
+/* Attach recorded thunks to cgraph_nodes.
+ All this is done only to avoid need to stream summaries to PCH. */
+void
+thunk_info::process_early_thunks ()
+{
+ unprocessed_thunk *e;
+ unsigned int i;
+ if (!thunks)
+ return;
+
+ FOR_EACH_VEC_ELT (*thunks, i, e)
+ {
+ *thunk_info::get_create (e->node) = *e->info;
+ }
+ vec_free (thunks);
+ thunks = NULL;
+}
+
/* Adjust PTR by the constant FIXED_OFFSET, by the vtable offset indicated by
VIRTUAL_OFFSET, and by the indirect offset indicated by INDIRECT_OFFSET, if
it is non-null. THIS_ADJUSTING is nonzero for a this adjusting thunk and zero
diff --git a/gcc/symtab-thunks.h b/gcc/symtab-thunks.h
index a23fc55..41a6849 100644
--- a/gcc/symtab-thunks.h
+++ b/gcc/symtab-thunks.h
@@ -77,6 +77,7 @@ struct GTY(()) thunk_info {
fixed_offset = other.fixed_offset;
virtual_value = other.virtual_value;
indirect_offset = other.indirect_offset;
+ alias = other.alias;
this_adjusting = other.this_adjusting;
virtual_offset_p = other.virtual_offset_p;
return *this;
@@ -133,6 +134,12 @@ struct GTY(()) thunk_info {
/* Remove thunk_info. */
static void remove (cgraph_node *node);
+ /* Add unprocessed thunk. */
+ void register_early (cgraph_node *node);
+
+ /* Attach recorded thunks to cgraph_nodes. */
+ static void process_early_thunks ();
+
/* Release all thunk_infos. */
static void release (void);
};