Commit ca30a539 by Jan Hubicka Committed by Jan Hubicka

cgraph.c (cgraph_remove_node): Do not remove nested nodes.


	* cgraph.c (cgraph_remove_node): Do not remove nested nodes.

	* cgraph.h (cgraph_maybe_hot_edge_p): Declare.
	* ipa-cp.c (n_cloning_candidates): New static variable.
	(ipcp_print_profile_data, ipcp_function_scale_print): Forward declare.
	(ipcp_print_all_lattices): Improve debug output.
	(ipcp_cloning_candidate_p): New function.
	(ipcp_initialize_node_lattices): Use it.
	(ipcp_init_stage): Do only analyzis here; prettier debug output.
	(ipcp_propagate_stage): Prettier debug output.
	(ipcp_iterate_stage): Initialize latices here; prettier debug output.
	(ipcp_print_all_structures): Remove.
	(ipcp_need_redirect_p): Test !n_cloning_candidates.
	(ipcp_insert_stage): Prettier debug output; call
	cgraph_remove_unreachable_nodes before propagating.
	(pass_ipa_cp): Schedule function removal pass.
	* ipa-inline.c (inline_indirect_intraprocedural_analysis): Better
	debug output.
	(cgraph_maybe_hot_edge_p): Move to ...
	* predict.c (cgraph_maybe_hot_edge_p) ... here.
	* opts.c (flag_ipa_cp_set, flag_ipa_cp_clone_set): New.
	(common_handle_option): Set them; enable ipa-cp when profiling.
	* ipa-prop.c (ipa_print_node_jump_functions): Prettier output.
	(ipa_print_all_jump_functions): Likewise.
	(ipa_print_all_tree_maps, ipa_print_node_param_flags): Remove.
	(ipa_print_node_params, ipa_print_all_params): New.
	* ipa-prop.h (ipa_print_all_tree_maps, ipa_print_node_param_flags,
	ipa_print_all_param_flags): Remove.
	(ipa_print_node_params, ipa_print_all_params): New.

