]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-streamer-out.c (streamer_pack_tree_bitfields): Back BINFO_BASE_ACCESSES and...
authorRichard Guenther <rguenther@suse.de>
Mon, 15 Oct 2012 10:39:59 +0000 (10:39 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 15 Oct 2012 10:39:59 +0000 (10:39 +0000)
2012-10-15  Richard Guenther  <rguenther@suse.de>

* tree-streamer-out.c (streamer_pack_tree_bitfields): Back
BINFO_BASE_ACCESSES and CONSTRUCTOR lengths here.
(streamer_write_chain): Write TREE_CHAIN as null-terminated list.
(write_ts_exp_tree_pointers): Adjust.
(write_ts_binfo_tree_pointers): Likewise.
(write_ts_constructor_tree_pointers): Likewise.
* tree-streamer-in.c (streamer_read_chain): Read TREE_CHAIN as
null-terminated list.
(unpack_value_fields): Unpack BINFO_BASE_ACCESSES and
CONSTRUCTOR lengths and materialize the arrays.
(lto_input_ts_exp_tree_pointers): Adjust.
(lto_input_ts_binfo_tree_pointers): Likewise.
(lto_input_ts_constructor_tree_pointers): Likewise.

From-SVN: r192451

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

index 82427de24ac31892a2471e08e425159afe5f878b..85db69e09f263dbff9ac00dcc7d685daf041f4c5 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-15  Richard Guenther  <rguenther@suse.de>
+
+       * tree-streamer-out.c (streamer_pack_tree_bitfields): Back
+       BINFO_BASE_ACCESSES and CONSTRUCTOR lengths here.
+       (streamer_write_chain): Write TREE_CHAIN as null-terminated list.
+       (write_ts_exp_tree_pointers): Adjust.
+       (write_ts_binfo_tree_pointers): Likewise.
+       (write_ts_constructor_tree_pointers): Likewise.
+       * tree-streamer-in.c (streamer_read_chain): Read TREE_CHAIN as
+       null-terminated list.
+       (unpack_value_fields): Unpack BINFO_BASE_ACCESSES and
+       CONSTRUCTOR lengths and materialize the arrays.
+       (lto_input_ts_exp_tree_pointers): Adjust.
+       (lto_input_ts_binfo_tree_pointers): Likewise.
+       (lto_input_ts_constructor_tree_pointers): Likewise.
+
 2012-10-14  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * config/mmix/mmix.c (mmix_opposite_regno): Handle the
index f77a66933f230df57089d0715dc2f8c8af14c87c..856fd6bf665d0b71c7c2b3663a232a7757bc4ca4 100644 (file)
@@ -68,12 +68,11 @@ input_identifier (struct data_in *data_in, struct lto_input_block *ib)
 tree
 streamer_read_chain (struct lto_input_block *ib, struct data_in *data_in)
 {
-  int i, count;
   tree first, prev, curr;
 
+  /* The chain is written as NULL terminated list of trees.  */
   first = prev = NULL_TREE;
-  count = streamer_read_hwi (ib);
-  for (i = 0; i < count; i++)
+  do
     {
       curr = stream_read_tree (ib, data_in);
       if (prev)
@@ -81,9 +80,9 @@ streamer_read_chain (struct lto_input_block *ib, struct data_in *data_in)
       else
        first = curr;
 
-      TREE_CHAIN (curr) = NULL_TREE;
       prev = curr;
     }
+  while (curr);
 
   return first;
 }
@@ -452,6 +451,20 @@ unpack_value_fields (struct data_in *data_in, struct bitpack_d *bp, tree expr)
 
   if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
     unpack_ts_optimization (bp, expr);
+
+  if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
+    {
+      unsigned HOST_WIDE_INT length = bp_unpack_var_len_unsigned (bp);
+      if (length > 0)
+       VEC_safe_grow (tree, gc, BINFO_BASE_ACCESSES (expr), length);
+    }
+
+  if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
+    {
+      unsigned HOST_WIDE_INT length = bp_unpack_var_len_unsigned (bp);
+      if (length > 0)
+       VEC_safe_grow (constructor_elt, gc, CONSTRUCTOR_ELTS (expr), length);
+    }
 }
 
 
