Patchwork Stream cgraph_node.ipa_transforms_to_apply

login
register
mail settings
Submitter Martin Jambor
Date Nov. 4, 2012, 10:43 p.m.
Message ID <20121104224353.GD5617@virgil.arch.suse.de>
Download mbox | patch
Permalink /patch/197113/
State New
Headers show

Comments

Martin Jambor - Nov. 4, 2012, 10:43 p.m.
Hi,

the following patch adds streaming ofcgraph_node.ipa_transforms_to_apply
so that transformation phases of IPA passes are run in LTO too.  It is
done by simple streaming of pass.static_pass_number and then looking
it up among all_regular_ipa_passes.

Bootstrapped and tested on x86_64-linux, required to make aggregate
IPA-CP work in LTO.

OK for trunk?

Thanks,

Martin


2012-11-03  Martin Jambor  <mjambor@suse.cz>

	* lto-cgraph.c: Include tree-pass.h.
	(lto_output_node): Stream node->ipa_transforms_to_apply.
	(input_node): Likewise.
	* Makefile.in (lto-cgraph.o): Add TREE_PASS_H to dependencies.
Jan Hubicka - Nov. 5, 2012, 11:15 a.m.
> Hi,
> 
> the following patch adds streaming ofcgraph_node.ipa_transforms_to_apply
> so that transformation phases of IPA passes are run in LTO too.  It is
> done by simple streaming of pass.static_pass_number and then looking
> it up among all_regular_ipa_passes.
> 
> Bootstrapped and tested on x86_64-linux, required to make aggregate
> IPA-CP work in LTO.
> 
> OK for trunk?
> 
> Thanks,
> 
> Martin
> 
> 
> 2012-11-03  Martin Jambor  <mjambor@suse.cz>
> 
> 	* lto-cgraph.c: Include tree-pass.h.
> 	(lto_output_node): Stream node->ipa_transforms_to_apply.
> 	(input_node): Likewise.
> 	* Makefile.in (lto-cgraph.o): Add TREE_PASS_H to dependencies.
> +  count = streamer_read_hwi (ib);
> +  node->ipa_transforms_to_apply = NULL;
> +  for (i = 0; i < count; i++)
> +    {
> +      struct opt_pass *pass;
> +      int pi = streamer_read_hwi (ib);
> +
> +      for (pass = all_regular_ipa_passes; pass; pass = pass->next)
> +	if (pass->static_pass_number == pi)

passes.c compute vector translating IDs to pass structures, please export it and use it here;
OK with this change.

Honza
> +	  {
> +	    VEC_safe_push (ipa_opt_pass, heap, node->ipa_transforms_to_apply,
> +			   (struct ipa_opt_pass_d *) pass);
> +	    break;
> +	  }
> +      gcc_assert (pass);
> +    }
> +
>    if (tag == LTO_symtab_analyzed_node)
>      ref = streamer_read_hwi (ib);
>  
> Index: src/gcc/Makefile.in
> ===================================================================
> --- src.orig/gcc/Makefile.in
> +++ src/gcc/Makefile.in
> @@ -2146,7 +2146,7 @@ lto-cgraph.o: lto-cgraph.c $(CONFIG_H) $
>     $(HASHTAB_H) langhooks.h $(BASIC_BLOCK_H) \
>     $(TREE_FLOW_H) $(CGRAPH_H) $(FUNCTION_H) $(GGC_H) $(DIAGNOSTIC_CORE_H) \
>     $(EXCEPT_H) $(TIMEVAR_H) pointer-set.h $(LTO_STREAMER_H) \
> -   $(GCOV_IO_H) $(DATA_STREAMER_H) $(TREE_STREAMER_H)
> +   $(GCOV_IO_H) $(DATA_STREAMER_H) $(TREE_STREAMER_H) $(TREE_PASS_H)
>  lto-streamer-in.o: lto-streamer-in.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
>     $(TM_H) toplev.h $(DIAGNOSTIC_CORE_H) $(EXPR_H) $(FLAGS_H) $(PARAMS_H) \
>     input.h $(HASHTAB_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) $(TREE_PASS_H) \

