This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto][patch] Split all_lto_ipa_passes out of all_regular_ipa_passes


To run the inliner in lgen, we must split the lto passes out of the
regular passes so that we can run only the former. The attached patch
does that.

2008-11-06  Rafael Espindola  <espindola@google.com>

	* cgraphunit.c (ipa_passes): Don't use execute_regular_ipa_pass_list.
	* ipa-pure-const.c (write_summary): Assert that fs is not NULL.
	* passes.c (all_lto_ipa_passes): New.
	(init_optimization_passes): Initialize all_lto_ipa_passes.
	(execute_ipa_summary_passes): Make non-static.
	(ipa_write_summaries_1): Update to use ipa_write_summaries_2. Remove PASS
	argument. Update all uses.
	(ipa_write_summaries_2): New.
	(execute_regular_ipa_pass_list): Remove.
	* tree-pass.h (all_lto_ipa_passes): New.
	(execute_regular_ipa_pass_list): Remove.
	(execute_ipa_summary_passes): New.

Cheers,
-- 
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 1669a6c..bab2cfc 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1248,7 +1248,14 @@ ipa_passes (void)
   gimple_register_cfg_hooks ();
   bitmap_obstack_initialize (NULL);
   execute_ipa_pass_list (all_small_ipa_passes);
-  execute_regular_ipa_pass_list (all_regular_ipa_passes);
+
+  execute_ipa_summary_passes ((struct ipa_opt_pass *) all_regular_ipa_passes);
+  execute_ipa_summary_passes ((struct ipa_opt_pass *) all_lto_ipa_passes);
+
+  ipa_write_summaries ();
+
+  execute_ipa_pass_list (all_regular_ipa_passes);
+
   bitmap_obstack_release (NULL);
 }
 
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 0a2ac65..a2f8c8f 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -764,7 +764,8 @@ write_summary (cgraph_node_set set)
 	{
 	  unsigned HOST_WIDEST_INT flags = 0;
 	  funct_state fs = get_function_state (node);
-	
+	  gcc_assert (fs);
+
 	  lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
 				    node->decl);
 	
diff --git a/gcc/passes.c b/gcc/passes.c
index b399fd3..f66cce9 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -334,7 +334,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_regular_ipa_passes, *all_lto_ipa_passes;
 
 /* A map from static pass id to optimization pass.  */
 struct opt_pass **passes_by_id;
@@ -577,16 +577,19 @@ init_optimization_passes (void)
 
   p = &all_regular_ipa_passes;
   NEXT_PASS (pass_ipa_cp);
-  NEXT_PASS (pass_ipa_lto_gimple_out);
-  NEXT_PASS (pass_ipa_lto_cgraph);
   NEXT_PASS (pass_ipa_inline);
   NEXT_PASS (pass_ipa_pure_const); 
   NEXT_PASS (pass_ipa_reference);
   NEXT_PASS (pass_ipa_type_escape);
   NEXT_PASS (pass_ipa_pta);
   NEXT_PASS (pass_ipa_struct_reorg);
+  *p = NULL;
+
+  p = &all_lto_ipa_passes;
+  NEXT_PASS (pass_ipa_lto_gimple_out);
+  NEXT_PASS (pass_ipa_lto_cgraph);
   NEXT_PASS (pass_ipa_lto_wpa_fixup);
-  NEXT_PASS (pass_ipa_lto_finish_out);  /* This must be the last IPA_PASS.  */
+  NEXT_PASS (pass_ipa_lto_finish_out);
   *p = NULL;
 
   /* These passes are run after IPA passes on every function that is being
@@ -839,6 +842,9 @@ init_optimization_passes (void)
   register_dump_files (all_regular_ipa_passes, 
 		       PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
 		       | PROP_cfg);
+  register_dump_files (all_lto_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);
@@ -1171,7 +1177,7 @@ add_ipa_transform_pass (void *data)
 
 /* Execute summary generation for all of the passes in IPA_PASS.  */
 
