+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
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)
else
first = curr;
- TREE_CHAIN (curr) = NULL_TREE;
prev = curr;
}
+ while (curr);
return first;
}
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);
+ }
}
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));
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
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);
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);
}
}
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));
}
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;
TREE_CHAIN (t) = saved_chain;
t = TREE_CHAIN (t);
}
+
+ /* Write a sentinel to terminate the chain. */
+ stream_write_tree (ob, NULL_TREE, 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);
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);
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);