From patchwork Sat Jul 2 01:35:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gab Charette X-Patchwork-Id: 102977 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 188EFB6F59 for ; Sat, 2 Jul 2011 11:35:24 +1000 (EST) Received: (qmail 2182 invoked by alias); 2 Jul 2011 01:35:22 -0000 Received: (qmail 1948 invoked by uid 22791); 2 Jul 2011 01:35:21 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD, URI_HEX 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; Sat, 02 Jul 2011 01:35:07 +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 p621Z5kY012971; Fri, 1 Jul 2011 18:35:06 -0700 Received: from gchare.mtv.corp.google.com (gchare.mtv.corp.google.com [172.18.111.122]) by hpaq3.eem.corp.google.com with ESMTP id p621Z2DB004390; Fri, 1 Jul 2011 18:35:03 -0700 Received: by gchare.mtv.corp.google.com (Postfix, from userid 138564) id 8FD271C1CDF; Fri, 1 Jul 2011 18:35:02 -0700 (PDT) To: reply@codereview.appspotmail.com, crowl@google.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fix global variable assembly ordering (issue4627087) Message-Id: <20110702013502.8FD271C1CDF@gchare.mtv.corp.google.com> Date: Fri, 1 Jul 2011 18:35:02 -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 As variables are discovered (while parsing the header) they are added to the varpool and their RTL is built. We do not stream, nor the varpool, nor the RTL (and I don't think we want to + that wouldn't work with multiple pph). We want to rebuild the varpool when streaming the global variables of the pph in so as to redefine them in the varpool in the same order they would have been found in a regular #include style parse. I'm not sure whether "global variables, not externals" is specific enough or too broad (I can't reuse the caller of varpool_finalize_decl (rest_of_decl_compilation) to take care of this logic because it needs some parser state which we no longer have). I will create more tests next week with different orderings for functions, structs, etc. coming in from the pph. For now, this fixes 8 tests :). Tested with bootstrap and pph regression testing. PS: Just realized I didn't put a comment in the code for that fix, should I add one? 2011-07-01 Gabriel Charette * gcc/cp/pph-streamer-in.c (pph_add_bindings_to_namespace): Rebuild the varpool for global variables coming in from the pph. * gcc/testsuite/g++.dg/pph/c120060625-1.cc: Expect no asm difference. * gcc/testsuite/g++.dg/pph/c1struct.cc: Likewise. * gcc/testsuite/g++.dg/pph/c1variables.cc: Likewise. * gcc/testsuite/g++.dg/pph/c1varorder.cc: Likewise. * gcc/testsuite/g++.dg/pph/c2builtin1.cc: Likewise. * gcc/testsuite/g++.dg/pph/c2builtin2.cc: Likewise. * gcc/testsuite/g++.dg/pph/x1struct2.cc: Likewise. * gcc/testsuite/g++.dg/pph/x1variables.cc: Likewise. --- This patch is available for review at http://codereview.appspot.com/4627087 diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c index 3ac5243..0ddcc75 100644 --- a/gcc/cp/pph-streamer-in.c +++ b/gcc/cp/pph-streamer-in.c @@ -1157,6 +1157,9 @@ pph_add_bindings_to_namespace (struct cp_binding_level *bl, tree ns) Preserve it. */ chain = DECL_CHAIN (t); pushdecl_into_namespace (t, ns); + + if (TREE_CODE (t) == VAR_DECL && TREE_STATIC (t) && !DECL_EXTERNAL (t)) + varpool_finalize_decl (t); } for (t = bl->namespaces; t; t = chain) diff --git a/gcc/testsuite/g++.dg/pph/c120060625-1.cc b/gcc/testsuite/g++.dg/pph/c120060625-1.cc index d09be39..05c7929 100644 --- a/gcc/testsuite/g++.dg/pph/c120060625-1.cc +++ b/gcc/testsuite/g++.dg/pph/c120060625-1.cc @@ -1,2 +1 @@ -// pph asm xdiff #include "c120060625-1.h" diff --git a/gcc/testsuite/g++.dg/pph/c1struct.cc b/gcc/testsuite/g++.dg/pph/c1struct.cc index 88c215b..8de9166 100644 --- a/gcc/testsuite/g++.dg/pph/c1struct.cc +++ b/gcc/testsuite/g++.dg/pph/c1struct.cc @@ -1,5 +1,3 @@ -// pph asm xdiff - #include "c1struct.h" thing var1; diff --git a/gcc/testsuite/g++.dg/pph/c1variables.cc b/gcc/testsuite/g++.dg/pph/c1variables.cc index 12a5f30..4d3c5a7 100644 --- a/gcc/testsuite/g++.dg/pph/c1variables.cc +++ b/gcc/testsuite/g++.dg/pph/c1variables.cc @@ -1,5 +1,3 @@ -// pph asm xdiff - #include "c1variables.h" int gbl_initial = 1; diff --git a/gcc/testsuite/g++.dg/pph/c1varorder.cc b/gcc/testsuite/g++.dg/pph/c1varorder.cc index a7a65ec..2791427 100644 --- a/gcc/testsuite/g++.dg/pph/c1varorder.cc +++ b/gcc/testsuite/g++.dg/pph/c1varorder.cc @@ -1,5 +1,3 @@ -// pph asm xdiff - #include "c1varorder.h" int foo(void) diff --git a/gcc/testsuite/g++.dg/pph/c2builtin1.cc b/gcc/testsuite/g++.dg/pph/c2builtin1.cc index 9a3a7a1..67327cb 100644 --- a/gcc/testsuite/g++.dg/pph/c2builtin1.cc +++ b/gcc/testsuite/g++.dg/pph/c2builtin1.cc @@ -1,5 +1,3 @@ -// pph asm xdiff - #include "c2builtin1.h" #include "c2builtin2.h" #include "c2builtin3.h" diff --git a/gcc/testsuite/g++.dg/pph/c2builtin2.cc b/gcc/testsuite/g++.dg/pph/c2builtin2.cc index 186ebcf..0ccae57 100644 --- a/gcc/testsuite/g++.dg/pph/c2builtin2.cc +++ b/gcc/testsuite/g++.dg/pph/c2builtin2.cc @@ -1,4 +1,3 @@ -// pph asm xdiff #include "a2builtin4.h" #include "c2builtin5.h" #include "c2builtin6.h" diff --git a/gcc/testsuite/g++.dg/pph/x1struct2.cc b/gcc/testsuite/g++.dg/pph/x1struct2.cc index be1af39..f31fb8c 100644 --- a/gcc/testsuite/g++.dg/pph/x1struct2.cc +++ b/gcc/testsuite/g++.dg/pph/x1struct2.cc @@ -1,5 +1,3 @@ -// pph asm xdiff - #include "x1struct2.h" type D::method() diff --git a/gcc/testsuite/g++.dg/pph/x1variables.cc b/gcc/testsuite/g++.dg/pph/x1variables.cc index 0f0814f..f9fd76e 100644 --- a/gcc/testsuite/g++.dg/pph/x1variables.cc +++ b/gcc/testsuite/g++.dg/pph/x1variables.cc @@ -1,5 +1,3 @@ -// pph asm xdiff - #include "x1variables.h" int D::mbr_init_plain = 4;