summaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-10-31 10:18:06 +0100
committerJan Hubicka <jh@suse.cz>2020-10-31 10:18:06 +0100
commitae7a23a3fab74ebd45203d48fa09681c9945ee7a (patch)
treedd288d22c32cd5f609204c5a62c74dd025194459 /gcc/cgraph.c
parent617695cdc2b3d950f1e4deb5ea85d5cc302943f4 (diff)
downloadgcc-ae7a23a3fab74ebd45203d48fa09681c9945ee7a.tar.gz
Move clone_info to summary
* Makefile.in: (OBJS): Add symtab-clones.o (GTFILES): Add symtab-clones.h * cgraph.c: Include symtab-clones.h. (cgraph_edge::resolve_speculation): Fix formating (cgraph_edge::redirect_call_stmt_to_callee): Update. (cgraph_update_edges_for_call_stmt): Update (release_function_body): Fix formating. (cgraph_node::remove): Fix formating. (cgraph_node::dump): Fix formating. (cgraph_node::get_availability): Fix formating. (cgraph_node::call_for_symbol_thunks_and_aliases): Fix formating. (set_const_flag_1): Fix formating. (set_pure_flag_1): Fix formating. (cgraph_node::can_remove_if_no_direct_calls_p): Fix formating. (collect_callers_of_node_1): Fix formating. (clone_of_p): Update. (cgraph_node::verify_node): Update. (cgraph_c_finalize): Call clone_info::release (). * cgraph.h (struct cgraph_clone_info): Move to symtab-clones.h. (cgraph_node): Remove clone_info. (symbol_table): Add m_clones. * cgraphclones.c: Include symtab-clone.h. (duplicate_thunk_for_node): Update. (cgraph_node::create_clone): Update. (cgraph_node::create_virtual_clone): Update. (cgraph_node::find_replacement): Update. (cgraph_node::materialize_clone): Update. * gengtype.c (open_base_files): Include symtab-clones.h. * ipa-cp.c: Include symtab-clones.h. (initialize_node_lattices): Update. (want_remove_some_param_p): Update. (create_specialized_node): Update. * ipa-fnsummary.c: Include symtab-clones.h. (ipa_fn_summary_t::duplicate): Update. * ipa-modref.c: Include symtab-clones.h. (update_signature): Update. * ipa-param-manipulation.c: Include symtab-clones.h. (ipa_param_body_adjustments::common_initialization): Update. * ipa-prop.c: Include symtab-clones.h. (adjust_agg_replacement_values): Update. (ipcp_get_parm_bits): Update. (ipcp_update_bits): Update. (ipcp_update_vr): Update. * ipa-sra.c: Include symtab-clones.h. (process_isra_node_results): Update. (disable_unavailable_parameters): Update. * lto-cgraph.c: Include symtab-clone.h. (output_cgraph_opt_summary_p): Update. (output_node_opt_summary): Update. (input_node_opt_summary): Update. * symtab-clones.cc: New file. * symtab-clones.h: New file. * tree-inline.c (expand_call_inline): Update. (update_clone_info): Update. (tree_function_versioning): Update.
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c96
1 files changed, 53 insertions, 43 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 9129bcf12d2..9f3a7284310 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -66,6 +66,7 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-inline.h"
#include "tree-nested.h"
#include "symtab-thunks.h"
+#include "symtab-clones.h"
/* FIXME: Only for PROP_loops, but cgraph shouldn't have to know about this. */
#include "tree-pass.h"
@@ -1236,7 +1237,7 @@ cgraph_edge::resolve_speculation (cgraph_edge *edge, tree callee_decl)
{
cgraph_edge *tmp = edge;
if (dump_file)
- fprintf (dump_file, "Speculative call turned into direct call.\n");
+ fprintf (dump_file, "Speculative call turned into direct call.\n");
edge = e2;
e2 = tmp;
/* FIXME: If EDGE is inlined, we should scale up the frequencies
@@ -1488,38 +1489,43 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e)
return e->call_stmt;
}
}
-
if (flag_checking && decl)
{
cgraph_node *node = cgraph_node::get (decl);
- gcc_assert (!node || !node->clone.param_adjustments);
+ clone_info *info = clone_info::get (node);
+ gcc_assert (!node || !info || !info->param_adjustments);
}
+ clone_info *callee_info = clone_info::get (e->callee);
+ clone_info *caller_info = clone_info::get (e->caller);
+
if (symtab->dump_file)
{
+
fprintf (symtab->dump_file, "updating call of %s -> %s: ",
e->caller->dump_name (), e->callee->dump_name ());
print_gimple_stmt (symtab->dump_file, e->call_stmt, 0, dump_flags);
- if (e->callee->clone.param_adjustments)
- e->callee->clone.param_adjustments->dump (symtab->dump_file);
+ if (callee_info && callee_info->param_adjustments)
+ callee_info->param_adjustments->dump (symtab->dump_file);
unsigned performed_len
- = vec_safe_length (e->caller->clone.performed_splits);
+ = vec_safe_length (caller_info->performed_splits);
if (performed_len > 0)
fprintf (symtab->dump_file, "Performed splits records:\n");
for (unsigned i = 0; i < performed_len; i++)
{
ipa_param_performed_split *sm
- = &(*e->caller->clone.performed_splits)[i];
+ = &(*caller_info->performed_splits)[i];
print_node_brief (symtab->dump_file, " dummy_decl: ", sm->dummy_decl,
TDF_UID);
fprintf (symtab->dump_file, ", unit_offset: %u\n", sm->unit_offset);
}
}
- if (ipa_param_adjustments *padjs = e->callee->clone.param_adjustments)
+ if (ipa_param_adjustments *padjs
+ = callee_info ? callee_info->param_adjustments : NULL)
{
/* We need to defer cleaning EH info on the new statement to
- fixup-cfg. We may not have dominator information at this point
+ fixup-cfg. We may not have dominator information at this point
and thus would end up with unreachable blocks and have no way
to communicate that we need to run CFG cleanup then. */
int lp_nr = lookup_stmt_eh_lp (e->call_stmt);
@@ -1528,7 +1534,8 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e)
tree old_fntype = gimple_call_fntype (e->call_stmt);
new_stmt = padjs->modify_call (e->call_stmt,
- e->caller->clone.performed_splits,
+ caller_info
+ ? caller_info->performed_splits : NULL,
e->callee->decl, false);
cgraph_node *origin = e->callee;
while (origin->clone_of)
@@ -1577,7 +1584,7 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e)
var = get_or_create_ssa_default_def
(DECL_STRUCT_FUNCTION (e->caller->decl), var);
gimple *set_stmt = gimple_build_assign (lhs, var);
- gsi = gsi_for_stmt (new_stmt);
+ gsi = gsi_for_stmt (new_stmt);
gsi_insert_before_without_update (&gsi, set_stmt, GSI_SAME_STMT);
update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), set_stmt);
}
@@ -1703,7 +1710,8 @@ cgraph_update_edges_for_call_stmt (gimple *old_stmt, tree old_decl,
if (orig->clones)
for (node = orig->clones; node != orig;)
{
- cgraph_update_edges_for_call_stmt_node (node, old_stmt, old_decl, new_stmt);
+ cgraph_update_edges_for_call_stmt_node (node, old_stmt, old_decl,
+ new_stmt);
if (node->clones)
node = node->clones;
else if (node->next_sibling_clone)
@@ -1809,7 +1817,7 @@ release_function_body (tree decl)
free_histograms (fn);
gimple_set_body (decl, NULL);
/* Struct function hangs a lot of data that would leak if we didn't
- removed all pointers to it. */
+ removed all pointers to it. */
ggc_free (fn);
DECL_STRUCT_FUNCTION (decl) = NULL;
}
@@ -1880,7 +1888,7 @@ cgraph_node::remove (void)
cgraph_node *n, *next;
if (clone_of)
- {
+ {
for (n = clones; n->next_sibling_clone; n = n->next_sibling_clone)
n->clone_of = clone_of;
n->clone_of = clone_of;
@@ -1890,7 +1898,7 @@ cgraph_node::remove (void)
clone_of->clones = clones;
}
else
- {
+ {
/* We are removing node with clones. This makes clones inconsistent,
but assume they will be removed subsequently and just keep clone
tree intact. This can happen in unreachable function removal since
@@ -2248,12 +2256,12 @@ cgraph_node::dump (FILE *f)
{
if (edge->indirect_info->polymorphic)
{
- fprintf (f, " Polymorphic indirect call of type ");
+ fprintf (f, " Polymorphic indirect call of type ");
print_generic_expr (f, edge->indirect_info->otr_type, TDF_SLIM);
fprintf (f, " token:%i", (int) edge->indirect_info->otr_token);
}
else
- fprintf (f, " Indirect call");
+ fprintf (f, " Indirect call");
edge->dump_edge_flags (f);
if (edge->indirect_info->param_index != -1)
{
@@ -2350,8 +2358,8 @@ cgraph_node::get_availability (symtab_node *ref)
Also comdat groups are always resolved in groups. */
else if ((this == ref && !has_aliases_p ())
- || (ref && get_comdat_group ()
- && get_comdat_group () == ref->get_comdat_group ()))
+ || (ref && get_comdat_group ()
+ && get_comdat_group () == ref->get_comdat_group ()))
avail = AVAIL_AVAILABLE;
/* Inline functions are safe to be analyzed even if their symbol can
be overwritten at runtime. It is not meaningful to enforce any sane
@@ -2419,7 +2427,7 @@ cgraph_node::call_for_symbol_thunks_and_aliases (bool (*callback)
|| (avail = get_availability ()) > AVAIL_INTERPOSABLE)
{
if (callback (this, data))
- return true;
+ return true;
}
FOR_EACH_ALIAS (this, ref)
{
@@ -2614,8 +2622,8 @@ set_const_flag_1 (cgraph_node *node, bool set_const, bool looping,
{
if (TREE_READONLY (node->decl))
{
- TREE_READONLY (node->decl) = 0;
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
+ TREE_READONLY (node->decl) = 0;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
*changed = true;
}
}
@@ -2642,14 +2650,14 @@ set_const_flag_1 (cgraph_node *node, bool set_const, bool looping,
{
if (!looping && DECL_LOOPING_CONST_OR_PURE_P (node->decl))
{
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
*changed = true;
}
}
else if (node->binds_to_current_def_p ())
{
TREE_READONLY (node->decl) = true;
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = looping;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = looping;
DECL_PURE_P (node->decl) = false;
*changed = true;
}
@@ -2661,12 +2669,12 @@ set_const_flag_1 (cgraph_node *node, bool set_const, bool looping,
if (!DECL_PURE_P (node->decl))
{
DECL_PURE_P (node->decl) = true;
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = looping;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = looping;
*changed = true;
}
else if (!looping && DECL_LOOPING_CONST_OR_PURE_P (node->decl))
{
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
*changed = true;
}
}
@@ -2685,9 +2693,9 @@ set_const_flag_1 (cgraph_node *node, bool set_const, bool looping,
{
/* Virtual thunks access virtual offset in the vtable, so they can
only be pure, never const. */
- if (set_const
+ if (set_const
&& (thunk_info::get (e->caller)->virtual_offset_p
- || !node->binds_to_current_def_p (e->caller)))
+ || !node->binds_to_current_def_p (e->caller)))
*changed |= e->caller->set_pure_flag (true, looping);
else
set_const_flag_1 (e->caller, set_const, looping, changed);
@@ -2757,14 +2765,14 @@ set_pure_flag_1 (cgraph_node *node, void *data)
{
if (!DECL_PURE_P (node->decl) && !TREE_READONLY (node->decl))
{
- DECL_PURE_P (node->decl) = true;
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = info->looping;
+ DECL_PURE_P (node->decl) = true;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = info->looping;
info->changed = true;
}
else if (DECL_LOOPING_CONST_OR_PURE_P (node->decl)
&& !info->looping)
{
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
info->changed = true;
}
}
@@ -2772,8 +2780,8 @@ set_pure_flag_1 (cgraph_node *node, void *data)
{
if (DECL_PURE_P (node->decl))
{
- DECL_PURE_P (node->decl) = false;
- DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
+ DECL_PURE_P (node->decl) = false;
+ DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
info->changed = true;
}
}
@@ -2927,7 +2935,7 @@ cgraph_node::can_remove_if_no_direct_calls_p (bool will_inline)
/* If function is not being inlined, we care only about
references outside of the comdat group. */
if (!will_inline)
- for (int i = 0; next->iterate_referring (i, ref); i++)
+ for (int i = 0; next->iterate_referring (i, ref); i++)
if (ref->referring->get_comdat_group () != get_comdat_group ())
return false;
}
@@ -3031,7 +3039,7 @@ collect_callers_of_node_1 (cgraph_node *node, void *data)
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
if (!cs->indirect_inlining_edge
&& !cs->caller->thunk)
- redirect_callers->safe_push (cs);
+ redirect_callers->safe_push (cs);
return false;
}
@@ -3083,8 +3091,9 @@ clone_of_p (cgraph_node *node, cgraph_node *node2)
return true;
node = node->callees->callee->ultimate_alias_target ();
- if (!node2->clone.param_adjustments
- || node2->clone.param_adjustments->first_param_intact_p ())
+ clone_info *info = clone_info::get (node2);
+ if (!info || !info->param_adjustments
+ || info->param_adjustments->first_param_intact_p ())
return false;
if (node2->former_clone_of == node->decl
|| node2->former_clone_of == node->former_clone_of)
@@ -3615,7 +3624,7 @@ cgraph_node::verify_node (void)
if (callees)
{
error ("Alias has call edges");
- error_found = true;
+ error_found = true;
}
for (i = 0; iterate_reference (i, ref); i++)
if (ref->use != IPA_REF_ALIAS)
@@ -3642,18 +3651,18 @@ cgraph_node::verify_node (void)
if (!callees)
{
error ("No edge out of thunk node");
- error_found = true;
+ error_found = true;
}
else if (callees->next_callee)
{
error ("More than one edge out of thunk node");
- error_found = true;
+ error_found = true;
}
if (gimple_has_body_p (decl) && !inlined_to)
- {
+ {
error ("Thunk is not supposed to have body");
- error_found = true;
- }
+ error_found = true;
+ }
}
else if (analyzed && gimple_has_body_p (decl)
&& !TREE_ASM_WRITTEN (decl)
@@ -3998,6 +4007,7 @@ cgraph_c_finalize (void)
{
nested_function_info::release ();
thunk_info::release ();
+ clone_info::release ();
symtab = NULL;
x_cgraph_nodes_queue = NULL;