re PR middle-end/49373 (Many testcase failures)
authorJan Hubicka <jh@suse.cz>
Thu, 23 Jun 2011 16:45:08 +0000 (18:45 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 23 Jun 2011 16:45:08 +0000 (16:45 +0000)
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

gcc/ChangeLog
gcc/cgraphunit.c
gcc/ipa-inline.c
gcc/passes.c
gcc/tree-pass.h

index b298d5fbd785a2bdab3364045b9a7078f69eb0c4..1d1dbd1d9581a3cc62423aea26232de15f7739cf 100644 (file)
@@ -1,3 +1,18 @@
+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>
 
        * params.c: Include common/common-target.h.  Don't include tm.h.
index eefd37226f9b85d452f1491910d69430f24fa669..e470d85acc61eec02f3846c4cfbb9f736b4b57df 100644 (file)
@@ -1420,7 +1420,7 @@ init_lowered_empty_function (tree decl)
   DECL_SAVED_TREE (decl) = error_mark_node;
   cfun->curr_properties |=
     (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.  */
   bb = create_basic_block (NULL, (void *) 0, ENTRY_BLOCK_PTR);
@@ -2102,6 +2102,13 @@ cgraph_optimize (void)
 #endif
 
   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_state = CGRAPH_STATE_EXPANSION;
index 90053e4ceceda8c8a3aec7b9dbae5a3ab959688f..2f57e2d9f14f32c79275e39faa3524bd72202753 100644 (file)
@@ -1972,17 +1972,15 @@ struct gimple_opt_pass pass_early_inline =
 
 
 /* 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
 gate_ipa_inline (void)
 {
-  /* ???  We'd like to skip this if not optimizing or not inlining as
-     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;
+  return optimize || flag_lto || flag_wpa;
 }
 
 struct ipa_opt_pass_d pass_ipa_inline =
index fb9de2b077e8c38e52f3f321d3ac10ea069074b1..a03aa3f48c0120e7890a822186a070703f84c30b 100644 (file)
@@ -332,7 +332,7 @@ struct rtl_opt_pass pass_postreload =
 
 /* The root of the compilation pass tree, once constructed.  */
 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.  */
 #define DEF_PASS_LIST(LIST) &LIST,
@@ -617,6 +617,7 @@ dump_passes (void)
   dump_pass_list (all_small_ipa_passes, 1);
   dump_pass_list (all_regular_ipa_passes, 1);
   dump_pass_list (all_lto_gen_passes, 1);
+  dump_pass_list (all_late_ipa_passes, 1);
   dump_pass_list (all_passes, 1);
 
   pop_cfun ();
@@ -1102,6 +1103,8 @@ register_pass (struct register_pass_info *pass_info)
     success |= position_pass (pass_info, &all_regular_ipa_passes);
   if (!success || all_instances)
     success |= position_pass (pass_info, &all_lto_gen_passes);
+  if (!success || all_instances)
+    success |= position_pass (pass_info, &all_late_ipa_passes);
   if (!success || all_instances)
     success |= position_pass (pass_info, &all_passes);
   if (!success)
@@ -1249,7 +1252,6 @@ init_optimization_passes (void)
   NEXT_PASS (pass_ipa_inline);
   NEXT_PASS (pass_ipa_pure_const);
   NEXT_PASS (pass_ipa_reference);
-  NEXT_PASS (pass_ipa_pta);
   *p = NULL;
 
   p = &all_lto_gen_passes;
@@ -1257,9 +1259,16 @@ init_optimization_passes (void)
   NEXT_PASS (pass_ipa_lto_finish_out);  /* This must be the last LTO pass.  */
   *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
      output to the assembler file.  */
   p = &all_passes;
+  NEXT_PASS (pass_fixup_cfg);
   NEXT_PASS (pass_lower_eh_dispatch);
   NEXT_PASS (pass_all_optimizations);
     {
@@ -1517,6 +1526,9 @@ init_optimization_passes (void)
   register_dump_files (all_lto_gen_passes,
                       PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
                       | 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,
                       PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
                       | PROP_cfg);
@@ -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
    the gate status.  FUNC is the function to be processed, and
    GATE_STATUS is the gate status determined by pass manager by
@@ -1996,6 +2022,16 @@ execute_one_pass (struct opt_pass *pass)
      executed.  */
   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)
     fprintf (stderr, " <%s>", pass->name ? pass->name : "");
 
index f3a03b07127afd20a34f216cb7059070236cb3d8..a17ef3581423620fc552207f1845ee8debf72236 100644 (file)
@@ -577,7 +577,7 @@ extern struct gimple_opt_pass pass_convert_switch;
 
 /* The root of the compilation pass tree, once constructed.  */
 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
    find all the pass lists.  */