Commit 74605a11 by Jan Hubicka Committed by Jan Hubicka

cgraph.c (cgraph_clone_node): Add call_duplication_hook parameter.

	* cgraph.c (cgraph_clone_node): Add call_duplication_hook parameter.
	(cgraph_create_virtual_clone): Call hooks once virtual clone is finished.
	* cgraph.h (cgraph_clone_node): Update prototype.
	* ipa-cp.c (ipcp_estimate_growth): Use estimate_ipcp_clone_size_and_time.
	* ipa-inline-transform.c (clone_inlined_nodes): Update.
	* lto-cgraph.c (input_node): Update.
	* ipa-inline.c (recursive_inlining): Update.
	* ipa-inline.h (estimate_ipcp_clone_size_and_time): New function.
	(evaluate_conditions_for_known_args): Break out from ...
	(evaluate_conditions_for_edge): ... here.
	(evaluate_conditions_for_ipcp_clone): New function.
	(inline_node_duplication_hook): Update clone summary based
	on parameter map.
	(estimate_callee_size_and_time): Rename to ...
	(estimate_node_size_and_time): take NODE instead of EDGE;
	take POSSIBLE_TRUTHS as argument.
	(estimate_callee_size_and_time): Update.
	(estimate_ipcp_clone_size_and_time): New function.
	(do_estimate_edge_time): Update.

From-SVN: r173551
parent 5c049507
2011-05-08 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_clone_node): Add call_duplication_hook parameter.
(cgraph_create_virtual_clone): Call hooks once virtual clone is finished.
* cgraph.h (cgraph_clone_node): Update prototype.
* ipa-cp.c (ipcp_estimate_growth): Use estimate_ipcp_clone_size_and_time.
* ipa-inline-transform.c (clone_inlined_nodes): Update.
* lto-cgraph.c (input_node): Update.
* ipa-inline.c (recursive_inlining): Update.
* ipa-inline.h (estimate_ipcp_clone_size_and_time): New function.
(evaluate_conditions_for_known_args): Break out from ...
(evaluate_conditions_for_edge): ... here.
(evaluate_conditions_for_ipcp_clone): New function.
(inline_node_duplication_hook): Update clone summary based
on parameter map.
(estimate_callee_size_and_time): Rename to ...
(estimate_node_size_and_time): take NODE instead of EDGE;
take POSSIBLE_TRUTHS as argument.
(estimate_callee_size_and_time): Update.
(estimate_ipcp_clone_size_and_time): New function.
(do_estimate_edge_time): Update.
2011-05-08 Richard Guenther <rguenther@suse.de>
PR middle-end/48908
......
......@@ -2128,6 +2128,7 @@ cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n,
return new_edge;
}
/* Create node representing clone of N executed COUNT times. Decrease
the execution counts from original node too.
The new clone will have decl set to DECL that may or may not be the same
......@@ -2135,11 +2136,15 @@ cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n,
When UPDATE_ORIGINAL is true, the counts are subtracted from the original
function's profile to reflect the fact that part of execution is handled
by node. */
by node.
When CALL_DUPLICATOIN_HOOK is true, the ipa passes are acknowledged about
the new clone. Otherwise the caller is responsible for doing so later. */
struct cgraph_node *
cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
bool update_original,
VEC(cgraph_edge_p,heap) *redirect_callers)
VEC(cgraph_edge_p,heap) *redirect_callers,
bool call_duplication_hook)
{
struct cgraph_node *new_node = cgraph_create_node_1 ();
struct cgraph_edge *e;
......@@ -2202,7 +2207,6 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
n->clones = new_node;
new_node->clone_of = n;
cgraph_call_node_duplication_hooks (n, new_node);
if (n->decl != decl)
{
struct cgraph_node **slot;
......@@ -2221,6 +2225,9 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
*aslot = new_node;
}
}
if (call_duplication_hook)
cgraph_call_node_duplication_hooks (n, new_node);
return new_node;
}
......@@ -2287,7 +2294,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
new_node = cgraph_clone_node (old_node, new_decl, old_node->count,
CGRAPH_FREQ_BASE, false,
redirect_callers);
redirect_callers, false);
/* Update the properties.
Make clone visible only within this translation unit. Make sure
that is not weak also.
......@@ -2358,6 +2365,8 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
new_node->lowered = true;
new_node->reachable = true;
cgraph_call_node_duplication_hooks (old_node, new_node);
return new_node;
}
......
......@@ -506,7 +506,8 @@ struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
struct cgraph_node *, gimple,
unsigned, gcov_type, int, bool);
struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
int, bool, VEC(cgraph_edge_p,heap) *);
int, bool, VEC(cgraph_edge_p,heap) *,
bool);
void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *,
......
......@@ -430,6 +430,11 @@ verify_edge_count_and_frequency (struct cgraph_edge *e)
}
if (gimple_has_body_p (e->caller->decl)
&& !e->caller->global.inlined_to
/* FIXME: Inline-analysis sets frequency to 0 when edge is optimized out.
Remove this once edges are actualy removed from the function at that time. */
&& (e->frequency
|| (inline_edge_summary_vec
&& !inline_edge_summary (e)->predicate))
&& (e->frequency
!= compute_call_stmt_bb_frequency (e->caller->decl,
gimple_bb (e->call_stmt))))
......
......@@ -1102,7 +1102,8 @@ ipcp_estimate_growth (struct cgraph_node *node)
call site. Precise cost is difficult to get, as our size metric counts
constants and moves as free. Generally we are looking for cases that
small function is called very many times. */
growth = inline_summary (node)->self_size
estimate_ipcp_clone_size_and_time (node, &growth, NULL);
growth = growth
- removable_args * redirectable_node_callers;
if (growth < 0)
return 0;
......
......@@ -133,7 +133,7 @@ clone_inlined_nodes (struct cgraph_edge *e, bool duplicate,
struct cgraph_node *n;
n = cgraph_clone_node (e->callee, e->callee->decl,
e->count, e->frequency,
update_original, NULL);
update_original, NULL, true);
cgraph_redirect_edge_callee (e, n);
}
}
......
......@@ -1174,7 +1174,7 @@ recursive_inlining (struct cgraph_edge *edge,
/* We need original clone to copy around. */
master_clone = cgraph_clone_node (node, node->decl,
node->count, CGRAPH_FREQ_BASE,
false, NULL);
false, NULL, true);
for (e = master_clone->callees; e; e = e->next_callee)
if (!e->inline_failed)
clone_inlined_nodes (e, true, false, NULL);
......
......@@ -149,6 +149,7 @@ void inline_free_summary (void);
void initialize_inline_failed (struct cgraph_edge *);
int estimate_time_after_inlining (struct cgraph_node *, struct cgraph_edge *);
int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
void estimate_ipcp_clone_size_and_time (struct cgraph_node *, int *, int *);
int do_estimate_growth (struct cgraph_node *);
void inline_merge_summary (struct cgraph_edge *edge);
int do_estimate_edge_growth (struct cgraph_edge *edge);
......
......@@ -999,7 +999,7 @@ input_node (struct lto_file_decl_data *file_data,
if (clone_ref != LCC_NOT_FOUND)
{
node = cgraph_clone_node (VEC_index (cgraph_node_ptr, nodes, clone_ref), fn_decl,
0, CGRAPH_FREQ_BASE, false, NULL);
0, CGRAPH_FREQ_BASE, false, NULL, false);
}
else
node = cgraph_get_create_node (fn_decl);
......
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