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.
This commit is contained in:
Jan Hubicka 2020-10-30 14:30:43 +01:00
parent 40cb3f8ac8
commit aa701610e5
4 changed files with 52 additions and 1 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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

View File

@ -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);
};