-static void
+void
 execute_ipa_summary_passes (struct ipa_opt_pass *ipa_pass)
 {
   while (ipa_pass)
@@ -1363,11 +1369,9 @@ execute_pass_list (struct opt_pass *pass)
    those node in SET. */
 
 static void
-ipa_write_summaries_1 (struct opt_pass *pass, cgraph_node_set set)
+ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set,
+		       struct lto_out_decl_state *state)
 {
-  struct lto_out_decl_state *state = lto_new_out_decl_state ();
-
-  lto_push_out_decl_state (state);
   do
     {
       struct ipa_opt_pass *ipa_pass = (struct ipa_opt_pass *)pass;
@@ -1379,10 +1383,24 @@ ipa_write_summaries_1 (struct opt_pass *pass, cgraph_node_set set)
 	  && (!pass->gate || pass->gate ()))
 	ipa_pass->write_summary (set);
       if (pass->sub && pass->sub->type != GIMPLE_PASS)
-	ipa_write_summaries_1 (pass->sub, set);
+	ipa_write_summaries_2 (pass->sub, set, state);
       pass = pass->next;
     }
   while (pass);
+}
+
+/* Helper function of ipa_write_summaries. Creates and destroys the decl state
+   and calls ipa_write_summaries_2 for all passes that have summaries. SET is
+   the set of nodes to be written. */
+
+static void
+ipa_write_summaries_1 (cgraph_node_set set)
+{
+  struct lto_out_decl_state *state = lto_new_out_decl_state ();
+  lto_push_out_decl_state (state);
+
+  ipa_write_summaries_2 (all_regular_ipa_passes, set, state);
+  ipa_write_summaries_2 (all_lto_ipa_passes, set, state);
 
   gcc_assert (lto_get_out_decl_state () == state);
   lto_pop_out_decl_state ();
@@ -1404,7 +1422,7 @@ ipa_write_summaries (void)
       set = cgraph_node_set_new ();
       for (node = cgraph_nodes; node; node = node->next)
 	cgraph_node_set_add (set, node);
-      ipa_write_summaries_1 (all_regular_ipa_passes, set);
+      ipa_write_summaries_1 (set);
       lto_delete_static_inline_states ();
       ggc_free (set);
     }
@@ -1414,7 +1432,7 @@ void
 ipa_write_summaries_of_cgraph_node_set (cgraph_node_set set)
 {
   if (flag_generate_lto && !(errorcount || sorrycount))
-    ipa_write_summaries_1 (all_regular_ipa_passes, set);
+    ipa_write_summaries_1 (set);
 }
 
 /* Same as execute_pass_list but assume that subpasses of IPA passes
@@ -1445,6 +1463,7 @@ void
 ipa_read_summaries (void)
 {
   ipa_read_summaries_1 (all_regular_ipa_passes);
+  ipa_read_summaries_1 (all_lto_ipa_passes);
 }
 
 /* Same as execute_pass_list but assume that subpasses of IPA passes
@@ -1475,19 +1494,6 @@ execute_ipa_pass_list (struct opt_pass *pass)
   while (pass);
 }
 
-/* Same as execute_pass_list but assume that subpasses of IPA passes
-   are local passes.  */
-void
-execute_regular_ipa_pass_list (struct opt_pass *pass)
-{
-  if (!quiet_flag && !cfun)
-    fprintf (stderr, " <summary generate>");
-  execute_ipa_summary_passes ((struct ipa_opt_pass *) pass);
-  ipa_write_summaries ();
-
-  execute_ipa_pass_list (pass);
-}
-
 extern void debug_properties (unsigned int);
 extern void dump_properties (FILE *, unsigned int);
 
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index d49708b..1263669 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -523,7 +523,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_regular_ipa_passes, *all_lto_ipa_passes;
 
 /* Current optimization pass.  */
 extern struct opt_pass *current_pass;
@@ -531,7 +531,7 @@ extern struct opt_pass *current_pass;
 extern struct opt_pass * get_pass_for_id (int);
 extern void execute_pass_list (struct opt_pass *);
 extern void execute_ipa_pass_list (struct opt_pass *);
-extern void execute_regular_ipa_pass_list (struct opt_pass *);
+extern void execute_ipa_summary_passes (struct ipa_opt_pass *);
 extern void execute_all_ipa_transforms (void);
 
 extern void print_current_pass (FILE *);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]