From patchwork Tue Jun 21 01:12:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gab Charette X-Patchwork-Id: 101228 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 412F4B6F82 for ; Tue, 21 Jun 2011 11:13:14 +1000 (EST) Received: (qmail 13504 invoked by alias); 21 Jun 2011 01:13:11 -0000 Received: (qmail 13492 invoked by uid 22791); 21 Jun 2011 01:13:10 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, 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, 21 Jun 2011 01:12:55 +0000 Received: from kpbe12.cbf.corp.google.com (kpbe12.cbf.corp.google.com [172.25.105.76]) by smtp-out.google.com with ESMTP id p5L1Crc2014740; Mon, 20 Jun 2011 18:12:53 -0700 Received: from gchare.mtv.corp.google.com (gchare.mtv.corp.google.com [172.18.111.122]) by kpbe12.cbf.corp.google.com with ESMTP id p5L1CpRC013373; Mon, 20 Jun 2011 18:12:51 -0700 Received: by gchare.mtv.corp.google.com (Postfix, from userid 138564) id 332DE1C1BF2; Mon, 20 Jun 2011 18:12:51 -0700 (PDT) To: reply@codereview.appspotmail.com, crowl@google.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fix binding_level's names_size streaming (issue4634071) Message-Id: <20110621011251.332DE1C1BF2@gchare.mtv.corp.google.com> Date: Mon, 20 Jun 2011 18:12:51 -0700 (PDT) From: gchare@google.com (Gabriel Charette) 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 We were streaming out the original names_size which includes the built-in names which are not streamed out. This only streams out the actual number of streamed names as names_size. It appears names_size is not even used anywhere in the code (or at least I couldn't find any use of it with `grep "names_size" -R gcc/`. Should we just remove it? This doesn't fix any currently failing pph tests. Tested with bootstrap build and pph regression testing. 2011-06-20 Gabriel Charette * gcc/cp/pph-streamer-out.c (pph_count_filter_match): Added. (pph_out_chain_filtered): Use pph_count_filter_match. (pph_out_binding_level): Use pph_count_filter_match. (pph_out_lang_specific): Fixed space typo. (pph_write_tree): Fixed space typo. --- This patch is available for review at http://codereview.appspot.com/4634071 diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c index 49847a9..1f9ae1d 100644 --- a/gcc/cp/pph-streamer-out.c +++ b/gcc/cp/pph-streamer-out.c @@ -383,6 +383,34 @@ pph_out_label_binding (pph_stream *stream, cp_label_binding *lb, bool ref_p) } +/* Returns the number of nodes matching FILTER in chain + starting with FIRST. */ + +static unsigned +pph_count_filter_match (tree first, enum chain_filter filter) +{ + unsigned count; + tree t; + + switch (filter) + { + case NO_BUILTINS: + for (t = first, count = 0; t; t = TREE_CHAIN (t)) + { + if (filter == NO_BUILTINS && DECL_P (t) && DECL_IS_BUILTIN (t)) + continue; + count++; + } + break; + + default: + internal_error ("unknown chain_filter used in pph_count_filter_match"); + } + + return count; +} + + /* 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. */ @@ -402,13 +430,7 @@ pph_out_chain_filtered (pph_stream *stream, tree first, bool 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++; - } + count = pph_count_filter_match (first, filter); pph_out_uint (stream, count); /* Output all the nodes that match the filter. */ @@ -439,7 +461,7 @@ static void pph_out_binding_level (pph_stream *stream, struct cp_binding_level *bl, bool ref_p) { - unsigned i; + unsigned i, streamed_names_size; cp_class_binding *cs; cp_label_binding *sl; struct bitpack_d bp; @@ -448,7 +470,8 @@ pph_out_binding_level (pph_stream *stream, struct cp_binding_level *bl, return; pph_out_chain_filtered (stream, bl->names, ref_p, NO_BUILTINS); - pph_out_uint (stream, bl->names_size); + streamed_names_size = pph_count_filter_match (bl->names, NO_BUILTINS); + pph_out_uint (stream, streamed_names_size); pph_out_chain_filtered (stream, bl->namespaces, ref_p, NO_BUILTINS); pph_out_tree_vec (stream, bl->static_decls, ref_p); @@ -714,7 +737,7 @@ pph_out_lang_specific (pph_stream *stream, tree decl, bool ref_p) ld = DECL_LANG_SPECIFIC (decl); if (!pph_start_record (stream, ld)) return; - + /* Write all the fields in lang_decl_base. */ ldb = &ld->u.base; pph_out_ld_base (stream, ldb); @@ -1080,7 +1103,7 @@ pph_write_tree (struct output_block *ob, tree expr, bool ref_p) TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr), ref_p); break; - case TEMPLATE_PARM_INDEX: + case TEMPLATE_PARM_INDEX: { template_parm_index *p = TEMPLATE_PARM_INDEX_CAST (expr); pph_out_tree_common (stream, expr, ref_p);