From: Jan Hubicka Date: Wed, 20 Aug 2014 13:55:06 +0000 (+0200) Subject: cgraphunit.c (ipa_passes, compile): Reshedule symtab_remove_unreachable_nodes passes... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8605403e2bcb731d5f1c8579a9c2ea3436e2fb27;p=gcc.git cgraphunit.c (ipa_passes, compile): Reshedule symtab_remove_unreachable_nodes passes; update comments. * cgraphunit.c (ipa_passes, compile): Reshedule symtab_remove_unreachable_nodes passes; update comments. * ipa-inline.c (pass_data_ipa_inline): Do not schedule TODO_remove_functions before the pass; the functions ought to be already removed. * ipa.c (pass_data_ipa_free_inline_summary): Enable dump; schedule TODO_remove_functions. * passes.c (pass_data_early_local_passes): Do not schedule function removal. (execute_one_pass): Fix call of symtab_remove_unreachable_nodes. * lto.c (read_cgraph_and_symbols): Fix symtab_remove_unreachable_nodes call. (do_whole_program_analysis): Only sanity check that IPA passes cleans up. * testsuite/g++.dg/ipa/devirt-17.C: Update template. * testsuite/g++.dg/ipa/devirt-16.C: Update template. From-SVN: r214224 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 00497633a9b..2ce924fb3f0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2014-08-20 Jan Hubicka + + * cgraphunit.c (ipa_passes, compile): Reshedule + symtab_remove_unreachable_nodes passes; update comments. + * ipa-inline.c (pass_data_ipa_inline): Do not schedule + TODO_remove_functions before the pass; the functions ought to be + already removed. + * ipa.c (pass_data_ipa_free_inline_summary): Enable dump; schedule + TODO_remove_functions. + * passes.c (pass_data_early_local_passes): Do not schedule function + removal. + (execute_one_pass): Fix call of symtab_remove_unreachable_nodes. + 2014-08-20 Manuel López-Ibáñez PR c/59304 diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 2c2006b5b6d..20294b3845a 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2047,10 +2047,8 @@ ipa_passes (void) return; } - /* We never run removal of unreachable nodes after early passes. This is - because TODO is run before the subpasses. It is important to remove - the unreachable functions to save works at IPA level and to get LTO - symbol tables right. */ + /* This extra symtab_remove_unreachable_nodes pass tends to catch some + devirtualization and other changes where removal iterate. */ symtab_remove_unreachable_nodes (true, cgraph_dump_file); /* If pass_all_early_optimizations was not scheduled, the state of @@ -2184,7 +2182,8 @@ compile (void) } /* This pass remove bodies of extern inline functions we never inlined. - Do this later so other IPA passes see what is really going on. */ + Do this later so other IPA passes see what is really going on. + FIXME: This should be run just after inlining by pasmanager. */ symtab_remove_unreachable_nodes (false, dump_file); cgraph_global_info_ready = true; if (cgraph_dump_file) @@ -2210,9 +2209,10 @@ compile (void) cgraph_materialize_all_clones (); bitmap_obstack_initialize (NULL); execute_ipa_pass_list (g->get_passes ()->all_late_ipa_passes); - symtab_remove_unreachable_nodes (true, dump_file); #ifdef ENABLE_CHECKING symtab_node::verify_symtab_nodes (); + /* Verify late IPA passes cleaned up after themselves. */ + gcc_assert (!symtab_remove_unreachable_nodes (false, dump_file)); #endif bitmap_obstack_release (NULL); mark_functions_to_output (); diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 5f1c9b04c6a..314262b873e 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -2519,7 +2519,7 @@ const pass_data pass_data_ipa_inline = 0, /* properties_required */ 0, /* properties_provided */ 0, /* properties_destroyed */ - TODO_remove_functions, /* todo_flags_start */ + 0, /* todo_flags_start */ ( TODO_dump_symtab ), /* todo_flags_finish */ }; diff --git a/gcc/ipa.c b/gcc/ipa.c index 1081e89d945..bf6b2d72e27 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -727,14 +727,17 @@ namespace { const pass_data pass_data_ipa_free_inline_summary = { SIMPLE_IPA_PASS, /* type */ - "*free_inline_summary", /* name */ + "free-inline-summary", /* name */ OPTGROUP_NONE, /* optinfo_flags */ TV_IPA_FREE_INLINE_SUMMARY, /* tv_id */ 0, /* properties_required */ 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ + /* Early optimizations may make function unreachable. We can not + remove unreachable functions as part of the ealry opts pass because + TODOs are run before subpasses. Do it here. */ + ( TODO_remove_functions | TODO_dump_symtab ), /* todo_flags_finish */ }; class pass_ipa_free_inline_summary : public simple_ipa_opt_pass diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 2e3a1563775..f41992ae29e 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2014-08-20 Jan Hubicka + + * lto.c (read_cgraph_and_symbols): Fix symtab_remove_unreachable_nodes + call. + (do_whole_program_analysis): Only sanity check that IPA passes cleans up. + 2014-08-14 Jan Hubicka * lto-symtab.c (lto_varpool_replace_node): Call compare_virtual_tables. diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index d211c8043a9..f0e32613113 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -3084,10 +3084,10 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) symtab_node::dump_table (cgraph_dump_file); } lto_symtab_merge_symbols (); - /* Removal of unreacable symbols is needed to make verify_symtab to pass; + /* Removal of unreachable symbols is needed to make verify_symtab to pass; we are still having duplicated comdat groups containing local statics. We could also just remove them while merging. */ - symtab_remove_unreachable_nodes (false, dump_file); + symtab_remove_unreachable_nodes (true, dump_file); ggc_collect (); cgraph_state = CGRAPH_STATE_IPA_SSA; @@ -3244,7 +3244,10 @@ do_whole_program_analysis (void) cgraph_state = CGRAPH_STATE_IPA_SSA; execute_ipa_pass_list (g->get_passes ()->all_regular_ipa_passes); - symtab_remove_unreachable_nodes (false, dump_file); +#ifdef ENABLE_CHECKING + /* Verify that IPA passes cleans up after themselves. */ + gcc_assert (!symtab_remove_unreachable_nodes (false, dump_file)); +#endif if (cgraph_dump_file) { diff --git a/gcc/passes.c b/gcc/passes.c index dea9de1432d..7e47992b672 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -350,7 +350,9 @@ const pass_data pass_data_early_local_passes = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - TODO_remove_functions, /* todo_flags_finish */ + /* todo_flags_finish is executed before subpases. For this reason + it makes no sense to remove unreachable functions here. */ + 0, /* todo_flags_finish */ }; class pass_early_local_passes : public simple_ipa_opt_pass @@ -2119,7 +2121,7 @@ execute_one_pass (opt_pass *pass) } } if (applied) - symtab_remove_unreachable_nodes (true, dump_file); + symtab_remove_unreachable_nodes (false, dump_file); /* Restore current_pass. */ current_pass = pass; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73390a2cd50..de08c9a04a7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-08-20 Jan Hubicka + + * testsuite/g++.dg/ipa/devirt-17.C: Update template. + * testsuite/g++.dg/ipa/devirt-16.C: Update template. + 2014-08-20 Manuel López-Ibáñez PR c/59304 diff --git a/gcc/testsuite/g++.dg/ipa/devirt-16.C b/gcc/testsuite/g++.dg/ipa/devirt-16.C index dd7696e6f55..99a1ea6ec4c 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-16.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-16.C @@ -32,7 +32,6 @@ main() return b->foo(); } -/* { dg-final { scan-ipa-dump "devirtualizing" "whole-program"} } */ /* { dg-final { scan-ipa-dump "builtin_unreachable" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */ diff --git a/gcc/testsuite/g++.dg/ipa/devirt-17.C b/gcc/testsuite/g++.dg/ipa/devirt-17.C index ce7943a8464..df10c481040 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-17.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-17.C @@ -37,7 +37,6 @@ main() return b->foo(); } -/* { dg-final { scan-ipa-dump "devirtualizing" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "builtin_unreachable" "whole-program"} } */ /* { dg-final { scan-ipa-dump "B::foo" "whole-program"} } */ /* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */