Patchwork Handle OPTIMIZATION_NODE in LTO

login
register
mail settings
Submitter Richard Guenther
Date Jan. 5, 2012, 3:01 p.m.
Message ID <alpine.LNX.2.00.1201051600570.4999@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/134489/
State New
Headers show

Comments

Richard Guenther - Jan. 5, 2012, 3:01 p.m.
Easy, just mimics what we do for the target attribute.

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-01-05  Richard Guenther  <rguenther@suse.de>

	PR lto/50490
	* tree-streamer-out.c (write_ts_optimization): New function.
	(streamer_write_tree_body): Call it.
	* tree-streamer-in.c (lto_input_ts_optimization): New function.
	(streamer_read_tree_body): Call it.
	* lto-streamer-out.c (lto_is_streamable): Handle OPTIMIZATION_NODE.
Steven Bosscher - Jan. 5, 2012, 6:10 p.m.
On Thu, Jan 5, 2012 at 4:01 PM, Richard Guenther <rguenther@suse.de> wrote:
> Index: gcc/tree-streamer-out.c
> ===================================================================
> --- gcc/tree-streamer-out.c     (revision 182908)
> +++ gcc/tree-streamer-out.c     (working copy)
> @@ -767,6 +767,27 @@ write_ts_target_option (struct output_bl
>   streamer_write_bitpack (&bp);
>  }
>
> +/* Write a TS_OPTIMIZATION tree in EXPR to OB.  */
> +
> +static void
> +write_ts_optimization (struct output_block *ob, tree expr)
> +{
> +  struct cl_optimization *t = TREE_OPTIMIZATION (expr);
> +  struct bitpack_d bp;
> +  unsigned i, len;
> +
> +  /* The cl_optimizaation is generated by the options

s/cl_optimizaation/cl_optimization/ ;-)

Ciao!
Steven
Richard Guenther - Jan. 9, 2012, 8:41 a.m.
On Thu, 5 Jan 2012, Steven Bosscher wrote:

> On Thu, Jan 5, 2012 at 4:01 PM, Richard Guenther <rguenther@suse.de> wrote:
> > Index: gcc/tree-streamer-out.c
> > ===================================================================
> > --- gcc/tree-streamer-out.c     (revision 182908)
> > +++ gcc/tree-streamer-out.c     (working copy)
> > @@ -767,6 +767,27 @@ write_ts_target_option (struct output_bl
> >   streamer_write_bitpack (&bp);
> >  }
> >
> > +/* Write a TS_OPTIMIZATION tree in EXPR to OB.  */
> > +
> > +static void
> > +write_ts_optimization (struct output_block *ob, tree expr)
> > +{
> > +  struct cl_optimization *t = TREE_OPTIMIZATION (expr);
> > +  struct bitpack_d bp;
> > +  unsigned i, len;
> > +
> > +  /* The cl_optimizaation is generated by the options
> 
> s/cl_optimizaation/cl_optimization/ ;-)

Fixed.

Thanks,
Richard.

Patch

Index: gcc/tree-streamer-out.c
===================================================================
--- gcc/tree-streamer-out.c	(revision 182908)
+++ gcc/tree-streamer-out.c	(working copy)
@@ -767,6 +767,27 @@  write_ts_target_option (struct output_bl
   streamer_write_bitpack (&bp);
 }
 
+/* Write a TS_OPTIMIZATION tree in EXPR to OB.  */
+
+static void
+write_ts_optimization (struct output_block *ob, tree expr)
+{
+  struct cl_optimization *t = TREE_OPTIMIZATION (expr);
+  struct bitpack_d bp;
+  unsigned i, len;
+
+  /* The cl_optimizaation is generated by the options
+     awk script, so we just recreate a byte-by-byte copy here. */
+
+  bp = bitpack_create (ob->main_stream);
+  len = sizeof (struct cl_optimization);
+  for (i = 0; i < len; i++)
+    bp_pack_value (&bp, ((unsigned char *)t)[i], 8);
+  /* Catch struct size mismatches between reader and writer. */
+  bp_pack_value (&bp, 0x12345678, 32);
+  streamer_write_bitpack (&bp);
+}
+
 /* Write a TS_TRANSLATION_UNIT_DECL tree in EXPR to OB.  */
 
 static void
@@ -841,6 +862,9 @@  streamer_write_tree_body (struct output_
   if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
     write_ts_target_option (ob, expr);
 
+  if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
+    write_ts_optimization (ob, expr);
+
   if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
     write_ts_translation_unit_decl_tree_pointers (ob, expr);
 }
Index: gcc/tree-streamer-in.c
===================================================================
--- gcc/tree-streamer-in.c	(revision 182908)
+++ gcc/tree-streamer-in.c	(working copy)
@@ -903,6 +903,23 @@  lto_input_ts_target_option (struct lto_i
     fatal_error ("cl_target_option size mismatch in LTO reader and writer");
 }
 
+/* Input a TS_OPTIMIZATION tree from IB into EXPR.  */
+
+static void
+lto_input_ts_optimization (struct lto_input_block *ib, tree expr)
+{
+  unsigned i, len;
+  struct bitpack_d bp;
+  struct cl_optimization *t = TREE_OPTIMIZATION (expr);
+
+  bp = streamer_read_bitpack (ib);
+  len = sizeof (struct cl_optimization);
+  for (i = 0; i < len; i++)
+    ((unsigned char *)t)[i] = bp_unpack_value (&bp, 8);
+  if (bp_unpack_value (&bp, 32) != 0x12345678)
+    fatal_error ("cl_optimization size mismatch in LTO reader and writer");
+}
+
 /* Input a TS_TRANSLATION_UNIT_DECL tree from IB and DATA_IN into EXPR.  */
 
 static void
@@ -979,6 +996,9 @@  streamer_read_tree_body (struct lto_inpu
   if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
     lto_input_ts_target_option (ib, expr);
 
+  if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
+    lto_input_ts_optimization (ib, expr);
+
   if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
     lto_input_ts_translation_unit_decl_tree_pointers (ib, data_in, expr);
 }
Index: gcc/lto-streamer-out.c
===================================================================
--- gcc/lto-streamer-out.c	(revision 182908)
+++ gcc/lto-streamer-out.c	(working copy)
@@ -304,7 +304,6 @@  lto_is_streamable (tree expr)
 	 && code != WITH_CLEANUP_EXPR
 	 && code != STATEMENT_LIST
 	 && code != OMP_CLAUSE
-	 && code != OPTIMIZATION_NODE
 	 && (code == CASE_LABEL_EXPR
 	     || code == DECL_EXPR
 	     || TREE_CODE_CLASS (code) != tcc_statement);