@@ -813,12 +826,9 @@ static void
 lto_input_ts_exp_tree_pointers (struct lto_input_block *ib,
                                struct data_in *data_in, tree expr)
 {
-  int i, length;
-
-  length = streamer_read_hwi (ib);
-  gcc_assert (length == TREE_OPERAND_LENGTH (expr));
+  int i;
 
-  for (i = 0; i < length; i++)
+  for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
     TREE_OPERAND (expr, i) = stream_read_tree (ib, data_in);
 
   TREE_SET_BLOCK (expr, stream_read_tree (ib, data_in));
@@ -878,7 +888,7 @@ static void
 lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
                                  struct data_in *data_in, tree expr)
 {
-  unsigned i, len;
+  unsigned i;
   tree t;
 
   /* Note that the number of slots in EXPR was read in
@@ -898,15 +908,12 @@ lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
   BINFO_VTABLE (expr) = stream_read_tree (ib, data_in);
   BINFO_VPTR_FIELD (expr) = stream_read_tree (ib, data_in);
 
-  len = streamer_read_uhwi (ib);
-  if (len > 0)
+  /* The vector of BINFO_BASE_ACCESSES is pre-allocated during
+     unpacking the bitfield section.  */
+  for (i = 0; i < VEC_length (tree, BINFO_BASE_ACCESSES (expr)); i++)
     {
-      VEC_reserve_exact (tree, gc, BINFO_BASE_ACCESSES (expr), len);
-      for (i = 0; i < len; i++)
-       {
-         tree a = stream_read_tree (ib, data_in);
-         VEC_quick_push (tree, BINFO_BASE_ACCESSES (expr), a);
-       }
+      tree a = stream_read_tree (ib, data_in);
+      VEC_replace (tree, BINFO_BASE_ACCESSES (expr), i, a);
     }
 
   BINFO_INHERITANCE_CHAIN (expr) = stream_read_tree (ib, data_in);
@@ -923,16 +930,14 @@ static void
 lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
                                        struct data_in *data_in, tree expr)
 {
-  unsigned i, len;
+  unsigned i;
 
-  len = streamer_read_uhwi (ib);
-  for (i = 0; i < len; i++)
+  for (i = 0; i < CONSTRUCTOR_NELTS (expr); i++)
     {
-      tree index, value;
-
-      index = stream_read_tree (ib, data_in);
-      value = stream_read_tree (ib, data_in);
-      CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (expr), index, value);
+      constructor_elt e;
+      e.index = stream_read_tree (ib, data_in);
+      e.value = stream_read_tree (ib, data_in);
+      VEC_replace (constructor_elt, CONSTRUCTOR_ELTS (expr), i, e);
     }
 }
 
index fc70eb9f856b7006b37c727051d7fb2ff2fe3628..cb2ccf47a46b34a5417cd4141ec68c41d5d53d55 100644 (file)
@@ -409,6 +409,12 @@ streamer_pack_tree_bitfields (struct output_block *ob,
 
   if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
     pack_ts_optimization (bp, expr);
+
+  if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
+    bp_pack_var_len_unsigned (bp, VEC_length (tree, BINFO_BASE_ACCESSES (expr)));
+
+  if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
+    bp_pack_var_len_unsigned (bp, CONSTRUCTOR_NELTS (expr));
 }
 
 
@@ -454,11 +460,7 @@ streamer_write_builtin (struct output_block *ob, tree expr)
 void
 streamer_write_chain (struct output_block *ob, tree t, bool ref_p)
 {
-  int i, count;
-
-  count = list_length (t);
-  streamer_write_hwi (ob, count);
-  for (i = 0; i < count; i++)
+  while (t)
     {
       tree saved_chain;
 
@@ -480,6 +482,9 @@ streamer_write_chain (struct output_block *ob, tree t, bool ref_p)
       TREE_CHAIN (t) = saved_chain;
       t = TREE_CHAIN (t);
     }
+
+  /* Write a sentinel to terminate the chain.  */
+  stream_write_tree (ob, NULL_TREE, ref_p);
 }
 
 
@@ -725,7 +730,6 @@ write_ts_exp_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
 {
   int i;
 
-  streamer_write_hwi (ob, TREE_OPERAND_LENGTH (expr));
   for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
     stream_write_tree (ob, TREE_OPERAND (expr, i), ref_p);
   stream_write_tree (ob, TREE_BLOCK (expr), ref_p);
@@ -786,7 +790,8 @@ write_ts_binfo_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
   stream_write_tree (ob, BINFO_VTABLE (expr), ref_p);
   stream_write_tree (ob, BINFO_VPTR_FIELD (expr), ref_p);
 
-  streamer_write_uhwi (ob, VEC_length (tree, BINFO_BASE_ACCESSES (expr)));
+  /* The number of BINFO_BASE_ACCESSES has already been emitted in
+     EXPR's bitfield section.  */
   FOR_EACH_VEC_ELT (tree, BINFO_BASE_ACCESSES (expr), i, t)
     stream_write_tree (ob, t, ref_p);
 
@@ -807,7 +812,6 @@ write_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
   unsigned i;
   tree index, value;
 
-  streamer_write_uhwi (ob, CONSTRUCTOR_NELTS (expr));
   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value)
     {
       stream_write_tree (ob, index, ref_p);