re PR target/45475 (target attribute use in libcpp breaks LTO bootstrap)
authorAndi Kleen <ak@linux.intel.com>
Wed, 1 Sep 2010 17:03:56 +0000 (17:03 +0000)
committerAndi Kleen <ak@gcc.gnu.org>
Wed, 1 Sep 2010 17:03:56 +0000 (17:03 +0000)
2010-09-01  Andi Kleen  <ak@linux.intel.com>

        PR lto/45475
        * 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.

From-SVN: r163740

gcc/ChangeLog
gcc/lto-streamer-in.c
gcc/lto-streamer-out.c

index 4e79cd850a70210f44fd1fec68631a93aae89f04..d55b8b650c59ca68d74b532c6f5caa047d4507ce 100644 (file)
@@ -1,3 +1,11 @@
+2010-09-01  Andi Kleen <ak@linux.intel.com>
+
+       PR lto/45475
+       * 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.
+
 2010-09-01  Kai Tietz  <kai.tietz@onevision.com>
 
        PR/target 45452
index 9ee15108fae477033a5170a9012b3c1184c5d103..14d87ed20fd85ff4651e552349309dbb76635b78 100644 (file)
@@ -2197,6 +2197,23 @@ lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
 }
 
 
+/* Input a TS_TARGET_OPTION tree from IB into EXPR.  */
+
+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
    file being read.  */
@@ -2281,9 +2298,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);
 }
 
 
index dde86b94595f91d85a0f5625064e6e919b05884c..80d818c6d1c70a42aeb96da4a77c34196ed5aada 100644 (file)
@@ -1105,6 +1105,26 @@ lto_output_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
     }
 }
 
+/* Write a TS_TARGET_OPTION tree in EXPR to OB.  */
+
+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);
 }