Patch

Index: src/gcc/lto-cgraph.c
===================================================================
--- src.orig/gcc/lto-cgraph.c
+++ src/gcc/lto-cgraph.c
@@ -45,6 +45,7 @@  along with GCC; see the file COPYING3.
 #include "data-streamer.h"
 #include "tree-streamer.h"
 #include "gcov-io.h"
+#include "tree-pass.h"
 
 static void output_cgraph_opt_summary (void);
 static void input_cgraph_opt_summary (VEC (symtab_node, heap) * nodes);
@@ -377,6 +378,8 @@  lto_output_node (struct lto_simple_outpu
   intptr_t ref;
   bool in_other_partition = false;
   struct cgraph_node *clone_of;
+  struct ipa_opt_pass_d *pass;
+  int i;
 
   boundary_p = !lto_symtab_encoder_in_partition_p (encoder, (symtab_node)node);
 
@@ -432,6 +435,12 @@  lto_output_node (struct lto_simple_outpu
   streamer_write_hwi_stream (ob->main_stream, node->count);
   streamer_write_hwi_stream (ob->main_stream, node->count_materialization_scale);
 
+  streamer_write_hwi_stream (ob->main_stream,
+			     VEC_length (ipa_opt_pass,
+					 node->ipa_transforms_to_apply));
+  FOR_EACH_VEC_ELT (ipa_opt_pass, node->ipa_transforms_to_apply, i, pass)
+    streamer_write_hwi_stream (ob->main_stream, pass->pass.static_pass_number);
+
   if (tag == LTO_symtab_analyzed_node)
     {
       if (node->global.inlined_to)
@@ -898,6 +907,7 @@  input_node (struct lto_file_decl_data *f
   int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND;
   int clone_ref;
   int order;
+  int i, count;
 
   order = streamer_read_hwi (ib) + order_base;
   clone_ref = streamer_read_hwi (ib);
@@ -920,6 +930,23 @@  input_node (struct lto_file_decl_data *f
   node->count = streamer_read_hwi (ib);
   node->count_materialization_scale = streamer_read_hwi (ib);
 
+  count = streamer_read_hwi (ib);
+  node->ipa_transforms_to_apply = NULL;
+  for (i = 0; i < count; i++)
+    {
+      struct opt_pass *pass;
+      int pi = streamer_read_hwi (ib);
+
+      for (pass = all_regular_ipa_passes; pass; pass = pass->next)
+	if (pass->static_pass_number == pi)
+	  {
+	    VEC_safe_push (ipa_opt_pass, heap, node->ipa_transforms_to_apply,
+			   (struct ipa_opt_pass_d *) pass);
+	    break;
+	  }
+      gcc_assert (pass);
+    }
+
   if (tag == LTO_symtab_analyzed_node)
     ref = streamer_read_hwi (ib);
 
Index: src/gcc/Makefile.in
===================================================================
--- src.orig/gcc/Makefile.in
+++ src/gcc/Makefile.in
@@ -2146,7 +2146,7 @@  lto-cgraph.o: lto-cgraph.c $(CONFIG_H) $
    $(HASHTAB_H) langhooks.h $(BASIC_BLOCK_H) \
    $(TREE_FLOW_H) $(CGRAPH_H) $(FUNCTION_H) $(GGC_H) $(DIAGNOSTIC_CORE_H) \
    $(EXCEPT_H) $(TIMEVAR_H) pointer-set.h $(LTO_STREAMER_H) \
-   $(GCOV_IO_H) $(DATA_STREAMER_H) $(TREE_STREAMER_H)
+   $(GCOV_IO_H) $(DATA_STREAMER_H) $(TREE_STREAMER_H) $(TREE_PASS_H)
 lto-streamer-in.o: lto-streamer-in.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) toplev.h $(DIAGNOSTIC_CORE_H) $(EXPR_H) $(FLAGS_H) $(PARAMS_H) \
    input.h $(HASHTAB_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) $(TREE_PASS_H) \