Commit 1ac2bdb4 by Martin Liska Committed by Martin Liska

Port IPA CP to edge_clone_summaries.

2018-06-08  Martin Liska  <mliska@suse.cz>

	* ipa-cp.c (class edge_clone_summary): New summary.
	(grow_edge_clone_vectors): Remove.
	(ipcp_edge_duplication_hook): Remove.
	(class edge_clone_summary_t): New call_summary class.
	(ipcp_edge_removal_hook): Remove.
	(edge_clone_summary_t::duplicate): New function.
	(get_next_cgraph_edge_clone): Use edge_clone_summaries.
	(create_specialized_node): Likewise.
	(ipcp_driver): Initialize edge_clone_summaries and do not
	register hooks.

From-SVN: r261317
parent dbea5bf9
2018-06-08 Martin Liska <mliska@suse.cz> 2018-06-08 Martin Liska <mliska@suse.cz>
* ipa-cp.c (class edge_clone_summary): New summary.
(grow_edge_clone_vectors): Remove.
(ipcp_edge_duplication_hook): Remove.
(class edge_clone_summary_t): New call_summary class.
(ipcp_edge_removal_hook): Remove.
(edge_clone_summary_t::duplicate): New function.
(get_next_cgraph_edge_clone): Use edge_clone_summaries.
(create_specialized_node): Likewise.
(ipcp_driver): Initialize edge_clone_summaries and do not
register hooks.
2018-06-08 Martin Liska <mliska@suse.cz>
* symbol-summary.h (get): New function. * symbol-summary.h (get): New function.
(call_summary::m_initialize_when_cloning): New class member. (call_summary::m_initialize_when_cloning): New class member.
......
...@@ -3374,54 +3374,56 @@ ipcp_discover_new_direct_edges (struct cgraph_node *node, ...@@ -3374,54 +3374,56 @@ ipcp_discover_new_direct_edges (struct cgraph_node *node,
ipa_update_overall_fn_summary (node); ipa_update_overall_fn_summary (node);
} }
/* Vector of pointers which for linked lists of clones of an original crgaph class edge_clone_summary;
edge. */ static call_summary <edge_clone_summary *> *edge_clone_summaries = NULL;
static vec<cgraph_edge *> next_edge_clone; /* Edge clone summary. */
static vec<cgraph_edge *> prev_edge_clone;
static inline void struct edge_clone_summary
grow_edge_clone_vectors (void)
{ {
if (next_edge_clone.length () /* Default constructor. */
<= (unsigned) symtab->edges_max_uid) edge_clone_summary (): prev_clone (NULL), next_clone (NULL) {}
next_edge_clone.safe_grow_cleared (symtab->edges_max_uid + 1);
if (prev_edge_clone.length ()
<= (unsigned) symtab->edges_max_uid)
prev_edge_clone.safe_grow_cleared (symtab->edges_max_uid + 1);
}
/* Edge duplication hook to grow the appropriate linked list in /* Default destructor. */
next_edge_clone. */ ~edge_clone_summary ()
{
if (prev_clone)
edge_clone_summaries->get (prev_clone)->next_clone = next_clone;
if (next_clone)
edge_clone_summaries->get (next_clone)->prev_clone = prev_clone;
}
static void cgraph_edge *prev_clone;
ipcp_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst, cgraph_edge *next_clone;
void *) };
{
grow_edge_clone_vectors ();
struct cgraph_edge *old_next = next_edge_clone[src->uid]; class edge_clone_summary_t:
if (old_next) public call_summary <edge_clone_summary *>
prev_edge_clone[old_next->uid] = dst; {
prev_edge_clone[dst->uid] = src; public:
edge_clone_summary_t (symbol_table *symtab):
call_summary <edge_clone_summary *> (symtab)
{
m_initialize_when_cloning = true;
}
next_edge_clone[dst->uid] = old_next; virtual void duplicate (cgraph_edge *src_edge, cgraph_edge *dst_edge,
next_edge_clone[src->uid] = dst; edge_clone_summary *src_data,
} edge_clone_summary *dst_data);
};
/* Hook that is called by cgraph.c when an edge is removed. */ /* Edge duplication hook. */
static void void
ipcp_edge_removal_hook (struct cgraph_edge *cs, void *) edge_clone_summary_t::duplicate (cgraph_edge *src_edge, cgraph_edge *dst_edge,
edge_clone_summary *src_data,
edge_clone_summary *dst_data)
{ {
grow_edge_clone_vectors (); if (src_data->next_clone)
edge_clone_summaries->get (src_data->next_clone)->prev_clone = dst_edge;
struct cgraph_edge *prev = prev_edge_clone[cs->uid]; dst_data->prev_clone = src_edge;
struct cgraph_edge *next = next_edge_clone[cs->uid]; dst_data->next_clone = src_data->next_clone;
if (prev) src_data->next_clone = dst_edge;
next_edge_clone[prev->uid] = next;
if (next)
prev_edge_clone[next->uid] = prev;
} }
/* See if NODE is a clone with a known aggregate value at a given OFFSET of a /* See if NODE is a clone with a known aggregate value at a given OFFSET of a
...@@ -3549,7 +3551,8 @@ cgraph_edge_brings_value_p (cgraph_edge *cs, ...@@ -3549,7 +3551,8 @@ cgraph_edge_brings_value_p (cgraph_edge *cs,
static inline struct cgraph_edge * static inline struct cgraph_edge *
get_next_cgraph_edge_clone (struct cgraph_edge *cs) get_next_cgraph_edge_clone (struct cgraph_edge *cs)
{ {
return next_edge_clone[cs->uid]; edge_clone_summary *s = edge_clone_summaries->get (cs);
return s != NULL ? s->next_clone : NULL;
} }
/* Given VAL that is intended for DEST, iterate over all its sources and if any /* Given VAL that is intended for DEST, iterate over all its sources and if any
...@@ -3853,7 +3856,7 @@ create_specialized_node (struct cgraph_node *node, ...@@ -3853,7 +3856,7 @@ create_specialized_node (struct cgraph_node *node,
bool have_self_recursive_calls = !self_recursive_calls.is_empty (); bool have_self_recursive_calls = !self_recursive_calls.is_empty ();
for (unsigned j = 0; j < self_recursive_calls.length (); j++) for (unsigned j = 0; j < self_recursive_calls.length (); j++)
{ {
cgraph_edge *cs = next_edge_clone[self_recursive_calls[j]->uid]; cgraph_edge *cs = get_next_cgraph_edge_clone (self_recursive_calls[j]);
/* Cloned edges can disappear during cloning as speculation can be /* Cloned edges can disappear during cloning as speculation can be
resolved, check that we have one and that it comes from the last resolved, check that we have one and that it comes from the last
cloning. */ cloning. */
...@@ -3863,8 +3866,8 @@ create_specialized_node (struct cgraph_node *node, ...@@ -3863,8 +3866,8 @@ create_specialized_node (struct cgraph_node *node,
edge would confuse this mechanism, so let's check that does not edge would confuse this mechanism, so let's check that does not
happen. */ happen. */
gcc_checking_assert (!cs gcc_checking_assert (!cs
|| !next_edge_clone[cs->uid] || !get_next_cgraph_edge_clone (cs)
|| next_edge_clone[cs->uid]->caller != new_node); || get_next_cgraph_edge_clone (cs)->caller != new_node);
} }
if (have_self_recursive_calls) if (have_self_recursive_calls)
new_node->expand_all_artificial_thunks (); new_node->expand_all_artificial_thunks ();
...@@ -5055,17 +5058,13 @@ ipcp_store_vr_results (void) ...@@ -5055,17 +5058,13 @@ ipcp_store_vr_results (void)
static unsigned int static unsigned int
ipcp_driver (void) ipcp_driver (void)
{ {
struct cgraph_2edge_hook_list *edge_duplication_hook_holder;
struct cgraph_edge_hook_list *edge_removal_hook_holder;
struct ipa_topo_info topo; struct ipa_topo_info topo;
if (edge_clone_summaries == NULL)
edge_clone_summaries = new edge_clone_summary_t (symtab);
ipa_check_create_node_params (); ipa_check_create_node_params ();
ipa_check_create_edge_args (); ipa_check_create_edge_args ();
grow_edge_clone_vectors ();
edge_duplication_hook_holder
= symtab->add_edge_duplication_hook (&ipcp_edge_duplication_hook, NULL);
edge_removal_hook_holder
= symtab->add_edge_removal_hook (&ipcp_edge_removal_hook, NULL);
if (dump_file) if (dump_file)
{ {
...@@ -5088,10 +5087,7 @@ ipcp_driver (void) ...@@ -5088,10 +5087,7 @@ ipcp_driver (void)
/* Free all IPCP structures. */ /* Free all IPCP structures. */
free_toporder_info (&topo); free_toporder_info (&topo);
next_edge_clone.release (); delete edge_clone_summaries;
prev_edge_clone.release ();
symtab->remove_edge_removal_hook (edge_removal_hook_holder);
symtab->remove_edge_duplication_hook (edge_duplication_hook_holder);
ipa_free_all_structures_after_ipa_cp (); ipa_free_all_structures_after_ipa_cp ();
if (dump_file) if (dump_file)
fprintf (dump_file, "\nIPA constant propagation end\n"); fprintf (dump_file, "\nIPA constant propagation end\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment