diff mbox

lto support for target attribute & fixing LTO bootstrap

Message ID 20100901163732.GA8741@basil.fritz.box
State New
Headers show

Commit Message

Andi Kleen Sept. 1, 2010, 4:37 p.m. UTC
This fixes the LTO bootstrap after the __target__ changes in libcpp
and makes LTO work with target attributes in general.

Otherwise the LTO streamer will error out.

I just stream the complete cl_target_option structure, because
writing out individual members would require messing with the awk
option scripts.

The method using the check word was suggested by Richard Guenther

Passed full LTO bootstrap and test on x86_64-linux

Ok to commit?
-Andi
    
2010-09-01  Andi Kleen	<ak@linux.intel.com>
    
    	PR45475
    	* lto-streamer-in.c (lto_input_ts_target_option): Add.
    	(lto_input_tree_pointers): Call lto_input_ts_target_option.
    	* lto-streamer-out: (lto_output_ts_target_option): Add.
    	(lto_output_tree_pointers): Call lto_output_ts_target_option.

Comments

Rainer Orth Sept. 1, 2010, 4:43 p.m. UTC | #1
Andi Kleen <andi@firstfloor.org> writes:

> 2010-09-01  Andi Kleen	<ak@linux.intel.com>
>     
>     	PR45475

        This should be PR lto/45475.

	Rainer
Diego Novillo Sept. 1, 2010, 4:45 p.m. UTC | #2
On Wed, Sep 1, 2010 at 12:37, Andi Kleen <andi@firstfloor.org> wrote:
>
> This fixes the LTO bootstrap after the __target__ changes in libcpp
> and makes LTO work with target attributes in general.
>
> Otherwise the LTO streamer will error out.
>
> I just stream the complete cl_target_option structure, because
> writing out individual members would require messing with the awk
> option scripts.
>
> The method using the check word was suggested by Richard Guenther
>
> Passed full LTO bootstrap and test on x86_64-linux
>
> Ok to commit?
> -Andi
>
> 2010-09-01  Andi Kleen  <ak@linux.intel.com>
>
>        PR45475

PR lto/45475  (I'm not sure if the svn commit pattern matcher will
catch it otherwise).


> +/* Input a TS_TARGET_OPTION tree */
> +
> +static void
> +lto_input_ts_target_option (struct lto_input_block *ib, tree expr)

End comment with '.  */'.  Add documentation for IB and EXPR.


> +/* Write a TS_TARGET_OPTION tree. Always write without reference. */
> +
> +static void
> +lto_output_ts_target_option (struct output_block *ob, tree expr)

Document OB and EXPR.

> +  bp = bitpack_create (ob->main_stream);
> +  len = sizeof (struct cl_target_option);
> +  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);

Make the 0x12345678 sentinel a #define or enum?

OK with those changes.  Thanks for fixing this.


Diego.
diff mbox

Patch

diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 9ee1510..3c82170 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -2196,6 +2196,22 @@  lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
     }
 }
 
+/* Input a TS_TARGET_OPTION tree */
+
+static void
+lto_input_ts_target_option (struct lto_input_block *ib, tree expr)
+{
+  unsigned i, len;
+  struct bitpack_d bp;
+  struct cl_target_option *t = TREE_TARGET_OPTION (expr);
+
+  bp = lto_input_bitpack (ib);
+  len = sizeof (struct cl_target_option);
+  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_target_option size mismatch in LTO reader and writer");
+}
 
 /* Helper for lto_input_tree.  Read all pointer fields in EXPR from
    input block IB.  DATA_IN contains tables and descriptors for the
@@ -2281,9 +2297,7 @@  lto_input_tree_pointers (struct lto_input_block *ib, struct data_in *data_in,
     }
 
   if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
-    {
-      sorry ("target optimization options not supported yet");
-    }
+    lto_input_ts_target_option (ib, expr);
 }
 
 
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index dde86b9..78cd47c 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -1105,6 +1105,26 @@  lto_output_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
     }
 }
 
+/* Write a TS_TARGET_OPTION tree. Always write without reference. */
+
+static void
+lto_output_ts_target_option (struct output_block *ob, tree expr)
+{
+  struct cl_target_option *t = TREE_TARGET_OPTION (expr);
+  struct bitpack_d bp;
+  unsigned i, len;
+
+  /* The cl_target_option is target specific and 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_target_option);
+  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);
+  lto_output_bitpack (&bp);
+}
 
 /* Helper for lto_output_tree.  Write all pointer fields in EXPR to output
    block OB.  If REF_P is true, the leaves of EXPR are emitted as
@@ -1187,7 +1207,7 @@  lto_output_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
     sorry ("gimple bytecode streams do not support the optimization attribute");
 
   if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
-    sorry ("gimple bytecode streams do not support the target attribute");
+    lto_output_ts_target_option (ob, expr);
 }