[pph] Pickle some more language-dependent fields (issue4389050)

2011-04-12 Thread Diego Novillo

In reconstructing pph images, I found some more language-specific
fields that we were not pickling.  There's a few more that I will be
sending shortly.

Tested on x86_64.  Committed to pph.


2011-04-12  Diego Novillo  dnovi...@google.com

* pph-streamer-in.c (pph_stream_unpack_value_fields): Unpack
TYPE_LANG_FLAGS and DECL_LANG_FLAGS.
(pph_stream_read_tree): Handle TYPE_DECL.
* pph-streamer-out.c (pph_stream_pack_value_fields): Pack
TYPE_LANG_FLAGS and DECL_LANG_FLAGS.
(pph_stream_write_binding_level): Call pph_output_chain_filtered
with a NO_BUILTINS filter for fields that have DECLs in them.
(pph_stream_write_tree): Handle TYPE_DECL.
(pph_output_chain_filtered): New.
* pph-streamer.c (pph_stream_trace): Show the code of the tree
if it is not NULL_TREE.
* pph-streamer.h (enum chain_filter): Declare.
(pph_output_chain_filtered): Declare.

diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index af7cd57..38a4561 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -36,10 +36,30 @@ along with GCC; see the file COPYING3.  If not see
we are unpacking from.  EXPR is the tree to unpack.  */
 
 void
-pph_stream_unpack_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED,
-   tree expr ATTRIBUTE_UNUSED)
+pph_stream_unpack_value_fields (struct bitpack_d *bp, tree expr)
 {
-  /* Do nothing for now.  */
+  if (TYPE_P (expr))
+{
+  TYPE_LANG_FLAG_0 (expr) = bp_unpack_value (bp, 1);
+  TYPE_LANG_FLAG_1 (expr) = bp_unpack_value (bp, 1);
+  TYPE_LANG_FLAG_2 (expr) = bp_unpack_value (bp, 1);
+  TYPE_LANG_FLAG_3 (expr) = bp_unpack_value (bp, 1);
+  TYPE_LANG_FLAG_4 (expr) = bp_unpack_value (bp, 1);
+  TYPE_LANG_FLAG_5 (expr) = bp_unpack_value (bp, 1);
+  TYPE_LANG_FLAG_6 (expr) = bp_unpack_value (bp, 1);
+}
+  else if (DECL_P (expr))
+{
+  DECL_LANG_FLAG_0 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_1 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_2 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_3 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_4 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_5 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_6 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_7 (expr) = bp_unpack_value (bp, 1);
+  DECL_LANG_FLAG_8 (expr) = bp_unpack_value (bp, 1);
+}
 }
 
 
@@ -585,6 +605,8 @@ pph_stream_read_tree (struct lto_input_block *ib 
ATTRIBUTE_UNUSED,
  if (TREE_CODE (expr) == FUNCTION_DECL)
DECL_SAVED_TREE (expr) = pph_input_tree (stream);
}
+  else if (TREE_CODE (expr) == TYPE_DECL)
+   DECL_ORIGINAL_TYPE (expr) = pph_input_tree (stream);
 }
   else if (TREE_CODE (expr) == STATEMENT_LIST)
 {
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index aeba8eb..609673b 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -42,10 +42,30 @@ static FILE *current_pph_file = NULL;
we are packing into.  EXPR is the tree to pack.  */
 
 void
-pph_stream_pack_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED,
- tree expr ATTRIBUTE_UNUSED)
+pph_stream_pack_value_fields (struct bitpack_d *bp, tree expr)
 {
-  /* Do nothing for now.  */
+  if (TYPE_P (expr))
+{
+  bp_pack_value (bp, TYPE_LANG_FLAG_0 (expr), 1);
+  bp_pack_value (bp, TYPE_LANG_FLAG_1 (expr), 1);
+  bp_pack_value (bp, TYPE_LANG_FLAG_2 (expr), 1);
+  bp_pack_value (bp, TYPE_LANG_FLAG_3 (expr), 1);
+  bp_pack_value (bp, TYPE_LANG_FLAG_4 (expr), 1);
+  bp_pack_value (bp, TYPE_LANG_FLAG_5 (expr), 1);
+  bp_pack_value (bp, TYPE_LANG_FLAG_6 (expr), 1);
+}
+  else if (DECL_P (expr))
+{
+  bp_pack_value (bp, DECL_LANG_FLAG_0 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_1 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_2 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_3 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_4 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_5 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_6 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_7 (expr), 1);
+  bp_pack_value (bp, DECL_LANG_FLAG_8 (expr), 1);
+}
 }
 
 
