This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][LTO] Move more non-tree pieces to bitfields


This moves more non-tree fields out of the tree streaming routines
into the bitfield parts.  One to go: strings.

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

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.

Index: gcc/tree-streamer-out.c
===================================================================
*** gcc/tree-streamer-out.c	(revision 192398)
--- gcc/tree-streamer-out.c	(working copy)
*************** streamer_pack_tree_bitfields (struct out
*** 409,414 ****
--- 409,420 ----
  
    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));
  }
  
  
*************** streamer_write_builtin (struct output_bl
*** 454,464 ****
  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++)
      {
        tree saved_chain;
  
--- 460,466 ----
  void
  streamer_write_chain (struct output_block *ob, tree t, bool ref_p)
  {
!   while (t)
      {
        tree saved_chain;
  
*************** streamer_write_chain (struct output_bloc
*** 480,485 ****
--- 482,490 ----
        TREE_CHAIN (t) = saved_chain;
        t = TREE_CHAIN (t);
      }
+ 
+   /* Write a sentinel to terminate the chain.  */
+   stream_write_tree (ob, NULL_TREE, ref_p);
  }
  
  
*************** write_ts_exp_tree_pointers (struct outpu
*** 725,731 ****
  {
    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);
--- 730,735 ----
*************** write_ts_binfo_tree_pointers (struct out
*** 786,792 ****
    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)));
    FOR_EACH_VEC_ELT (tree, BINFO_BASE_ACCESSES (expr), i, t)
      stream_write_tree (ob, t, ref_p);
  
--- 790,797 ----
    stream_write_tree (ob, BINFO_VTABLE (expr), ref_p);
    stream_write_tree (ob, BINFO_VPTR_FIELD (expr), ref_p);
  
!   /* 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);
  
*************** write_ts_constructor_tree_pointers (stru
*** 807,813 ****
    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);
--- 812,817 ----
Index: gcc/tree-streamer-in.c
===================================================================
*** gcc/tree-streamer-in.c	(revision 192398)
--- gcc/tree-streamer-in.c	(working copy)
*************** input_identifier (struct data_in *data_i
*** 68,79 ****
  tree
  streamer_read_chain (struct lto_input_block *ib, struct data_in *data_in)
  {
-   int i, count;
    tree first, prev, curr;
  
    first = prev = NULL_TREE;
!   count = streamer_read_hwi (ib);
!   for (i = 0; i < count; i++)
      {
        curr = stream_read_tree (ib, data_in);
        if (prev)
--- 68,78 ----
  tree
  streamer_read_chain (struct lto_input_block *ib, struct data_in *data_in)
  {
    tree first, prev, curr;
  
+   /* The chain is written as NULL terminated list of trees.  */
    first = prev = NULL_TREE;
!   do
      {
        curr = stream_read_tree (ib, data_in);
        if (prev)
*************** streamer_read_chain (struct lto_input_bl
*** 81,89 ****
        else
  	first = curr;
  
-       TREE_CHAIN (curr) = NULL_TREE;
        prev = curr;
      }
  
    return first;
  }
--- 80,88 ----
        else
  	first = curr;
  
        prev = curr;
      }
+   while (curr);
  
    return first;
  }
*************** unpack_value_fields (struct data_in *dat
*** 452,457 ****
--- 451,470 ----
  
    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);
+     }
  }
  
  
*************** static void
*** 813,824 ****
  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));
  
!   for (i = 0; i < length; i++)
      TREE_OPERAND (expr, i) = stream_read_tree (ib, data_in);
  
    TREE_SET_BLOCK (expr, stream_read_tree (ib, data_in));
--- 826,834 ----
  lto_input_ts_exp_tree_pointers (struct lto_input_block *ib,
  			        struct data_in *data_in, tree expr)
  {
!   int 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));
*************** static void
*** 878,884 ****
  lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
  				  struct data_in *data_in, tree expr)
  {
!   unsigned i, len;
    tree t;
  
    /* Note that the number of slots in EXPR was read in
--- 888,894 ----
  lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
  				  struct data_in *data_in, tree expr)
  {
!   unsigned i;
    tree t;
  
    /* Note that the number of slots in EXPR was read in
*************** lto_input_ts_binfo_tree_pointers (struct
*** 898,912 ****
    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)
      {
!       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);
! 	}
      }
  
    BINFO_INHERITANCE_CHAIN (expr) = stream_read_tree (ib, data_in);
--- 908,919 ----
    BINFO_VTABLE (expr) = stream_read_tree (ib, data_in);
    BINFO_VPTR_FIELD (expr) = stream_read_tree (ib, data_in);
  
!   /* 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++)
      {
!       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);
*************** static void
*** 923,938 ****
  lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
  				        struct data_in *data_in, tree expr)
  {
!   unsigned i, len;
  
!   len = streamer_read_uhwi (ib);
!   for (i = 0; i < len; 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);
      }
  }
  
--- 930,943 ----
  lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
  				        struct data_in *data_in, tree expr)
  {
!   unsigned i;
  
!   for (i = 0; i < CONSTRUCTOR_NELTS (expr); i++)
      {
!       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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]