From patchwork Tue Jun 28 00:27:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gab Charette X-Patchwork-Id: 102298 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 F0635B6F65 for ; Tue, 28 Jun 2011 10:27:21 +1000 (EST) Received: (qmail 12720 invoked by alias); 28 Jun 2011 00:27:20 -0000 Received: (qmail 12711 invoked by uid 22791); 28 Jun 2011 00:27:19 -0000 X-SWARE-Spam-Status: No, hits=-1.4 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) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Jun 2011 00:27:05 +0000 Received: from kpbe19.cbf.corp.google.com (kpbe19.cbf.corp.google.com [172.25.105.83]) by smtp-out.google.com with ESMTP id p5S0R3Xx013665; Mon, 27 Jun 2011 17:27:04 -0700 Received: from gchare.mtv.corp.google.com (gchare.mtv.corp.google.com [172.18.111.122]) by kpbe19.cbf.corp.google.com with ESMTP id p5S0R1VN015483; Mon, 27 Jun 2011 17:27:02 -0700 Received: by gchare.mtv.corp.google.com (Postfix, from userid 138564) id B0BCA1C1BE0; Mon, 27 Jun 2011 17:27:01 -0700 (PDT) To: reply@codereview.appspotmail.com, crowl@google.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fix var order when streaming in. (issue4635074) Message-Id: <20110628002701.B0BCA1C1BE0@gchare.mtv.corp.google.com> Date: Mon, 27 Jun 2011 17:27:01 -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 The names and namespaces chains are built by adding each new element to the front of the list. When streaming it in we traverse the list of names and re-add them to the current chains; thus reversing the order in which they were defined in the header file. Since this is a singly linked-list we cannot start from the tail; thus we reverse the chain in place and then traverse it, now adding the bindings in the same order they were found in the header file. I introduced a new failing test to test this. The test showed the reverse behaviour prior to the patch. The test still fails however, there is another inversion problem between the global variables and the .LFBO, .LCFI0, ... This patch only fixes the inversion of the global variables declarations in the assembly, not the second issue this is exposing. This second issue is potentially already exposed by another test?? Do we need this new test? This fixes all of the assembly mismatches in c1limits-externalid.cc however! Tested with bootstrap build and pph regression testing. 2011-06-27 Gabriel Charette * pph-streamer-in.c (pph_add_bindings_to_namespace): Reverse names and namespaces chains. * g++.dg/pph/c1limits-externalid.cc: Remove pph asm xdiff. * g++.dg/pph/c1varorder.cc: New. * g++.dg/pph/c1varorder.h: New. * g++.dg/pph/pph.map: Add c1varorder.h --- This patch is available for review at http://codereview.appspot.com/4635074 diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c index 93b5685..cfa2ce5 100644 --- a/gcc/cp/pph-streamer-in.c +++ b/gcc/cp/pph-streamer-in.c @@ -1141,6 +1141,11 @@ pph_add_bindings_to_namespace (struct cp_binding_level *bl, tree ns) { tree t, chain; + /* The chains are built backwards (ref: add_decl_to_level@name-lookup.c), + reverse them before putting them back in. */ + bl->names = nreverse (bl->names); + bl->namespaces = nreverse (bl->namespaces); + for (t = bl->names; t; t = chain) { /* Pushing a decl into a scope clobbers its DECL_CHAIN. diff --git a/gcc/testsuite/g++.dg/pph/c1limits-externalid.cc b/gcc/testsuite/g++.dg/pph/c1limits-externalid.cc index 8d2da40..8b5039c 100644 --- a/gcc/testsuite/g++.dg/pph/c1limits-externalid.cc +++ b/gcc/testsuite/g++.dg/pph/c1limits-externalid.cc @@ -1,2 +1 @@ -// pph asm xdiff #include "c1limits-externalid.h" diff --git a/gcc/testsuite/g++.dg/pph/c1varorder.cc b/gcc/testsuite/g++.dg/pph/c1varorder.cc new file mode 100644 index 0000000..2db8209 --- /dev/null +++ b/gcc/testsuite/g++.dg/pph/c1varorder.cc @@ -0,0 +1,7 @@ +#include "c1varorder.h" +// pph asm xdiff + +int foo(void) +{ + return var1 - var2; +} diff --git a/gcc/testsuite/g++.dg/pph/c1varorder.h b/gcc/testsuite/g++.dg/pph/c1varorder.h new file mode 100644 index 0000000..a87c80c --- /dev/null +++ b/gcc/testsuite/g++.dg/pph/c1varorder.h @@ -0,0 +1,7 @@ +#ifndef __C1VARORDER_H +#define __C1VARORDER_H + +int var1; +int var2; + +#endif diff --git a/gcc/testsuite/g++.dg/pph/pph.map b/gcc/testsuite/g++.dg/pph/pph.map index 2735af8..2ed5bf2 100644 --- a/gcc/testsuite/g++.dg/pph/pph.map +++ b/gcc/testsuite/g++.dg/pph/pph.map @@ -25,6 +25,7 @@ c1simple2.h c1simple2.pph c1struct.h c1struct.pph c1typerefs.h c1typerefs.pph c1variables.h c1variables.pph +c1varorder.h c1varorder.pph c2builtin1.h c2builtin1.pph c2builtin2.h c2builtin2.pph c2builtin3.h c2builtin3.pph