From patchwork Tue Apr 12 19:56:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 90859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8355CB6EFE for ; Wed, 13 Apr 2011 05:56:32 +1000 (EST) Received: (qmail 32392 invoked by alias); 12 Apr 2011 19:56:31 -0000 Received: (qmail 32384 invoked by uid 22791); 12 Apr 2011 19:56:30 -0000 X-SWARE-Spam-Status: No, hits=-2.3 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; Tue, 12 Apr 2011 19:56:24 +0000 Received: from hpaq3.eem.corp.google.com (hpaq3.eem.corp.google.com [172.25.149.3]) by smtp-out.google.com with ESMTP id p3CJuNJ2020269; Tue, 12 Apr 2011 12:56:23 -0700 Received: from topo.tor.corp.google.com (topo.tor.corp.google.com [172.29.41.2]) by hpaq3.eem.corp.google.com with ESMTP id p3CJuLRn028374; Tue, 12 Apr 2011 12:56:21 -0700 Received: by topo.tor.corp.google.com (Postfix, from userid 54752) id ABB881DA1BE; Tue, 12 Apr 2011 15:56:20 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Pickle some more language-dependent fields (issue4389050) Message-Id: <20110412195620.ABB881DA1BE@topo.tor.corp.google.com> Date: Tue, 12 Apr 2011 15:56:20 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. --- This patch is available for review at http://codereview.appspot.com/4389050 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 *);