From patchwork Tue Jan 24 23:31:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 137688 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 0A8D9B6F65 for ; Wed, 25 Jan 2012 10:31:27 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328052689; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Received:Received:Received:To: Subject:Message-Id:Date:From:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=4wj85mnNUA/jZ0JjFRIgZfqyqQI=; b=Ri/ZAxaNFfqGCXD DoHOA8ovQIM/+l2kv14vIIGS4ittg6xRNOuXcsU9OKXL1ZnqkyoTmkVT1xm4ePWH hgJgLPW4j7cRYbzcsDufVyTa38bD6R3dv6hm0saBYtaCoghjOuLvY+AZ6lGvTvVr K7LhEdhmxamqTGPDdQHHMnQacXHU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=kaURT+7wT/hLnSWwA1bzCtCmwRKIzNgNK9cc1OcnbQhVLYTuwKwtQhjheSpjPq 2FZ1aJKV2VA1KQXnFJDyFgE0wNDow3r8WRcRY/X37n7J8VENS1nWaLvnwAKzvJH0 T5DoIcSnyoiLgJ/TpSD9SryE2+LY/NLzJBxggDyThzTvY=; Received: (qmail 18904 invoked by alias); 24 Jan 2012 23:31:22 -0000 Received: (qmail 18890 invoked by uid 22791); 24 Jan 2012 23:31:20 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yx0-f201.google.com (HELO mail-yx0-f201.google.com) (209.85.213.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jan 2012 23:31:05 +0000 Received: by yenr9 with SMTP id r9so419622yen.2 for ; Tue, 24 Jan 2012 15:31:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.175.232 with SMTP id z68mr22875637yhl.6.1327447864895; Tue, 24 Jan 2012 15:31:04 -0800 (PST) Received: by 10.236.175.232 with SMTP id z68mr22875620yhl.6.1327447864832; Tue, 24 Jan 2012 15:31:04 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id j11si9494291ane.2.2012.01.24.15.31.04 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 24 Jan 2012 15:31:04 -0800 (PST) Received: from jade.mtv.corp.google.com (jade.mtv.corp.google.com [172.18.110.116]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 99B611E2653; Tue, 24 Jan 2012 15:31:04 -0800 (PST) Received: by jade.mtv.corp.google.com (Postfix, from userid 21482) id 449EC2225C8; Tue, 24 Jan 2012 15:31:04 -0800 (PST) To: reply@codereview.appspotmail.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Merge unemitted_tinfo_decls and keyed_classes (issue5575053) Message-Id: <20120124233104.449EC2225C8@jade.mtv.corp.google.com> Date: Tue, 24 Jan 2012 15:31:04 -0800 (PST) From: crowl@google.com (Lawrence Crowl) X-Gm-Message-State: ALoCoQmZAVO2TdP814IgRmLLnhQqJrsAwBIgP8Mc2pRSzNSqP1nsZtIwbGc+/cmqn6xdNuNinWPYkGmKXflTxIIesNaVEcInCibKsdTj6XSgh0IAv6UaPldBNqhhejHGFKd2CQ2r2Vn6zdhaDXYLIqXyAEVRuGAwqFK4cazxwMySLg3+QAaSLZk= 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 Merge unemitted_tinfo_decls and keyed_classes. We do not have a test case failing for keyed_classes, so the latter is anticipatory. Add a 'pph asm xokay' test marker for assembly differences that are benign. We would rather have identical assembly, but it is just not important right now. These will be treated as passes. Clarify a few other failures. Make various debug/trace dump changes. --- This patch is available for review at http://codereview.appspot.com/5575053 Index: gcc/testsuite/ChangeLog.pph 2012-01-24 Lawrence Crowl * lib/dg-pph.exp: Add an asm 'xokay' for benign assembly differences. * g++.dg/pph/x4keyno.cc: Bug fixed, now xokay. * g++.dg/pph/x4keyed.cc: Bug fixed, now xokay. * g++.dg/pph/x4keyex.cc: Mark xokay. * g++.dg/pph/x4tmplclass1.cc: Mark xokay. * g++.dg/pph/x1tmplclass2.cc: Clarify failure. * g++.dg/pph/x4tmplclass2.cc: Clarify failure. Index: gcc/cp/ChangeLog.pph 2012-01-24 Lawrence Crowl * pph-streamer.h (pph_dump_global_state): New. (pph_dump_namespace): Removed; callers now use pph_dump_global_state. * pph-core.c (pph_dump_tree_name): Add tree pointer. (pph_dump_vec_tree): New. (pph_dump_namespace): Remove message parameter. (pph_dump_global_state): New. (pph_loaded): Call pph_dump_global_state instead of pph_dump_namespace. * pph-out.c (pph_write_file): Call pph_dump_global_state instead of pph_dump_namespace. * error.c (dump_decl): Protect against null pointers. * name-lookup.c (pph_debug_binding_action): Add PPH: output label. (pph_debug_binding_inaction): Add PPH: output label. (pph_set_identifier_bindings): Modify debug label. (pph_debug_overload_binding_action): New. (pph_set_namespace_bindings): Call pph_debug_overload_binding_action instead of pph_debug_binding_action. (pph_add_overload): Remove unused. * pph-in.c (pph_is_on_chain): New. (pph_union_into_chain): New. (pph_read_file_1): Call pph_union_into_chain for keyed_classes. Call pph_union_into_tree_vec for unemitted_tinfo_decls. Call pph_dump_global_state instead of pph_dump_namespace. Index: gcc/testsuite/lib/dg-pph.exp =================================================================== --- gcc/testsuite/lib/dg-pph.exp (revision 183499) +++ gcc/testsuite/lib/dg-pph.exp (working copy) @@ -166,9 +166,14 @@ proc dg-pph-pos { subdir test options ma # The sources mark when they expect the comparison to differ. # When marked with xdiff, the difference is a problem. + # When marked with xokay, the difference is not causing a problem. # When marked with xwant, the difference is what we want. set xdiff_entry [grep $test "pph asm xdiff( )*\[0-9\]*"] + set xokay_entry [grep $test "pph asm xokay( )*\[0-9\]*"] set xwant_entry [grep $test "pph asm xwant( )*\[0-9\]*"] + if { $xokay_entry != ""} { + set xwant_entry $xokay_entry + } set xdiff [llength $xdiff_entry] set xwant [llength $xwant_entry] if { $adiff == 0 } { Index: gcc/testsuite/g++.dg/pph/x4keyno.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x4keyno.cc (revision 183499) +++ gcc/testsuite/g++.dg/pph/x4keyno.cc (working copy) @@ -1,5 +1,4 @@ -// { dg-xfail-if "redefinition problems" { *-*-* } { "-fpph-map=pph.map" } } -// { dg-excess-errors "The variable for the typeinfo name for 'keyno' is duplicated." } +// pph asm xokay 32642 #include "x0keyno1.h" #include "x0keyno2.h" Index: gcc/testsuite/g++.dg/pph/x1tmplclass2.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x1tmplclass2.cc (revision 183499) +++ gcc/testsuite/g++.dg/pph/x1tmplclass2.cc (working copy) @@ -1,4 +1,7 @@ // pph asm xdiff 37711 -// Soft failure. Symbols are emitted in different order in pph compile. +// xfail BOGUS MISSVAR +// The assembly is missing a template class static member variable +// base::variable instantiated in a prior pph file. +// Others symbols are emitted in a different order. #include "x0tmplclass23.h" #include "a0tmplclass2_u.h" Index: gcc/testsuite/g++.dg/pph/x4keyex.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x4keyex.cc (revision 183499) +++ gcc/testsuite/g++.dg/pph/x4keyex.cc (working copy) @@ -1,4 +1,4 @@ -// pph asm xdiff 32642 +// pph asm xokay 32642 // // This test case fails to compare because LFB/LFE labels are different. // Index: gcc/testsuite/g++.dg/pph/x4tmplclass1.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x4tmplclass1.cc (revision 183499) +++ gcc/testsuite/g++.dg/pph/x4tmplclass1.cc (working copy) @@ -1,4 +1,4 @@ -// pph asm xdiff 63957 +// pph asm xokay 63957 // Assembly differences seem to be due to the order in which the // symbols in the template hash tables are emitted. #include "x0tmplclass11.h" Index: gcc/testsuite/g++.dg/pph/x4keyed.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x4keyed.cc (revision 183499) +++ gcc/testsuite/g++.dg/pph/x4keyed.cc (working copy) @@ -1,5 +1,4 @@ -// { dg-xfail-if "redefinition problems" { *-*-* } { "-fpph-map=pph.map" } } -// { dg-excess-errors "typeinfo redefinition problems. May be merging issue for global binding" } +// pph asm xokay 27667 #include "x0keyed1.h" #include "x0keyed2.h" Index: gcc/testsuite/g++.dg/pph/x4tmplclass2.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x4tmplclass2.cc (revision 183499) +++ gcc/testsuite/g++.dg/pph/x4tmplclass2.cc (working copy) @@ -1,4 +1,5 @@ // pph asm xdiff 54639 +// generating different sets of variables #include "x0tmplclass21.h" #include "x0tmplclass22.h" #include "a0tmplclass2_u.h" Index: gcc/cp/pph-core.c =================================================================== --- gcc/cp/pph-core.c (revision 183499) +++ gcc/cp/pph-core.c (working copy) @@ -125,6 +125,7 @@ pph_dump_tree_name (FILE *file, tree t, { enum tree_code code = TREE_CODE (t); const char *text = pph_tree_code_text (code); + fprintf (file, "%p ", (void *)t); if (DECL_P (t)) fprintf (file, "%s %s\n", text, decl_as_string (t, flags)); else if (TYPE_P (t)) @@ -146,11 +147,9 @@ pph_dump_binding (FILE *file, cp_binding /* Dump namespace NS for PPH. */ -void -pph_dump_namespace (FILE *file, tree ns, const char *msg) +static void +pph_dump_namespace (FILE *file, tree ns) { - if (msg) - fprintf (file, "\nPPH: %s\n", msg); fprintf (file, "namespace "); pph_dump_tree_name (file, ns, 0); fprintf (file, "{\n"); @@ -185,11 +184,44 @@ pph_dump_binding (FILE *file, cp_binding { next = DECL_CHAIN (t); if (!DECL_IS_BUILTIN (t)) - pph_dump_namespace (file, t, (const char *)NULL); + pph_dump_namespace (file, t); } } +/* Dump a tree vec v for PPH. */ + +void +pph_dump_vec_tree (FILE *file, VEC(tree,gc) *v) +{ + unsigned i; + tree t; + FOR_EACH_VEC_ELT (tree, v, i, t) + pph_dump_tree_name (file, t, 0); +} + + + +/* Dump global symbol information for PPH. */ + +void +pph_dump_global_state (FILE *file, const char *msg) +{ + fprintf (file, "\nPPH: BEGIN GLOBAL STATE "); + if (msg) + fprintf (file, "%s", msg); + fprintf (file, "\n"); + pph_dump_namespace (file, global_namespace); + fprintf (file, "\nPPH: static_aggregates\n"); + pph_dump_chain (file, static_aggregates); + fprintf (file, "\nPPH: keyed_classes\n"); + pph_dump_chain (file, keyed_classes); + fprintf (file, "\nPPH: unemitted_tinfo_decls\n"); + pph_dump_vec_tree (file, unemitted_tinfo_decls); + fprintf (file, "\nPPH: END GLOBAL STATE\n\n"); +} + + /* Trace a record MARKER and TAG. */ static const char *marker_strings[] = @@ -868,7 +900,7 @@ pph_loaded (void) { pph_set_global_identifier_bindings(); if (flag_pph_dump_tree) - pph_dump_namespace (pph_logfile, global_namespace, "after all pph read"); + pph_dump_global_state (pph_logfile, "after all pph read"); } Index: gcc/cp/error.c =================================================================== --- gcc/cp/error.c (revision 183499) +++ gcc/cp/error.c (working copy) @@ -1130,7 +1130,10 @@ dump_decl (tree t, int flags) break; case LABEL_DECL: - pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); + if (DECL_NAME (t)) + pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); + else + pp_cxx_ws_string (cxx_pp, ""); break; case CONST_DECL: Index: gcc/cp/pph-out.c =================================================================== --- gcc/cp/pph-out.c (revision 183499) +++ gcc/cp/pph-out.c (working copy) @@ -2696,7 +2696,7 @@ pph_write_file (pph_stream *stream) pph_out_symtab (stream); if (flag_pph_dump_tree) - pph_dump_namespace (pph_logfile, global_namespace, "after pph write"); + pph_dump_global_state (pph_logfile, "after pph write"); } Index: gcc/cp/pph-streamer.h =================================================================== --- gcc/cp/pph-streamer.h (revision 183499) +++ gcc/cp/pph-streamer.h (working copy) @@ -249,7 +249,7 @@ enum pph_trace_end /* In pph-core.c. */ const char *pph_tree_code_text (enum tree_code code); -void pph_dump_namespace (FILE *, tree ns, const char *msg); +void pph_dump_global_state (FILE *, const char *msg); pph_stream *pph_stream_registry_lookup (const char *); void pph_stream_set_header_name (pph_stream *, const char *); pph_stream *pph_stream_open (const char *, const char *); Index: gcc/cp/name-lookup.c =================================================================== --- gcc/cp/name-lookup.c (revision 183499) +++ gcc/cp/name-lookup.c (working copy) @@ -6105,7 +6105,21 @@ pph_debug_binding_action (const char *ac { if (flag_pph_debug >= 5 || (flag_pph_debug >= 2 && !DECL_IS_BUILTIN (decl))) { - fprintf (pph_logfile, "%s ", action); + fprintf (pph_logfile, "PPH: %s ", action); + pph_dump_tree_name (pph_logfile, decl, 0); + } +} + + +/* Dump a taken binding action for overloads. */ + +static void +pph_debug_overload_binding_action (const char *action, tree ovld) +{ + tree decl = OVL_CURRENT (ovld); + if (flag_pph_debug >= 5 || (flag_pph_debug >= 2 && !DECL_IS_BUILTIN (decl))) + { + fprintf (pph_logfile, "PPH: %s ", action); pph_dump_tree_name (pph_logfile, decl, 0); } } @@ -6117,7 +6131,7 @@ pph_debug_binding_inaction (const char * { if (flag_pph_debug >= 5 || (flag_pph_debug >= 3 && !DECL_IS_BUILTIN (decl))) { - fprintf (pph_logfile, "not %s ", action); + fprintf (pph_logfile, "PPH: not %s ", action); pph_dump_tree_name (pph_logfile, decl, 0); } } @@ -6149,7 +6163,7 @@ pph_set_identifier_bindings (tree decl, tree id = DECL_NAME (decl); if (id) { - pph_debug_binding_action ("i-bind", decl); + pph_debug_binding_action ("push bind", decl); push_binding (id, decl, bl); } } @@ -6164,22 +6178,6 @@ pph_set_chain_identifier_bindings (tree } -#if 0 -/* Add an overload to a binding. */ - -static tree -pph_add_overload (tree decl, tree older) -{ - tree newer; - if (older && TREE_CODE (older) != OVERLOAD) - newer = ovl_cons (decl, ovl_cons (older, NULL_TREE)); - else - newer = ovl_cons (decl, older); - return newer; -} -#endif - - /* Set a namespace identifier binding. */ static void @@ -6220,7 +6218,7 @@ pph_set_namespace_bindings (tree decl, c if (TREE_CODE (decl) == OVERLOAD) { b->value = decl; - pph_debug_binding_action ("ovl bind", decl); + pph_debug_overload_binding_action ("ovl bind", decl); } else if (TREE_CODE (b->value) == TYPE_DECL && TREE_CODE (decl) != TYPE_DECL) Index: gcc/cp/pph-in.c =================================================================== --- gcc/cp/pph-in.c (revision 183499) +++ gcc/cp/pph-in.c (working copy) @@ -810,6 +810,37 @@ pph_union_into_tree_vec (VEC(tree,gc) ** /******************************************************************** chains */ +/* Test whether or not a tree T is on a CHAIN. */ + +static bool +pph_is_on_chain (tree chain, tree t) +{ + for (; chain; chain = TREE_CHAIN (chain)) + { + if (chain == t) + return true; + } + return false; +} + +/* Union a NEWER chain into an EXISTING chain. */ + +static void +pph_union_into_chain (tree *existing, tree newer) +{ + /* FIXME pph: A better algorithm would be nice. */ + if (newer == NULL) + return; + if (pph_is_on_chain (*existing, newer)) + pph_union_into_chain (existing, TREE_CHAIN (newer)); + else + { + pph_union_into_chain (existing, TREE_CHAIN (newer)); + TREE_CHAIN (newer) = *existing; + *existing = newer; + } +} + /* Read a chain of ASTs from STREAM. */ @@ -2990,9 +3021,7 @@ pph_read_file_1 (pph_stream *stream) cpp_ident_use *bad_use; const char *cur_def; cpp_idents_used idents_used; - tree t, file_keyed_classes, file_static_aggregates; - unsigned i; - VEC(tree,gc) *file_unemitted_tinfo_decls; + tree file_static_aggregates; source_location cpp_token_replay_loc; /* If we already have STREAM in memory (or are reading it), ignore @@ -3042,12 +3071,8 @@ pph_read_file_1 (pph_stream *stream) /* Read and merge the other global state collected during parsing of the original header. */ - file_keyed_classes = pph_in_tree (stream); - keyed_classes = chainon (file_keyed_classes, keyed_classes); - - file_unemitted_tinfo_decls = pph_in_tree_vec (stream); - FOR_EACH_VEC_ELT (tree, file_unemitted_tinfo_decls, i, t) - VEC_safe_push (tree, gc, unemitted_tinfo_decls, t); + pph_union_into_chain (&keyed_classes, pph_in_tree (stream)); + pph_union_into_tree_vec (&unemitted_tinfo_decls, pph_in_tree_vec (stream)); pph_in_pending_templates_list (stream); pph_in_spec_entry_tables (stream); @@ -3059,7 +3084,7 @@ pph_read_file_1 (pph_stream *stream) pph_in_symtab (stream); if (flag_pph_dump_tree) - pph_dump_namespace (pph_logfile, global_namespace, "after pph read"); + pph_dump_global_state (pph_logfile, "after pph read"); }