cgraphunit.c (ipa_passes, compile): Reshedule symtab_remove_unreachable_nodes passes...
authorJan Hubicka <hubicka@ucw.cz>
Wed, 20 Aug 2014 13:55:06 +0000 (15:55 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 20 Aug 2014 13:55:06 +0000 (13:55 +0000)
* 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

gcc/ChangeLog
gcc/cgraphunit.c
gcc/ipa-inline.c
gcc/ipa.c
gcc/lto/ChangeLog
gcc/lto/lto.c
gcc/passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/devirt-16.C
gcc/testsuite/g++.dg/ipa/devirt-17.C

index 00497633a9be53d645f7049114f6df05e6a72966..2ce924fb3f0a21f50166ac29f5227dd7f44f3844 100644 (file)
@@ -1,3 +1,16 @@
+2014-08-20  Jan Hubicka  <hubicka@ucw.cz>
+
+       * 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  <manu@gcc.gnu.org>
 
        PR c/59304
index 2c2006b5b6d0d1b04f6c4c528215cdc3013009a1..20294b3845a4ad3fbdfb126e8defc9686f0e09b1 100644 (file)
@@ -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 ();
index 5f1c9b04c6a282c440e626a3ecf3d1c563680b1a..314262b873eb9eca96e4df79e4e2ee9a44d7ff1e 100644 (file)
@@ -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 */
 };
 
index 1081e89d94550f426a98ab4f1db2efee7d9cacd9..bf6b2d72e27ec759cb52b1ea414a235f2f70ba0a 100644 (file)
--- 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
index 2e3a15637754b9c072c70ff8b33379e6c4cc6691..f41992ae29e939d51e905c86689c272edeb73ce8 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-20  Jan Hubicka  <hubicka@ucw.cz>
+
+       * 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  <hubicka@ucw.cz>
 
        * lto-symtab.c (lto_varpool_replace_node): Call compare_virtual_tables.
index d211c8043a9da0f2d979605c72298fc8e3e3e703..f0e32613113586fcff91367ad566606cd81eb9b8 100644 (file)
@@ -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)
     {
index dea9de1432d7a455f00c0ec193767580763285a7..7e47992b67284bd0f856b6acfe8b6ed0b5a560da 100644 (file)
@@ -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;
     }
index 73390a2cd50ec1aa6ae788780903080dfb20fcb3..de08c9a04a7ff50517a07954635dd9534b896ba8 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-20  Jan Hubicka  <hubicka@ucw.cz>
+
+       * 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  <manu@gcc.gnu.org>
 
        PR c/59304
index dd7696e6f55ff10c4d0b2376132cf4c4cdfe47ba..99a1ea6ec4cfb39284f1d08031ac61d4cba20dc8 100644 (file)
@@ -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"} } */
index ce7943a8464b0a389b6dff3d1fe7f31034f01312..df10c481040417df61446e18a4a2b9c40d6e58fb 100644 (file)
@@ -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"} } */