From patchwork Thu Oct 13 03:36:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 119342 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 D9F84B6F71 for ; Thu, 13 Oct 2011 14:37:11 +1100 (EST) Received: (qmail 22680 invoked by alias); 13 Oct 2011 03:37:09 -0000 Received: (qmail 22670 invoked by uid 22791); 13 Oct 2011 03:37:07 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Thu, 13 Oct 2011 03:36:53 +0000 Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id p9D3aphf004510; Wed, 12 Oct 2011 20:36:51 -0700 Received: from jade.mtv.corp.google.com (jade.mtv.corp.google.com [172.18.110.116]) by wpaz29.hot.corp.google.com with ESMTP id p9D3an1L014224; Wed, 12 Oct 2011 20:36:49 -0700 Received: by jade.mtv.corp.google.com (Postfix, from userid 21482) id 472DE222694; Wed, 12 Oct 2011 20:36:49 -0700 (PDT) To: reply@codereview.appspotmail.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] More DECL merging. (issue5268042) Message-Id: <20111013033649.472DE222694@jade.mtv.corp.google.com> Date: Wed, 12 Oct 2011 20:36:49 -0700 (PDT) From: crowl@google.com (Lawrence Crowl) 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 Use the mangled name for merging, as this should enable us to handle function overloads. We use the regular identifier for other declarations, as that should be sufficient and avoids the problem of --- This patch is available for review at http://codereview.appspot.com/5268042 different typedefs mangling to the same name. Merge struct members as well as namespace members. This will eventually help with member declaration versus definition issues. Change test cases to reflect the above. Comment on other failing tests. Comment on failing cache handling for merge. Tested on x64. Index: gcc/testsuite/ChangeLog.pph 2011-10-12 Lawrence Crowl * g++.dg/pph/p2pr36533.cc: Mark expected fail on unexpanded intrinsic. * g++.dg/pph/p4pr36533.cc: Likewise. * g++.dg/pph/p4mean.cc: Likewise. * g++.dg/pph/c3variables.cc: Comment on reason for fail. * g++.dg/pph/c4vardef.cc: Likewise. Index: gcc/cp/ChangeLog.pph 2011-10-12 Lawrence Crowl * pph-streamer.h (pph_merge_name): New. * pph-streamer.c (pph_merge_name): New. * pph-streamer-out.c (pph_out_mergeable_tree_vec): Emit the vector in declaration order. (pph_out_merge_name): New. (pph_write_any_tree): Use pph_out_merge_name instead of raw code. * pph-streamer-in.c (pph_match_to_link): Use pph_merge_name. (pph_in_binding_level): Also merge members of structs. (pph_read_any_tree): Save read tree to determine if it is different from the tree to be used. Index: gcc/testsuite/g++.dg/pph/p2pr36533.cc =================================================================== --- gcc/testsuite/g++.dg/pph/p2pr36533.cc (revision 179880) +++ gcc/testsuite/g++.dg/pph/p2pr36533.cc (working copy) @@ -1,2 +1,6 @@ /* { dg-options "-w -fpermissive" } */ +// pph asm xdiff 25347 +// xfail BOGUS INTRINSIC +// failing to recognise memset as an intrinsic + #include "p1pr36533.h" Index: gcc/testsuite/g++.dg/pph/c3variables.cc =================================================================== --- gcc/testsuite/g++.dg/pph/c3variables.cc (revision 179880) +++ gcc/testsuite/g++.dg/pph/c3variables.cc (working copy) @@ -1,4 +1,5 @@ // pph asm xdiff 34997 +// xfail BOGUS DUPVAR // tentative definition emitted twice #include "c0variables1.h" Index: gcc/testsuite/g++.dg/pph/p4mean.cc =================================================================== --- gcc/testsuite/g++.dg/pph/p4mean.cc (revision 179880) +++ gcc/testsuite/g++.dg/pph/p4mean.cc (working copy) @@ -1,4 +1,8 @@ /* { dg-options "-w -fpermissive" } */ +// pph asm xdiff 39234 +// xfail BOGUS INTRINSIC +// failing to recognize sqrt as an intrinsic + #include #include #include Index: gcc/testsuite/g++.dg/pph/p4pr36533.cc =================================================================== --- gcc/testsuite/g++.dg/pph/p4pr36533.cc (revision 179880) +++ gcc/testsuite/g++.dg/pph/p4pr36533.cc (working copy) @@ -1,2 +1,6 @@ /* { dg-options "-w -fpermissive" } */ +// pph asm xdiff 25347 +// xfail BOGUS INTRINSIC +// failing to recognise memset as an intrinsic + #include "p4pr36533.h" Index: gcc/testsuite/g++.dg/pph/c4vardef.cc =================================================================== --- gcc/testsuite/g++.dg/pph/c4vardef.cc (revision 179880) +++ gcc/testsuite/g++.dg/pph/c4vardef.cc (working copy) @@ -1,4 +1,6 @@ // pph asm xdiff 00553 +// xfail BOGUS DUPVAR +// definition emitted twice #include "c0vardef1.h" #include "c0vardef2.h" Index: gcc/cp/pph-streamer-in.c =================================================================== --- gcc/cp/pph-streamer-in.c (revision 179880) +++ gcc/cp/pph-streamer-in.c (working copy) @@ -803,7 +803,7 @@ pph_match_to_function (tree expr ATTRIBU against an LINK of a chain. */ static tree -pph_match_to_link (tree expr, location_t where, const char *idstr, tree* link) +pph_match_to_link (tree expr, location_t where, const char *idstr, tree *link) { enum tree_code link_code, expr_code; tree idtree; @@ -817,7 +817,7 @@ pph_match_to_link (tree expr, location_t if (link_code != expr_code) return NULL; - idtree = DECL_NAME (*link); + idtree = pph_merge_name (*link); if (!idtree) return NULL; @@ -1072,7 +1072,7 @@ pph_in_binding_level (cp_binding_level * *out_field = bl; entity = bl->this_entity = pph_in_tree (stream); - if (NAMESPACE_SCOPE_P (entity)) + if (NAMESPACE_SCOPE_P (entity) || DECL_CLASS_SCOPE_P (entity)) { if (flag_pph_debug >= 3) debug_tree_chain (bl->names); @@ -1962,7 +1962,8 @@ pph_read_any_tree (pph_stream *stream, t { struct lto_input_block *ib = stream->encoder.r.ib; struct data_in *data_in = stream->encoder.r.data_in; - tree expr = NULL_TREE; + tree read = NULL; + tree expr = NULL; enum pph_record_marker marker; unsigned image_ix, ix; enum LTO_tags tag; @@ -1998,9 +1999,11 @@ pph_read_any_tree (pph_stream *stream, t /* Materialize a new node from IB. This will also read all the language-independent bitfields for the new tree. */ - expr = pph_read_tree_header (stream, tag); + expr = read = pph_read_tree_header (stream, tag); + gcc_assert (read != NULL); if (chain) expr = pph_merge_into_chain (stream, expr, chain); + gcc_assert (expr != NULL); } gcc_assert (marker == PPH_RECORD_START @@ -2021,6 +2024,7 @@ pph_read_any_tree (pph_stream *stream, t /* Add the new tree to the cache and read its body. The tree is added to the cache before we read its body to handle circular references and references from children nodes. */ + /* FIXME pph: We should not insert when read == expr, but it fails. */ pph_cache_insert_at (&stream->cache, expr, ix, pph_tree_code_to_tag (expr)); pph_read_tree_body (stream, expr); Index: gcc/cp/pph-streamer.c =================================================================== --- gcc/cp/pph-streamer.c (revision 179880) +++ gcc/cp/pph-streamer.c (working copy) @@ -727,3 +727,15 @@ pph_get_signature (tree t, size_t *nbyte return crc; } + + +/* Return the merge name string identifier tree for a decl EXPR. */ + +tree +pph_merge_name (tree expr) +{ + if (TREE_CODE (expr) == FUNCTION_DECL) + return DECL_ASSEMBLER_NAME (expr); + else + return DECL_NAME (expr); +} Index: gcc/cp/pph-streamer.h =================================================================== --- gcc/cp/pph-streamer.h (revision 179880) +++ gcc/cp/pph-streamer.h (working copy) @@ -246,6 +246,7 @@ bool pph_cache_add (pph_cache *, void *, void pph_cache_sign (pph_cache *, unsigned, unsigned, size_t); unsigned pph_get_signature (tree, size_t *); void pph_writer_add_include (pph_stream *); +tree pph_merge_name (tree expr); /* In pph-streamer-out.c. */ void pph_flush_buffers (pph_stream *); Index: gcc/cp/pph-streamer-out.c =================================================================== --- gcc/cp/pph-streamer-out.c (revision 179880) +++ gcc/cp/pph-streamer-out.c (working copy) @@ -819,7 +819,7 @@ pph_out_mergeable_tree_vec (pph_stream * using streamer_read_chain, we have to write VECs in exactly the same way as tree chains. */ pph_out_hwi (stream, VEC_length (tree, v)); - FOR_EACH_VEC_ELT (tree, v, i, t) + FOR_EACH_VEC_ELT_REVERSE (tree, v, i, t) pph_out_mergeable_tree (stream, t); } @@ -1906,9 +1906,23 @@ pph_write_tree_header (pph_stream *strea } +/* Write the merge name string for a decl EXPR. */ + +static void +pph_out_merge_name (pph_stream *stream, tree expr) +{ + tree name = pph_merge_name (expr); + if (name) + pph_out_string_with_length (stream, IDENTIFIER_POINTER (name), + IDENTIFIER_LENGTH (name)); + else + pph_out_string (stream, NULL); +} + + /* Write a tree EXPR (MERGEABLE or not) to STREAM. */ -void +static void pph_write_any_tree (pph_stream *stream, tree expr, bool mergeable) { enum pph_record_marker marker; @@ -1952,16 +1966,9 @@ pph_write_any_tree (pph_stream *stream, pph_write_tree_header (stream, expr); if (mergeable && DECL_P (expr)) { - tree name; - /* We may need to unify two declarations. */ pph_out_location (stream, DECL_SOURCE_LOCATION (expr)); - name = DECL_NAME (expr); - if (name) - pph_out_string_with_length (stream, IDENTIFIER_POINTER (name), - IDENTIFIER_LENGTH (name)); - else - pph_out_string (stream, NULL); + pph_out_merge_name (stream, expr); } }