Commit febb1302 by Jan Hubicka Committed by Jan Hubicka

re PR middle-end/49373 (Many testcase failures)

	PR tree-optimize/49373
	* tree-pass.h (all_late_ipa_passes): Declare.
	* cgraphunit.c (init_lowered_empty_function): Fix properties.
	(cgraph_optimize): Execute late passes; remove unreachable funcions after
	materialization.
	* ipa-inline.c (gate_ipa_inline): Enable only when optimizing or LTOing.
	* passes.c (all_late_ipa_passes): Declare.
	(dump_passes, register_pass): Handle late ipa passes.
	(init_optimization_passes): Move ipa_pta to late passes; schedule fixup_cfg
	at beggining of all_passes.
	(apply_ipa_transforms): New function.
	(execute_one_pass): When doing simple ipa pass, apply all transforms.

From-SVN: r175336
parent 4c77620d
2011-06-23 Jan Hubicka <jh@suse.cz>
PR tree-optimize/49373
* tree-pass.h (all_late_ipa_passes): Declare.
* cgraphunit.c (init_lowered_empty_function): Fix properties.
(cgraph_optimize): Execute late passes; remove unreachable funcions after
materialization.
* ipa-inline.c (gate_ipa_inline): Enable only when optimizing or LTOing.
* passes.c (all_late_ipa_passes): Declare.
(dump_passes, register_pass): Handle late ipa passes.
(init_optimization_passes): Move ipa_pta to late passes; schedule fixup_cfg
at beggining of all_passes.
(apply_ipa_transforms): New function.
(execute_one_pass): When doing simple ipa pass, apply all transforms.
2011-06-23 Joseph Myers <joseph@codesourcery.com> 2011-06-23 Joseph Myers <joseph@codesourcery.com>
* params.c: Include common/common-target.h. Don't include tm.h. * params.c: Include common/common-target.h. Don't include tm.h.
......
...@@ -1420,7 +1420,7 @@ init_lowered_empty_function (tree decl) ...@@ -1420,7 +1420,7 @@ init_lowered_empty_function (tree decl)
DECL_SAVED_TREE (decl) = error_mark_node; DECL_SAVED_TREE (decl) = error_mark_node;
cfun->curr_properties |= cfun->curr_properties |=
(PROP_gimple_lcf | PROP_gimple_leh | PROP_cfg | PROP_referenced_vars | (PROP_gimple_lcf | PROP_gimple_leh | PROP_cfg | PROP_referenced_vars |
PROP_ssa); PROP_ssa | PROP_gimple_any);
/* Create BB for body of the function and connect it properly. */ /* Create BB for body of the function and connect it properly. */
bb = create_basic_block (NULL, (void *) 0, ENTRY_BLOCK_PTR); bb = create_basic_block (NULL, (void *) 0, ENTRY_BLOCK_PTR);
...@@ -2102,6 +2102,13 @@ cgraph_optimize (void) ...@@ -2102,6 +2102,13 @@ cgraph_optimize (void)
#endif #endif
cgraph_materialize_all_clones (); cgraph_materialize_all_clones ();
bitmap_obstack_initialize (NULL);
execute_ipa_pass_list (all_late_ipa_passes);
cgraph_remove_unreachable_nodes (true, dump_file);
#ifdef ENABLE_CHECKING
verify_cgraph ();
#endif
bitmap_obstack_release (NULL);
cgraph_mark_functions_to_output (); cgraph_mark_functions_to_output ();
cgraph_state = CGRAPH_STATE_EXPANSION; cgraph_state = CGRAPH_STATE_EXPANSION;
......
...@@ -1972,17 +1972,15 @@ struct gimple_opt_pass pass_early_inline = ...@@ -1972,17 +1972,15 @@ struct gimple_opt_pass pass_early_inline =
/* When to run IPA inlining. Inlining of always-inline functions /* When to run IPA inlining. Inlining of always-inline functions
happens during early inlining. */ happens during early inlining.
Enable inlining unconditoinally at -flto. We need size estimates to
drive partitioning. */
static bool static bool
gate_ipa_inline (void) gate_ipa_inline (void)
{ {
/* ??? We'd like to skip this if not optimizing or not inlining as return optimize || flag_lto || flag_wpa;
all always-inline functions have been processed by early
inlining already. But this at least breaks EH with C++ as
we need to unconditionally run fixup_cfg even at -O0.
So leave it on unconditionally for now. */
return 1;
} }
struct ipa_opt_pass_d pass_ipa_inline = struct ipa_opt_pass_d pass_ipa_inline =
......
...@@ -332,7 +332,7 @@ struct rtl_opt_pass pass_postreload = ...@@ -332,7 +332,7 @@ struct rtl_opt_pass pass_postreload =
/* The root of the compilation pass tree, once constructed. */ /* The root of the compilation pass tree, once constructed. */
struct opt_pass *all_passes, *all_small_ipa_passes, *all_lowering_passes, struct opt_pass *all_passes, *all_small_ipa_passes, *all_lowering_passes,
*all_regular_ipa_passes, *all_lto_gen_passes; *all_regular_ipa_passes, *all_late_ipa_passes, *all_lto_gen_passes;
/* This is used by plugins, and should also be used in register_pass. */ /* This is used by plugins, and should also be used in register_pass. */
#define DEF_PASS_LIST(LIST) &LIST, #define DEF_PASS_LIST(LIST) &LIST,
...@@ -617,6 +617,7 @@ dump_passes (void) ...@@ -617,6 +617,7 @@ dump_passes (void)
dump_pass_list (all_small_ipa_passes, 1); dump_pass_list (all_small_ipa_passes, 1);
dump_pass_list (all_regular_ipa_passes, 1); dump_pass_list (all_regular_ipa_passes, 1);
dump_pass_list (all_lto_gen_passes, 1); dump_pass_list (all_lto_gen_passes, 1);
dump_pass_list (all_late_ipa_passes, 1);
dump_pass_list (all_passes, 1); dump_pass_list (all_passes, 1);
pop_cfun (); pop_cfun ();
...@@ -1103,6 +1104,8 @@ register_pass (struct register_pass_info *pass_info) ...@@ -1103,6 +1104,8 @@ register_pass (struct register_pass_info *pass_info)
if (!success || all_instances) if (!success || all_instances)
success |= position_pass (pass_info, &all_lto_gen_passes); success |= position_pass (pass_info, &all_lto_gen_passes);
if (!success || all_instances) if (!success || all_instances)
success |= position_pass (pass_info, &all_late_ipa_passes);
if (!success || all_instances)
success |= position_pass (pass_info, &all_passes); success |= position_pass (pass_info, &all_passes);
if (!success) if (!success)
fatal_error fatal_error
...@@ -1249,7 +1252,6 @@ init_optimization_passes (void) ...@@ -1249,7 +1252,6 @@ init_optimization_passes (void)
NEXT_PASS (pass_ipa_inline); NEXT_PASS (pass_ipa_inline);
NEXT_PASS (pass_ipa_pure_const); NEXT_PASS (pass_ipa_pure_const);
NEXT_PASS (pass_ipa_reference); NEXT_PASS (pass_ipa_reference);
NEXT_PASS (pass_ipa_pta);
*p = NULL; *p = NULL;
p = &all_lto_gen_passes; p = &all_lto_gen_passes;
...@@ -1257,9 +1259,16 @@ init_optimization_passes (void) ...@@ -1257,9 +1259,16 @@ init_optimization_passes (void)
NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */ NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */
*p = NULL; *p = NULL;
/* Simple IPA passes executed after the regular passes. In WHOPR mode the
passes are executed after partitioning and thus see just parts of the
compiled unit. */
p = &all_late_ipa_passes;
NEXT_PASS (pass_ipa_pta);
*p = NULL;
/* These passes are run after IPA passes on every function that is being /* These passes are run after IPA passes on every function that is being
output to the assembler file. */ output to the assembler file. */
p = &all_passes; p = &all_passes;
NEXT_PASS (pass_fixup_cfg);
NEXT_PASS (pass_lower_eh_dispatch); NEXT_PASS (pass_lower_eh_dispatch);
NEXT_PASS (pass_all_optimizations); NEXT_PASS (pass_all_optimizations);
{ {
...@@ -1517,6 +1526,9 @@ init_optimization_passes (void) ...@@ -1517,6 +1526,9 @@ init_optimization_passes (void)
register_dump_files (all_lto_gen_passes, register_dump_files (all_lto_gen_passes,
PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
| PROP_cfg); | PROP_cfg);
register_dump_files (all_late_ipa_passes,
PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
| PROP_cfg);
register_dump_files (all_passes, register_dump_files (all_passes,
PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
| PROP_cfg); | PROP_cfg);
...@@ -1935,6 +1947,20 @@ execute_all_ipa_transforms (void) ...@@ -1935,6 +1947,20 @@ execute_all_ipa_transforms (void)
} }
} }
/* Callback for do_per_function to apply all IPA transforms. */
static void
apply_ipa_transforms (void *data)
{
struct cgraph_node *node = cgraph_get_node (current_function_decl);
if (!node->global.inlined_to && node->ipa_transforms_to_apply)
{
*(bool *)data = true;
execute_all_ipa_transforms();
rebuild_cgraph_edges ();
}
}
/* Check if PASS is explicitly disabled or enabled and return /* Check if PASS is explicitly disabled or enabled and return
the gate status. FUNC is the function to be processed, and the gate status. FUNC is the function to be processed, and
GATE_STATUS is the gate status determined by pass manager by GATE_STATUS is the gate status determined by pass manager by
...@@ -1996,6 +2022,16 @@ execute_one_pass (struct opt_pass *pass) ...@@ -1996,6 +2022,16 @@ execute_one_pass (struct opt_pass *pass)
executed. */ executed. */
invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass); invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass);
/* SIPLE IPA passes do not handle callgraphs with IPA transforms in it.
Apply all trnasforms first. */
if (pass->type == SIMPLE_IPA_PASS)
{
bool applied = false;
do_per_function (apply_ipa_transforms, (void *)&applied);
if (applied)
cgraph_remove_unreachable_nodes (true, dump_file);
}
if (!quiet_flag && !cfun) if (!quiet_flag && !cfun)
fprintf (stderr, " <%s>", pass->name ? pass->name : ""); fprintf (stderr, " <%s>", pass->name ? pass->name : "");
......
...@@ -577,7 +577,7 @@ extern struct gimple_opt_pass pass_convert_switch; ...@@ -577,7 +577,7 @@ extern struct gimple_opt_pass pass_convert_switch;
/* The root of the compilation pass tree, once constructed. */ /* The root of the compilation pass tree, once constructed. */
extern struct opt_pass *all_passes, *all_small_ipa_passes, *all_lowering_passes, extern struct opt_pass *all_passes, *all_small_ipa_passes, *all_lowering_passes,
*all_regular_ipa_passes, *all_lto_gen_passes; *all_regular_ipa_passes, *all_lto_gen_passes, *all_late_ipa_passes;
/* Define a list of pass lists so that both passes.c and plugins can easily /* Define a list of pass lists so that both passes.c and plugins can easily
find all the pass lists. */ find all the pass lists. */
......
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