Commit 0dbca537 by Jan Hubicka Committed by Jan Hubicka

ipa-cp.c (ipcp_analyze_node): New function.

	* ipa-cp.c (ipcp_analyze_node): New function.
	(ipcp_update_cloned_node): Use it.
	(ipcp_init_stage): Likewise.
	* ipa-inline.c (function_insertion_hook_holder): New static var.
	(analyze_function): Break out from ....
	(inline_generate_summary): Here; register insertion hook.
	(cgraph_decide_inlining): Remove hook.
	(add_new_function): New function.

From-SVN: r139536
parent 30b608eb
2008-08-23 Jan Hubicka <jh@suse.cz> 2008-08-23 Jan Hubicka <jh@suse.cz>
* ipa-cp.c (ipcp_analyze_node): New function.
(ipcp_update_cloned_node): Use it.
(ipcp_init_stage): Likewise.
* ipa-inline.c (function_insertion_hook_holder): New static var.
(analyze_function): Break out from ....
(inline_generate_summary): Here; register insertion hook.
(cgraph_decide_inlining): Remove hook.
(add_new_function): New function.
2008-08-23 Jan Hubicka <jh@suse.cz>
* opts.c (decode_options): Revert accidental change enabling ipa-cp. * opts.c (decode_options): Revert accidental change enabling ipa-cp.
2008-08-23 Jan Hubicka <jh@suse.cz> 2008-08-23 Jan Hubicka <jh@suse.cz>
......
...@@ -159,6 +159,18 @@ ipcp_init_cloned_node (struct cgraph_node *orig_node, ...@@ -159,6 +159,18 @@ ipcp_init_cloned_node (struct cgraph_node *orig_node,
ipa_create_param_decls_array (new_node); ipa_create_param_decls_array (new_node);
} }
/* Perform intraprocedrual analysis needed for ipcp. */
static void
ipcp_analyze_node (struct cgraph_node *node)
{
/* Unreachable nodes should have been eliminated before ipcp. */
gcc_assert (node->needed || node->reachable);
ipa_count_formal_params (node);
ipa_create_param_decls_array (node);
ipa_detect_param_modifications (node);
}
/* Recompute all local information since node might've got new /* Recompute all local information since node might've got new
direct calls after clonning. */ direct calls after clonning. */
static void static void
...@@ -169,15 +181,13 @@ ipcp_update_cloned_node (struct cgraph_node *new_node) ...@@ -169,15 +181,13 @@ ipcp_update_cloned_node (struct cgraph_node *new_node)
current_function_decl = new_node->decl; current_function_decl = new_node->decl;
rebuild_cgraph_edges (); rebuild_cgraph_edges ();
/* Indirect inlinng rely on fact that we've already analyzed
the body.. */
if (flag_indirect_inlining) if (flag_indirect_inlining)
{ {
struct cgraph_edge *cs; struct cgraph_edge *cs;
ipa_check_create_node_params (); ipcp_analyze_node (new_node);
ipa_count_formal_params (new_node);
ipa_create_param_decls_array (new_node);
ipa_detect_param_modifications (new_node);
ipa_analyze_params_uses (new_node);
for (cs = new_node->callees; cs; cs = cs->next_callee) for (cs = new_node->callees; cs; cs = cs->next_callee)
{ {
...@@ -418,16 +428,10 @@ ipcp_init_stage (void) ...@@ -418,16 +428,10 @@ ipcp_init_stage (void)
struct cgraph_edge *cs; struct cgraph_edge *cs;
for (node = cgraph_nodes; node; node = node->next) for (node = cgraph_nodes; node; node = node->next)
if (node->analyzed)
{ {
if (!node->analyzed) ipcp_analyze_node (node);
continue;
/* Unreachable nodes should have been eliminated before ipcp. */
gcc_assert (node->needed || node->reachable);
ipa_count_formal_params (node);
ipa_create_param_decls_array (node);
ipcp_initialize_node_lattices (node); ipcp_initialize_node_lattices (node);
ipa_detect_param_modifications (node);
ipcp_compute_node_scale (node); ipcp_compute_node_scale (node);
} }
for (node = cgraph_nodes; node; node = node->next) for (node = cgraph_nodes; node; node = node->next)
......
...@@ -166,6 +166,9 @@ static int nfunctions_inlined; ...@@ -166,6 +166,9 @@ static int nfunctions_inlined;
static int overall_insns; static int overall_insns;
static gcov_type max_count; static gcov_type max_count;
/* Holders of ipa cgraph hooks: */
static struct cgraph_node_hook_list *function_insertion_hook_holder;
static inline struct inline_summary * static inline struct inline_summary *
inline_summary (struct cgraph_node *node) inline_summary (struct cgraph_node *node)
{ {
...@@ -1073,6 +1076,8 @@ cgraph_decide_inlining (void) ...@@ -1073,6 +1076,8 @@ cgraph_decide_inlining (void)
int i; int i;
int initial_insns = 0; int initial_insns = 0;
cgraph_remove_function_insertion_hook (function_insertion_hook_holder);
max_count = 0; max_count = 0;
for (node = cgraph_nodes; node; node = node->next) for (node = cgraph_nodes; node; node = node->next)
if (node->analyzed && (node->needed || node->reachable)) if (node->analyzed && (node->needed || node->reachable))
...@@ -1657,12 +1662,34 @@ inline_indirect_intraprocedural_analysis (struct cgraph_node *node) ...@@ -1657,12 +1662,34 @@ inline_indirect_intraprocedural_analysis (struct cgraph_node *node)
/* Note function body size. */ /* Note function body size. */
static void static void
analyze_function (struct cgraph_node *node)
{
push_cfun (DECL_STRUCT_FUNCTION (node->decl));
current_function_decl = node->decl;
compute_inline_parameters (node);
if (flag_indirect_inlining)
inline_indirect_intraprocedural_analysis (node);
current_function_decl = NULL;
pop_cfun ();
}
/* Called when new function is inserted to callgraph late. */
static void
add_new_function (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
{
analyze_function (node);
}
/* Note function body size. */
static void
inline_generate_summary (void) inline_generate_summary (void)
{ {
struct cgraph_node **order = struct cgraph_node *node;
XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
int nnodes = cgraph_postorder (order); function_insertion_hook_holder =
int i; cgraph_add_function_insertion_hook (&add_new_function, NULL);
if (flag_indirect_inlining) if (flag_indirect_inlining)
{ {
...@@ -1671,27 +1698,10 @@ inline_generate_summary (void) ...@@ -1671,27 +1698,10 @@ inline_generate_summary (void)
ipa_check_create_edge_args (); ipa_check_create_edge_args ();
} }
for (i = nnodes - 1; i >= 0; i--) for (node = cgraph_nodes; node; node = node->next)
{ if (node->analyzed)
struct cgraph_node *node = order[i]; analyze_function (node);
/* Allow possibly removed nodes to be garbage collected. */
order[i] = NULL;
if (node->analyzed && (node->needed || node->reachable))
{
push_cfun (DECL_STRUCT_FUNCTION (node->decl));
current_function_decl = node->decl;
compute_inline_parameters (node);
if (flag_indirect_inlining)
inline_indirect_intraprocedural_analysis (node);
pop_cfun ();
}
}
current_function_decl = NULL;
free (order);
return; return;
} }
......
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