@@ -344,14 +364,14 @@ pph_stream_write_binding_level (pph_stream *stream, 
struct cp_binding_level *bl,
   if (!pph_start_record (stream, bl))
 return;
 
-  pph_output_chain (stream, bl-names, ref_p);
+  pph_output_chain_filtered (stream, bl-names, ref_p, NO_BUILTINS);
   pph_output_uint (stream, bl-names_size);
-  pph_output_chain (stream, bl-namespaces, ref_p);
+  pph_output_chain_filtered (stream, bl-namespaces, ref_p, NO_BUILTINS);
 
   pph_stream_write_tree_vec (stream, bl-static_decls, ref_p);
 
-  pph_output_chain (stream, bl-usings, ref_p);
-  pph_output_chain (stream, bl-using_directives, ref_p);
+  pph_output_chain_filtered 

Re: [pph] Pickle some more language-dependent fields (issue4389050)

2011-04-12 Thread Lawrence Crowl
LGTM

On 4/12/11, Diego Novillo dnovi...@google.com wrote:

 In reconstructing pph images, I found some more language-specific
 fields that we were not pickling.  There's a few more that I will be
 sending shortly.

 Tested on x86_64.  Committed to pph.


 2011-04-12  Diego Novillo  dnovi...@google.com

   * pph-streamer-in.c (pph_stream_unpack_value_fields): Unpack
   TYPE_LANG_FLAGS and DECL_LANG_FLAGS.
   (pph_stream_read_tree): Handle TYPE_DECL.
   * pph-streamer-out.c (pph_stream_pack_value_fields): Pack
   TYPE_LANG_FLAGS and DECL_LANG_FLAGS.
   (pph_stream_write_binding_level): Call pph_output_chain_filtered
   with a NO_BUILTINS filter for fields that have DECLs in them.
   (pph_stream_write_tree): Handle TYPE_DECL.
   (pph_output_chain_filtered): New.
   * pph-streamer.c (pph_stream_trace): Show the code of the tree
   if it is not NULL_TREE.
   * pph-streamer.h (enum chain_filter): Declare.
   (pph_output_chain_filtered): Declare.

 diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
 index af7cd57..38a4561 100644
 --- a/gcc/cp/pph-streamer-in.c
 +++ b/gcc/cp/pph-streamer-in.c
 @@ -36,10 +36,30 @@ along with GCC; see the file COPYING3.  If not see
 we are unpacking from.  EXPR is the tree to unpack.  */

  void
 -pph_stream_unpack_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED,
 - tree expr ATTRIBUTE_UNUSED)
 +pph_stream_unpack_value_fields (struct bitpack_d *bp, tree expr)
  {
 -  /* Do nothing for now.  */
 +  if (TYPE_P (expr))
 +{
 +  TYPE_LANG_FLAG_0 (expr) = bp_unpack_value (bp, 1);
 +  TYPE_LANG_FLAG_1 (expr) = bp_unpack_value (bp, 1);
 +  TYPE_LANG_FLAG_2 (expr) = bp_unpack_value (bp, 1);
 +  TYPE_LANG_FLAG_3 (expr) = bp_unpack_value (bp, 1);
 +  TYPE_LANG_FLAG_4 (expr) = bp_unpack_value (bp, 1);
 +  TYPE_LANG_FLAG_5 (expr) = bp_unpack_value (bp, 1);
 +  TYPE_LANG_FLAG_6 (expr) = bp_unpack_value (bp, 1);
 +}
 +  else if (DECL_P (expr))
 +{
 +  DECL_LANG_FLAG_0 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_1 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_2 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_3 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_4 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_5 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_6 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_7 (expr) = bp_unpack_value (bp, 1);
 +  DECL_LANG_FLAG_8 (expr) = bp_unpack_value (bp, 1);
 +}
  }


 @@ -585,6 +605,8 @@ pph_stream_read_tree (struct lto_input_block *ib
 ATTRIBUTE_UNUSED,
 if (TREE_CODE (expr) == FUNCTION_DECL)
   DECL_SAVED_TREE (expr) = pph_input_tree (stream);
   }
 +  else if (TREE_CODE (expr) == TYPE_DECL)
 + DECL_ORIGINAL_TYPE (expr) = pph_input_tree (stream);
  }
else if (TREE_CODE (expr) == STATEMENT_LIST)
  {
 diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
 index aeba8eb..609673b 100644
 --- a/gcc/cp/pph-streamer-out.c
 +++ b/gcc/cp/pph-streamer-out.c
 @@ -42,10 +42,30 @@ static FILE *current_pph_file = NULL;
 we are packing into.  EXPR is the tree to pack.  */

  void
 -pph_stream_pack_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED,
 -   tree expr ATTRIBUTE_UNUSED)
 +pph_stream_pack_value_fields (struct bitpack_d *bp, tree expr)
  {
 -  /* Do nothing for now.  */
 +  if (TYPE_P (expr))
 +{
 +  bp_pack_value (bp, TYPE_LANG_FLAG_0 (expr), 1);
 +  bp_pack_value (bp, TYPE_LANG_FLAG_1 (expr), 1);
 +  bp_pack_value (bp, TYPE_LANG_FLAG_2 (expr), 1);
 +  bp_pack_value (bp, TYPE_LANG_FLAG_3 (expr), 1);
 +  bp_pack_value (bp, TYPE_LANG_FLAG_4 (expr), 1);
 +  bp_pack_value (bp, TYPE_LANG_FLAG_5 (expr), 1);
 +  bp_pack_value (bp, TYPE_LANG_FLAG_6 (expr), 1);
 +}
 +  else if (DECL_P (expr))
 +{
 +  bp_pack_value (bp, DECL_LANG_FLAG_0 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_1 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_2 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_3 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_4 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_5 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_6 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_7 (expr), 1);
 +  bp_pack_value (bp, DECL_LANG_FLAG_8 (expr), 1);
 +}
  }


 @@ -344,14 +364,14 @@ pph_stream_write_binding_level (pph_stream *stream,
 struct cp_binding_level *bl,
if (!pph_start_record (stream, bl))
  return;

 -  pph_output_chain (stream, bl-names, ref_p);
 +  pph_output_chain_filtered (stream, bl-names, ref_p, NO_BUILTINS);
pph_output_uint (stream, bl-names_size);
 -  pph_output_chain (stream, bl-namespaces, ref_p);
 +  pph_output_chain_filtered (stream, bl-namespaces, ref_p, NO_BUILTINS);

pph_stream_write_tree_vec (stream, bl-static_decls, ref_p);

 -  pph_output_chain