From-SVN: r139772
parent a1f626ad
2008-08-29 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_remove_node): Do not remove nested nodes.
* cgraph.h (cgraph_maybe_hot_edge_p): Declare.
* ipa-cp.c (n_cloning_candidates): New static variable.
(ipcp_print_profile_data, ipcp_function_scale_print): Forward declare.
(ipcp_print_all_lattices): Improve debug output.
(ipcp_cloning_candidate_p): New function.
(ipcp_initialize_node_lattices): Use it.
(ipcp_init_stage): Do only analyzis here; prettier debug output.
(ipcp_propagate_stage): Prettier debug output.
(ipcp_iterate_stage): Initialize latices here; prettier debug output.
(ipcp_print_all_structures): Remove.
(ipcp_need_redirect_p): Test !n_cloning_candidates.
(ipcp_insert_stage): Prettier debug output; call
cgraph_remove_unreachable_nodes before propagating.
(pass_ipa_cp): Schedule function removal pass.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Better
debug output.
(cgraph_maybe_hot_edge_p): Move to ...
* predict.c (cgraph_maybe_hot_edge_p) ... here.
* opts.c (flag_ipa_cp_set, flag_ipa_cp_clone_set): New.
(common_handle_option): Set them; enable ipa-cp when profiling.
* ipa-prop.c (ipa_print_node_jump_functions): Prettier output.
(ipa_print_all_jump_functions): Likewise.
(ipa_print_all_tree_maps, ipa_print_node_param_flags): Remove.
(ipa_print_node_params, ipa_print_all_params): New.
* ipa-prop.h (ipa_print_all_tree_maps, ipa_print_node_param_flags,
ipa_print_all_param_flags): Remove.
(ipa_print_node_params, ipa_print_all_params): New.
2008-08-29 Bob Wilson <bob.wilson@acm.org> 2008-08-29 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/xtensa.c (xtensa_secondary_reload_class): Revert * config/xtensa/xtensa.c (xtensa_secondary_reload_class): Revert
......
...@@ -857,6 +857,7 @@ cgraph_remove_node (struct cgraph_node *node) ...@@ -857,6 +857,7 @@ cgraph_remove_node (struct cgraph_node *node)
{ {
void **slot; void **slot;
bool kill_body = false; bool kill_body = false;
struct cgraph_node *n;
cgraph_call_node_removal_hooks (node); cgraph_call_node_removal_hooks (node);
cgraph_node_remove_callers (node); cgraph_node_remove_callers (node);
...@@ -865,8 +866,9 @@ cgraph_remove_node (struct cgraph_node *node) ...@@ -865,8 +866,9 @@ cgraph_remove_node (struct cgraph_node *node)
/* Incremental inlining access removed nodes stored in the postorder list. /* Incremental inlining access removed nodes stored in the postorder list.
*/ */
node->needed = node->reachable = false; node->needed = node->reachable = false;
while (node->nested) for (n = node->nested; n; n = n->next_nested)
cgraph_remove_node (node->nested); n->origin = NULL;
node->nested = NULL;
if (node->origin) if (node->origin)
{ {
struct cgraph_node **node2 = &node->origin->nested; struct cgraph_node **node2 = &node->origin->nested;
......
...@@ -390,6 +390,8 @@ int compute_call_stmt_bb_frequency (basic_block bb); ...@@ -390,6 +390,8 @@ int compute_call_stmt_bb_frequency (basic_block bb);
bool cgraph_remove_unreachable_nodes (bool, FILE *); bool cgraph_remove_unreachable_nodes (bool, FILE *);
int cgraph_postorder (struct cgraph_node **); int cgraph_postorder (struct cgraph_node **);
bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
/* In varpool.c */ /* In varpool.c */
extern GTY(()) struct varpool_node *varpool_nodes_queue; extern GTY(()) struct varpool_node *varpool_nodes_queue;
......
...@@ -468,26 +468,6 @@ cgraph_recursive_inlining_p (struct cgraph_node *to, ...@@ -468,26 +468,6 @@ cgraph_recursive_inlining_p (struct cgraph_node *to,
return recursive; return recursive;
} }
/* Return true if the call can be hot. */
static bool
cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
{
if (profile_info && flag_branch_probabilities
&& (edge->count
<= profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
return false;
if (lookup_attribute ("cold", DECL_ATTRIBUTES (edge->callee->decl))
|| lookup_attribute ("cold", DECL_ATTRIBUTES (edge->caller->decl)))
return false;
if (lookup_attribute ("hot", DECL_ATTRIBUTES (edge->caller->decl)))
return true;
if (flag_guess_branch_prob
&& edge->frequency < (CGRAPH_FREQ_MAX
/ PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
return false;
return true;
}
/* A cost model driving the inlining heuristics in a way so the edges with /* A cost model driving the inlining heuristics in a way so the edges with
smallest badness are inlined first. After each inlining is performed smallest badness are inlined first. After each inlining is performed
the costs of all caller edges of nodes affected are recomputed so the the costs of all caller edges of nodes affected are recomputed so the
...@@ -1646,9 +1626,6 @@ inline_indirect_intraprocedural_analysis (struct cgraph_node *node) ...@@ -1646,9 +1626,6 @@ inline_indirect_intraprocedural_analysis (struct cgraph_node *node)
} }
ipa_analyze_params_uses (node); ipa_analyze_params_uses (node);
if (dump_file)
ipa_print_node_param_flags (dump_file, node);
if (!flag_ipa_cp) if (!flag_ipa_cp)
for (cs = node->callees; cs; cs = cs->next_callee) for (cs = node->callees; cs; cs = cs->next_callee)
{ {
...@@ -1657,7 +1634,10 @@ inline_indirect_intraprocedural_analysis (struct cgraph_node *node) ...@@ -1657,7 +1634,10 @@ inline_indirect_intraprocedural_analysis (struct cgraph_node *node)
} }
if (dump_file) if (dump_file)
{
ipa_print_node_params (dump_file, node);
ipa_print_node_jump_functions (dump_file, node); ipa_print_node_jump_functions (dump_file, node);
}
} }
/* Note function body size. */ /* Note function body size. */
......
...@@ -255,13 +255,13 @@ ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node) ...@@ -255,13 +255,13 @@ ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node)
struct ipa_jump_func *jump_func; struct ipa_jump_func *jump_func;
enum jump_func_type type; enum jump_func_type type;
fprintf (f, "JUMP FUNCTIONS OF CALLER %s:\n", cgraph_node_name (node)); fprintf (f, " Jump functions of caller %s:\n", cgraph_node_name (node));
for (cs = node->callees; cs; cs = cs->next_callee) for (cs = node->callees; cs; cs = cs->next_callee)
{ {
if (!ipa_edge_args_info_available_for_edge_p (cs)) if (!ipa_edge_args_info_available_for_edge_p (cs))
continue; continue;
fprintf (f, "callsite %s ", cgraph_node_name (node)); fprintf (f, " callsite %s ", cgraph_node_name (node));
fprintf (f, "-> %s :: \n", cgraph_node_name (cs->callee)); fprintf (f, "-> %s :: \n", cgraph_node_name (cs->callee));
count = ipa_get_cs_argument_count (IPA_EDGE_REF (cs)); count = ipa_get_cs_argument_count (IPA_EDGE_REF (cs));
...@@ -303,7 +303,7 @@ ipa_print_all_jump_functions (FILE *f) ...@@ -303,7 +303,7 @@ ipa_print_all_jump_functions (FILE *f)
{ {
struct cgraph_node *node; struct cgraph_node *node;
fprintf (f, "\nCALLSITE PARAM PRINT\n"); fprintf (f, "\nJump functions:\n");
for (node = cgraph_nodes; node; node = node->next) for (node = cgraph_nodes; node; node = node->next)
{ {
ipa_print_node_jump_functions (f, node); ipa_print_node_jump_functions (f, node);
...@@ -1207,48 +1207,23 @@ free_all_ipa_structures_after_iinln (void) ...@@ -1207,48 +1207,23 @@ free_all_ipa_structures_after_iinln (void)
/* Print ipa_tree_map data structures of all functions in the /* Print ipa_tree_map data structures of all functions in the
callgraph to F. */ callgraph to F. */
void void
ipa_print_all_tree_maps (FILE * f) ipa_print_node_params (FILE * f, struct cgraph_node *node)
{ {
int i, count; int i, count;
tree temp; tree temp;
struct cgraph_node *node;
fprintf (f, "\nPARAM TREE MAP PRINT\n");
for (node = cgraph_nodes; node; node = node->next)
{
struct ipa_node_params *info; struct ipa_node_params *info;
if (!node->analyzed) if (!node->analyzed)
continue; return;
info = IPA_NODE_REF (node); info = IPA_NODE_REF (node);
fprintf (f, "function %s Trees :: \n", cgraph_node_name (node)); fprintf (f, " function %s Trees :: \n", cgraph_node_name (node));
count = ipa_get_param_count (info); count = ipa_get_param_count (info);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
temp = ipa_get_ith_param (info, i); temp = ipa_get_ith_param (info, i);
if (TREE_CODE (temp) == PARM_DECL) if (TREE_CODE (temp) == PARM_DECL)
fprintf (f, " param [%d] : %s\n", i, fprintf (f, " param %d : %s", i,
(*lang_hooks.decl_printable_name) (temp, 2)); (*lang_hooks.decl_printable_name) (temp, 2));
}
}
}
/* Print param_flags data structures of the NODE to F. */
void
ipa_print_node_param_flags (FILE * f, struct cgraph_node *node)
{
int i, count;
struct ipa_node_params *info;
if (!node->analyzed)
return;
info = IPA_NODE_REF (node);
fprintf (f, "PARAM FLAGS of function %s: \n", cgraph_node_name (node));
count = ipa_get_param_count (info);
for (i = 0; i < count; i++)
{
fprintf (f, " param %d flags:", i);
if (ipa_is_ith_param_modified (info, i)) if (ipa_is_ith_param_modified (info, i))
fprintf (f, " modified"); fprintf (f, " modified");
if (ipa_is_ith_param_called (info, i)) if (ipa_is_ith_param_called (info, i))
...@@ -1257,14 +1232,14 @@ ipa_print_node_param_flags (FILE * f, struct cgraph_node *node) ...@@ -1257,14 +1232,14 @@ ipa_print_node_param_flags (FILE * f, struct cgraph_node *node)
} }
} }
/* Print param_flags data structures of all functions in the /* Print ipa_tree_map data structures of all functions in the
callgraph to F. */ callgraph to F. */
void void
ipa_print_all_param_flags (FILE * f) ipa_print_all_params (FILE * f)
{ {
struct cgraph_node *node; struct cgraph_node *node;
fprintf (f, "\nIPA PARAM FLAGS DUMP\n"); fprintf (f, "\nFunction parameters:\n");
for (node = cgraph_nodes; node; node = node->next) for (node = cgraph_nodes; node; node = node->next)
ipa_print_node_param_flags (f, node); ipa_print_node_params (f, node);
} }
...@@ -381,9 +381,8 @@ void ipa_propagate_indirect_call_infos (struct cgraph_edge *cs, ...@@ -381,9 +381,8 @@ void ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
VEC (cgraph_edge_p, heap) *new_edges); VEC (cgraph_edge_p, heap) *new_edges);
/* Debugging interface. */ /* Debugging interface. */
void ipa_print_all_tree_maps (FILE *); void ipa_print_node_params (FILE *, struct cgraph_node *node);
void ipa_print_node_param_flags (FILE * f, struct cgraph_node *node); void ipa_print_all_params (FILE *);
void ipa_print_all_param_flags (FILE *);
void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node); void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
void ipa_print_all_jump_functions (FILE * f); void ipa_print_all_jump_functions (FILE * f);
......
...@@ -347,7 +347,7 @@ static bool profile_arc_flag_set, flag_profile_values_set; ...@@ -347,7 +347,7 @@ static bool profile_arc_flag_set, flag_profile_values_set;
static bool flag_unroll_loops_set, flag_tracer_set; static bool flag_unroll_loops_set, flag_tracer_set;
static bool flag_value_profile_transformations_set; static bool flag_value_profile_transformations_set;
static bool flag_peel_loops_set, flag_branch_probabilities_set; static bool flag_peel_loops_set, flag_branch_probabilities_set;
static bool flag_inline_functions_set; static bool flag_inline_functions_set, flag_ipa_cp_set, flag_ipa_cp_clone_set;
/* Functions excluded from profiling. */ /* Functions excluded from profiling. */
...@@ -1031,9 +1031,6 @@ decode_options (unsigned int argc, const char **argv) ...@@ -1031,9 +1031,6 @@ decode_options (unsigned int argc, const char **argv)
/* We want to crossjump as much as possible. */ /* We want to crossjump as much as possible. */
set_param_value ("min-crossjump-insns", 1); set_param_value ("min-crossjump-insns", 1);
/* Do not perform clonning in ipcp. */
flag_ipa_cp_clone = 0;
} }
else else
set_param_value ("min-crossjump-insns", initial_min_crossjump_insns); set_param_value ("min-crossjump-insns", initial_min_crossjump_insns);
...@@ -1837,6 +1834,11 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1837,6 +1834,11 @@ common_handle_option (size_t scode, const char *arg, int value,
flag_value_profile_transformations = value; flag_value_profile_transformations = value;
if (!flag_inline_functions_set) if (!flag_inline_functions_set)
flag_inline_functions = value; flag_inline_functions = value;
if (!flag_ipa_cp_set)
flag_ipa_cp = value;
if (!flag_ipa_cp_clone_set
&& value && flag_ipa_cp)
flag_ipa_cp_clone = value;
break; break;
case OPT_fprofile_generate_: case OPT_fprofile_generate_:
...@@ -1994,6 +1996,14 @@ common_handle_option (size_t scode, const char *arg, int value, ...@@ -1994,6 +1996,14 @@ common_handle_option (size_t scode, const char *arg, int value,
flag_tracer_set = true; flag_tracer_set = true;
break; break;
case OPT_fipa_cp:
flag_ipa_cp_set = true;
break;
case OPT_fipa_cp_clone:
flag_ipa_cp_clone_set = true;
break;
case OPT_funroll_loops: case OPT_funroll_loops:
flag_unroll_loops_set = true; flag_unroll_loops_set = true;
break; break;
......
...@@ -138,6 +138,27 @@ maybe_hot_bb_p (const_basic_block bb) ...@@ -138,6 +138,27 @@ maybe_hot_bb_p (const_basic_block bb)
return maybe_hot_frequency_p (bb->frequency); return maybe_hot_frequency_p (bb->frequency);
} }
/* Return true if the call can be hot. */
bool
cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
{
if (profile_info && flag_branch_probabilities
&& (edge->count
<= profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
return false;
if (lookup_attribute ("cold", DECL_ATTRIBUTES (edge->callee->decl))
|| lookup_attribute ("cold", DECL_ATTRIBUTES (edge->caller->decl)))
return false;
if (lookup_attribute ("hot", DECL_ATTRIBUTES (edge->caller->decl)))
return true;
if (flag_guess_branch_prob
&& edge->frequency < (CGRAPH_FREQ_MAX
/ PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
return false;
return true;
}
/* Return true in case BB can be CPU intensive and should be optimized /* Return true in case BB can be CPU intensive and should be optimized
for maximal performance. */ for maximal performance. */
......
2008-08-29 Jan Hubicka <jh@suse.cz> 2008-08-29 Jan Hubicka <jh@suse.cz>
* gcc.dg/ipa/modif-1.c: Update template.
2008-08-29 Jan Hubicka <jh@suse.cz>
* gcc.dg/ipa/ipa-1.c: Fix template for better debug output. * gcc.dg/ipa/ipa-1.c: Fix template for better debug output.
* gcc.dg/ipa/ipa-2.c: Fix template for better debug output. * gcc.dg/ipa/ipa-2.c: Fix template for better debug output.
* gcc.dg/ipa/ipa-3.c: Fix template for better debug output. * gcc.dg/ipa/ipa-3.c: Fix template for better debug output.
......
/* Verify that modification analysis detects modfications. */ /* Verify that modification analysis detects modfications. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O3 -c -fdump-ipa-inline -fno-early-inlining" } */ /* { dg-options "-O3 -c -fdump-ipa-inline-details -fno-early-inlining" } */
struct whatever struct whatever
{ {
...@@ -33,12 +33,12 @@ void the_test (struct whatever u, struct whatever v, ...@@ -33,12 +33,12 @@ void the_test (struct whatever u, struct whatever v,
func4 (&l); func4 (&l);
} }
/* { dg-final { scan-ipa-dump-not "param 0 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump-not "param 0\[^\\n\]*modified" "inline" } } */
/* { dg-final { scan-ipa-dump "param 1 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump "param 1\[^\\n\]*modified" "inline" } } */
/* { dg-final { scan-ipa-dump "param 2 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump "param 2\[^\\n\]*modified" "inline" } } */
/* { dg-final { scan-ipa-dump "param 3 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump "param 3\[^\\n\]*modified" "inline" } } */
/* { dg-final { scan-ipa-dump-not "param 4 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump-not "param 4\[^\\n\]*modified" "inline" } } */
/* { dg-final { scan-ipa-dump "param 5 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump "param 5\[^\\n\]*modified" "inline" } } */
/* { dg-final { scan-ipa-dump "param 6 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump "param 6\[^\\n\]*modified" "inline" } } */
/* { dg-final { scan-ipa-dump "param 7 flags:\[^\\n\]*modified" "inline" } } */ /* { dg-final { scan-ipa-dump "param 7\[^\\n\]*modified" "inline" } } */
/* { dg-final { cleanup-ipa-dump "inline" } } */ /* { dg-final { cleanup-ipa-dump "inline" } } */
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