OSDN Git Service

PR plugins/53126
[pf3gnuchains/gcc-fork.git] / gcc / tree-streamer-out.c
index 093b4b3..21689df 100644 (file)
@@ -31,14 +31,15 @@ along with GCC; see the file COPYING3.  If not see
 /* Output the STRING constant to the string
    table in OB.  Then put the index onto the INDEX_STREAM.  */
 
-static void
-write_string_cst (struct output_block *ob,
-                  struct lto_output_stream *index_stream,
-                  tree string)
+void
+streamer_write_string_cst (struct output_block *ob,
+                          struct lto_output_stream *index_stream,
+                          tree string)
 {
   streamer_write_string_with_length (ob, index_stream,
-                                    TREE_STRING_POINTER (string),
-                                    TREE_STRING_LENGTH (string),
+                                    string ? TREE_STRING_POINTER (string)
+                                           : NULL,
+                                    string ? TREE_STRING_LENGTH (string) : 0,
                                     true);
 }
 
@@ -87,7 +88,8 @@ pack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
   else
     bp_pack_value (bp, 0, 1);
   /* We write debug info two times, do not confuse the second one.  */
-  bp_pack_value (bp, TYPE_P (expr) ? 0 : TREE_ASM_WRITTEN (expr), 1);
+  bp_pack_value (bp, ((TYPE_P (expr) || TREE_CODE (expr) == TYPE_DECL)
+                     ? 0 : TREE_ASM_WRITTEN (expr)), 1);
   if (TYPE_P (expr))
     bp_pack_value (bp, TYPE_ARTIFICIAL (expr), 1);
   else
@@ -99,7 +101,10 @@ pack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
   bp_pack_value (bp, TREE_PROTECTED (expr), 1);
   bp_pack_value (bp, TREE_DEPRECATED (expr), 1);
   if (TYPE_P (expr))
-    bp_pack_value (bp, TYPE_SATURATING (expr), 1);
+    {
+      bp_pack_value (bp, TYPE_SATURATING (expr), 1);
+      bp_pack_value (bp, TYPE_ADDR_SPACE (expr), 8);
+    }
   else if (TREE_CODE (expr) == SSA_NAME)
     bp_pack_value (bp, SSA_NAME_IS_DEFAULT_DEF (expr), 1);
   else
@@ -401,7 +406,15 @@ streamer_write_chain (struct output_block *ob, tree t, bool ref_p)
       saved_chain = TREE_CHAIN (t);
       TREE_CHAIN (t) = NULL_TREE;
 
-      stream_write_tree (ob, t, ref_p);
+      /* We avoid outputting external vars or functions by reference
+        to the global decls section as we do not want to have them
+        enter decl merging.  This is, of course, only for the call
+        for streaming BLOCK_VARS, but other callers are safe.  */
+      if (VAR_OR_FUNCTION_DECL_P (t)
+         && DECL_EXTERNAL (t))
+       stream_write_tree_shallow_non_ref (ob, t, ref_p);
+      else
+       stream_write_tree (ob, t, ref_p);
 
       TREE_CHAIN (t) = saved_chain;
       t = TREE_CHAIN (t);
@@ -504,6 +517,8 @@ write_ts_decl_non_common_tree_pointers (struct output_block *ob, tree expr,
       stream_write_tree (ob, DECL_ARGUMENTS (expr), ref_p);
       stream_write_tree (ob, DECL_RESULT (expr), ref_p);
     }
+  else if (TREE_CODE (expr) == TYPE_DECL)
+    stream_write_tree (ob, DECL_ORIGINAL_TYPE (expr), ref_p);
   stream_write_tree (ob, DECL_VINDEX (expr), ref_p);
 }
 
@@ -537,10 +552,9 @@ write_ts_field_decl_tree_pointers (struct output_block *ob, tree expr,
 {
   stream_write_tree (ob, DECL_FIELD_OFFSET (expr), ref_p);
   stream_write_tree (ob, DECL_BIT_FIELD_TYPE (expr), ref_p);
-  stream_write_tree (ob, DECL_QUALIFIER (expr), ref_p);
+  /* Do not stream DECL_QUALIFIER, it is useless after gimplification.  */
   stream_write_tree (ob, DECL_FIELD_BIT_OFFSET (expr), ref_p);
   stream_write_tree (ob, DECL_FCONTEXT (expr), ref_p);
-  streamer_write_chain (ob, TREE_CHAIN (expr), ref_p);
 }
 
 
@@ -596,7 +610,7 @@ write_ts_type_non_common_tree_pointers (struct output_block *ob, tree expr,
   else if (TREE_CODE (expr) == ARRAY_TYPE)
     stream_write_tree (ob, TYPE_DOMAIN (expr), ref_p);
   else if (RECORD_OR_UNION_TYPE_P (expr))
-    stream_write_tree (ob, TYPE_FIELDS (expr), ref_p);
+    streamer_write_chain (ob, TYPE_FIELDS (expr), ref_p);
   else if (TREE_CODE (expr) == FUNCTION_TYPE
           || TREE_CODE (expr) == METHOD_TYPE)
     stream_write_tree (ob, TYPE_ARG_TYPES (expr), ref_p);
@@ -753,6 +767,27 @@ write_ts_target_option (struct output_block *ob, tree expr)
   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_optimization 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
@@ -827,6 +862,9 @@ streamer_write_tree_body (struct output_block *ob, tree expr, bool ref_p)
   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);
 }
@@ -866,7 +904,7 @@ streamer_write_tree_header (struct output_block *ob, tree expr)
   /* The text in strings and identifiers are completely emitted in
      the header.  */
   if (CODE_CONTAINS_STRUCT (code, TS_STRING))
-    write_string_cst (ob, ob->main_stream, expr);
+    streamer_write_string_cst (ob, ob->main_stream, expr);
   else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
     write_identifier (ob, ob->main_stream, expr);
   else if (CODE_CONTAINS_STRUCT (code, TS_VEC))