From patchwork Thu Jun 16 18:57:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gab Charette X-Patchwork-Id: 100683 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 A360EB6F7D for ; Fri, 17 Jun 2011 04:57:37 +1000 (EST) Received: (qmail 3390 invoked by alias); 16 Jun 2011 18:57:35 -0000 Received: (qmail 3382 invoked by uid 22791); 16 Jun 2011 18:57:34 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Jun 2011 18:57:20 +0000 Received: from hpaq5.eem.corp.google.com (hpaq5.eem.corp.google.com [172.25.149.5]) by smtp-out.google.com with ESMTP id p5GIvIRM025090; Thu, 16 Jun 2011 11:57:19 -0700 Received: from gchare.mtv.corp.google.com (gchare.mtv.corp.google.com [172.18.111.122]) by hpaq5.eem.corp.google.com with ESMTP id p5GIvGxi001903; Thu, 16 Jun 2011 11:57:16 -0700 Received: by gchare.mtv.corp.google.com (Postfix, from userid 138564) id CDA091C3548; Thu, 16 Jun 2011 11:57:15 -0700 (PDT) To: reply@codereview.appspotmail.com, crowl@google.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fix cxx_binding streaming logic (issue4646041) Message-Id: <20110616185715.CDA091C3548@gchare.mtv.corp.google.com> Date: Thu, 16 Jun 2011 11:57:15 -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 losing bindings when reassigning prev bindings with the current streaming logic. This doesn't fix any currently exposed bugs, but again helps me as part of fixing the bigger bug I'm on. Tested with bootstrap build and pph regression testing. At the end of pph_out_cxx_binding I could also simply do pph_out_uchar (stream, PPH_RECORD_END); instead of pph_out_cxx_binding_1 (stream, NULL, ref_p); which has the exact same effect. I just thought it might clearer to the reader and also more robust code if we eventually decide to change the way caching works internally. 2011-06-16 Gabriel Charette * gcc/cp/pph-streamer-in.c (pph_in_cxx_binding): Fix streaming logic. * gcc/cp/pph-streamer-out.c (pph_out_cxx_binding): Fix streaming logic. --- This patch is available for review at http://codereview.appspot.com/4646041 Index: gcc/cp/pph-streamer-in.c =================================================================== --- gcc/cp/pph-streamer-in.c (revision 175106) +++ gcc/cp/pph-streamer-in.c (working copy) @@ -353,24 +353,18 @@ static cxx_binding * pph_in_cxx_binding (pph_stream *stream) { - unsigned i, num_bindings; - cxx_binding *curr, *cb; + cxx_binding *curr, *prev, *cb; + /* Read the current binding first. */ + cb = pph_in_cxx_binding_1 (stream); + /* Read the list of previous bindings. */ - num_bindings = pph_in_uint (stream); - for (curr = NULL, i = 0; i < num_bindings; i++) + for (curr = cb; curr; curr = prev) { - cxx_binding *prev = pph_in_cxx_binding_1 (stream); - if (curr) - curr->previous = prev; - curr = prev; + prev = pph_in_cxx_binding_1 (stream); + curr->previous = prev; } - /* Read the current binding at the end. */ - cb = pph_in_cxx_binding_1 (stream); - if (cb) - cb->previous = curr; - return cb; } Index: gcc/cp/pph-streamer-out.c =================================================================== --- gcc/cp/pph-streamer-out.c (revision 175106) +++ gcc/cp/pph-streamer-out.c (working copy) @@ -339,21 +339,18 @@ static void pph_out_cxx_binding (pph_stream *stream, cxx_binding *cb, bool ref_p) { - unsigned num_bindings; cxx_binding *prev; - num_bindings = 0; - for (prev = cb ? cb->previous : NULL; prev; prev = prev->previous) - num_bindings++; + /* Write the current binding first. */ + pph_out_cxx_binding_1 (stream, cb, ref_p); /* Write the list of previous bindings. */ - pph_out_uint (stream, num_bindings); - if (num_bindings > 0) - for (prev = cb->previous; prev; prev = prev->previous) - pph_out_cxx_binding_1 (stream, prev, ref_p); + for (prev = cb ? cb->previous : NULL; prev; prev = prev->previous) + pph_out_cxx_binding_1 (stream, prev, ref_p); - /* Write the current binding at the end. */ - pph_out_cxx_binding_1 (stream, cb, ref_p); + /* Mark the end of the list (if there was a list). */ + if (cb) + pph_out_cxx_binding_1 (stream, NULL, ref_p); }