From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5957 invoked by alias); 13 Apr 2011 00:34:15 -0000 Received: (qmail 5300 invoked by uid 22791); 13 Apr 2011 00:34:13 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_TM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Apr 2011 00:34:06 +0000 Received: from hpaq14.eem.corp.google.com (hpaq14.eem.corp.google.com [172.25.149.14]) by smtp-out.google.com with ESMTP id p3D0Y4H1015365 for ; Tue, 12 Apr 2011 17:34:04 -0700 Received: from pzk32 (pzk32.prod.google.com [10.243.19.160]) by hpaq14.eem.corp.google.com with ESMTP id p3D0Y2eq031860 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 12 Apr 2011 17:34:03 -0700 Received: by pzk32 with SMTP id 32so47336pzk.28 for ; Tue, 12 Apr 2011 17:34:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.150.22 with SMTP id x22mr7185206wfd.150.1302654841436; Tue, 12 Apr 2011 17:34:01 -0700 (PDT) Received: by 10.142.98.2 with HTTP; Tue, 12 Apr 2011 17:34:01 -0700 (PDT) In-Reply-To: <20110412195620.ABB881DA1BE@topo.tor.corp.google.com> References: <20110412195620.ABB881DA1BE@topo.tor.corp.google.com> Date: Wed, 13 Apr 2011 00:34:00 -0000 Message-ID: Subject: Re: [pph] Pickle some more language-dependent fields (issue4389050) From: Lawrence Crowl To: Diego Novillo Cc: reply@codereview.appspotmail.com, gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg00951.txt.bz2 LGTM On 4/12/11, Diego Novillo 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 > > * 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 (stream, bl->usings, ref_p, NO_BUILTINS); > + pph_output_chain_filtered (stream, bl->using_directives, ref_p, > NO_BUILTINS); > > pph_output_uint (stream, VEC_length (cp_class_binding, > bl->class_shadowed)); > for (i = 0; VEC_iterate (cp_class_binding, bl->class_shadowed, i, cs); > i++) > @@ -594,6 +614,8 @@ pph_stream_write_tree (struct output_block *ob, tree > expr, bool ref_p) > if (TREE_CODE (expr) == FUNCTION_DECL) > pph_output_tree_aux (stream, DECL_SAVED_TREE (expr), ref_p); > } > + else if (TREE_CODE (expr) == TYPE_DECL) > + pph_output_tree (stream, DECL_ORIGINAL_TYPE (expr), ref_p); > } > else if (TREE_CODE (expr) == STATEMENT_LIST) > { > @@ -611,3 +633,52 @@ pph_stream_write_tree (struct output_block *ob, tree > expr, bool ref_p) > pph_output_tree_aux (stream, tsi_stmt (i), ref_p); > } > } > + > + > +/* Output a chain of nodes to STREAM starting with FIRST. Skip any > + nodes that do not match FILTER. REF_P is true if nodes in the chain > + should be emitted as references. */ > + > +void > +pph_output_chain_filtered (pph_stream *stream, tree first, bool ref_p, > + enum chain_filter filter) > +{ > + unsigned count; > + tree t; > + > + /* Special case. If the caller wants no filtering, it is much > + faster to just call pph_output_chain directly. */ > + if (filter == NONE) > + { > + pph_output_chain (stream, first, ref_p); > + return; > + } > + > + /* Count all the nodes that match the filter. */ > + for (t = first, count = 0; t; t = TREE_CHAIN (t)) > + { > + if (filter == NO_BUILTINS && DECL_P (t) && DECL_IS_BUILTIN (t)) > + continue; > + count++; > + } > + pph_output_uint (stream, count); > + > + /* Output all the nodes that match the filter. */ > + for (t = first; t; t = TREE_CHAIN (t)) > + { > + tree saved_chain; > + > + /* Apply filters to T. */ > + if (filter == NO_BUILTINS && DECL_P (t) && DECL_IS_BUILTIN (t)) > + continue; > + > + /* Clear TREE_CHAIN to avoid blindly recursing into the rest > + of the list. */ > + saved_chain = TREE_CHAIN (t); > + TREE_CHAIN (t) = NULL_TREE; > + > + pph_output_tree (stream, t, ref_p); > + > + TREE_CHAIN (t) = saved_chain; > + } > +} > diff --git a/gcc/cp/pph-streamer.c b/gcc/cp/pph-streamer.c > index e65a792..91e01a4 100644 > --- a/gcc/cp/pph-streamer.c > +++ b/gcc/cp/pph-streamer.c > @@ -146,8 +146,14 @@ pph_stream_trace (pph_stream *stream, const void *data, > unsigned int nbytes, > case PPH_TRACE_TREE: > { > const_tree t = (const_tree) data; > - print_generic_expr (pph_logfile, CONST_CAST (union tree_node *, t), > - TDF_SLIM); > + if (t) > + { > + print_generic_expr (pph_logfile, CONST_CAST (union tree_node *, t), > + 0); > + fprintf (pph_logfile, ", code=%s", tree_code_name[TREE_CODE (t)]); > + } > + else > + fprintf (pph_logfile, "NULL_TREE"); > } > break; > > diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h > index 8731eb8..329e507 100644 > --- a/gcc/cp/pph-streamer.h > +++ b/gcc/cp/pph-streamer.h > @@ -87,6 +87,9 @@ typedef struct pph_stream { > unsigned int write_p : 1; > } pph_stream; > > +/* Filter values for pph_output_chain_filtered. */ > +enum chain_filter { NONE, NO_BUILTINS }; > + > /* In pph-streamer.c. */ > pph_stream *pph_stream_open (const char *, const char *); > void pph_stream_close (pph_stream *); > @@ -104,6 +107,7 @@ void pph_stream_init_write (pph_stream *); > void pph_stream_write_tree (struct output_block *, tree, bool ref_p); > void pph_stream_pack_value_fields (struct bitpack_d *, tree); > void pph_stream_output_tree_header (struct output_block *, tree); > +void pph_output_chain_filtered (pph_stream *, tree, bool, enum > chain_filter); > > /* In pph-streamer-in.c. */ > void pph_stream_init_read (pph_stream *); > > -- > This patch is available for review at http://codereview.appspot.com/4389050 > -- Lawrence Crowl