From patchwork Wed Apr 13 15:54:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 610083 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qlSzW3nqpz9t3t for ; Thu, 14 Apr 2016 01:54:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=MF4o4fEr; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=DkOZ9XVQs9OqUfwDB OSmKGm4UocFIeCB7eT/RhwJT/kvujAiZhHILA+JJiA70SunyjPpCbqvVYsIcUd4t anE/VMg7Jz18pRwVKKuiKsJsPWtKcR+2m34C/+pOQ03QtZWCDxXQCIWwZ4spksOr 6zpstBwV9WGgIIXdGKhRq8c2Co= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=5XpuxlgUXvDSPUpvgHqGup/ el6M=; b=MF4o4fEre4FhFhkyGmGIFe+q1D0mWIT86caJhyk6i4QQQgRkihQjA5u eEVp737aKH9kfHHc/taQk5pGKeJbG3AmUoK/8FntzZ42Ee9aj4L3GM/AW5e2kjre r/J5gJ1FpyEVdh5IIlBweJb0V52sltsLCZhDlxQeUBnzlD9aZATk= Received: (qmail 46256 invoked by alias); 13 Apr 2016 15:54:17 -0000 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 Received: (qmail 46188 invoked by uid 89); 13 Apr 2016 15:54:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=68797, 68796, unshare, tree_chain X-HELO: mail-qk0-f196.google.com Received: from mail-qk0-f196.google.com (HELO mail-qk0-f196.google.com) (209.85.220.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 13 Apr 2016 15:54:06 +0000 Received: by mail-qk0-f196.google.com with SMTP id u190so1786218qkh.2 for ; Wed, 13 Apr 2016 08:54:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to; bh=871M3cBY1Y/3206CovtcTiv5uziD+JyJFUR+fmNyAgo=; b=BX+13K9pphASRqt+w/gDZGm7K9xSFo0OWlr1CRYLp4ADdljP55OR8hFMpsUw+y3+vI 8/+2o/XDgMz8QvSPmMuW0Gac+8/NabUlcgdO2zoVXdUFRazt/Y4ahEK5IpcUWHrXpsbs 5yC6/gy6FO5i+B/gNCopxhZIEcRRqyq7zb7/0Mzu8FscpCSk17pbRI6umEgyS3KxScbW svXBzA1mp0XRKMANToRTem0hirBjHrUI4do/hNW9V7BzNAGYAtKqEd9xdYKOA/Dd2Fq4 YU2muS14E90kts+6ZETQzbqEzqY7RZyrzP1Fj/iFXhwNWWWt/JLvzp0wuRHTcIVd4f4T NJcw== X-Gm-Message-State: AOPr4FW3Q/0qhtMJfK3v0QZEZY286ye9LhX2xXSKBEcPJ+qyeOl9jlTY8QM5Ki5fmXlfOA== X-Received: by 10.55.210.66 with SMTP id f63mr12068367qkj.25.1460562844126; Wed, 13 Apr 2016 08:54:04 -0700 (PDT) Received: from ?IPv6:2601:181:c003:1930:a2a8:cdff:fe3e:b48? ([2601:181:c003:1930:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id o75sm5433649qke.17.2016.04.13.08.54.02 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Apr 2016 08:54:03 -0700 (PDT) Subject: Re: [PATCH] c++/70594 debug info differences To: Jason Merrill , Jakub Jelinek , Patrick Palka References: <570BFE33.4030305@acm.org> <570CF588.8020006@redhat.com> <570CFE63.2010209@acm.org> <570D0617.6090201@redhat.com> <570D6190.1050704@acm.org> Cc: GCC Patches , Richard Guenther From: Nathan Sidwell Message-ID: <570E6B99.50901@acm.org> Date: Wed, 13 Apr 2016 11:54:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <570D6190.1050704@acm.org> This patch builds from Jason's proto-patch in comment #26. As Jason discovered, that led to link problems with gt_ggc_mx (tree_node *&) when building cc1. Making 'hash_map' GC-able caused gengtype to put the GC-walkers for tree into constexpr.c. No idea why. That's also what led me to add the user GTY stuff in the patch I posted earlier. For some reason manual GC fns kept the tree GC-walker in a sane place. I wonder if the same problem is why Patrick's original patch wrapped the hash_map pointer in a local structure? Rather than peer into gengtype's mind, I figured on changing to use a regular tree->tree mapper, which didn't disturb gengtype. I employ a TREE_LIST to hold the bits that fundef_copy held (body, parms, result) on (PURPOSE, VALUE, TYPE). A little unclean, but not the first time non-types are on such a TYPE, IIRC. While there I noticed that the getter only needed to use a hash getter, rather than get_or_insert. The thrust of the patch makes the fundef copies and constexpr call tables GCable, not GC-deletable. Thus their contents are not affected by GC occurrences. Finally, a new hook called at end of parsing to delete the constexpr call & fundef copies tables, so they don't remain after parsing. We don't do anything about stopping them getting too big. Patch survives boot & test, and fixes the testcase in 70594/#4 (without Jakub's patch to not emit UIDs in the gimple dump). ok? nathan 2016-04-13 Jason Merrill Nathan Sidwell PR c++/70594 * constexpr.c (constexpr_call_table): Preserve in GC. (struct fundef_copy, struct fundef_copies_table_t): Delete. (fundef_copies_table): Preserve in GC. Change to pointer to tree->tree hash. (maybe_initialize_fundef_copies_table): Adjust. (get_fundef_copy): Return a TREE_LIST. Use non-inserting search. (save_fundef_copy): Adjust for a TREE_LIST. (cxx_eval_call_expression): Adjust for a fundef_copy TREE_LIST. (fini_constexpr): New. * cp-tree.h (fini_constexpr): Declare. * decl2.c (c_parse_final_cleanups): Call fini_constexpr. Index: cp/constexpr.c =================================================================== --- cp/constexpr.c (revision 234934) +++ cp/constexpr.c (working copy) @@ -915,7 +915,7 @@ struct constexpr_ctx { /* A table of all constexpr calls that have been evaluated by the compiler in this translation unit. */ -static GTY ((deletable)) hash_table *constexpr_call_table; +static GTY (()) hash_table *constexpr_call_table; static tree cxx_eval_constant_expression (const constexpr_ctx *, tree, bool, bool *, bool *, tree * = NULL); @@ -965,17 +965,6 @@ maybe_initialize_constexpr_call_table (v constexpr_call_table = hash_table::create_ggc (101); } -/* The representation of a single node in the per-function freelist maintained - by FUNDEF_COPIES_TABLE. */ - -struct fundef_copy -{ - tree body; - tree parms; - tree res; - fundef_copy *prev; -}; - /* During constexpr CALL_EXPR evaluation, to avoid issues with sharing when a function happens to get called recursively, we unshare the callee function's body and evaluate this unshared copy instead of evaluating the @@ -983,45 +972,42 @@ struct fundef_copy FUNDEF_COPIES_TABLE is a per-function freelist of these unshared function copies. The underlying data structure of FUNDEF_COPIES_TABLE is a hash_map - that's keyed off of the original FUNCTION_DECL and whose value is the chain - of this function's unused copies awaiting reuse. */ + that's keyed off of the original FUNCTION_DECL and whose value is a + TREE_LIST of this function's unused copies awaiting reuse. -struct fundef_copies_table_t -{ - hash_map *map; -}; + This is not GC-deletable to avoid GC affecting UID generation. */ -static GTY((deletable)) fundef_copies_table_t fundef_copies_table; +static GTY(()) hash_map *fundef_copies_table; /* Initialize FUNDEF_COPIES_TABLE if it's not initialized. */ static void maybe_initialize_fundef_copies_table () { - if (fundef_copies_table.map == NULL) - fundef_copies_table.map = hash_map::create_ggc (101); + if (fundef_copies_table == NULL) + fundef_copies_table = hash_map::create_ggc (101); } /* Reuse a copy or create a new unshared copy of the function FUN. Return this copy. */ -static fundef_copy * +static tree get_fundef_copy (tree fun) { maybe_initialize_fundef_copies_table (); - fundef_copy *copy; - fundef_copy **slot = &fundef_copies_table.map->get_or_insert (fun, NULL); - if (*slot == NULL) - { - copy = ggc_alloc (); - copy->body = copy_fn (fun, copy->parms, copy->res); - copy->prev = NULL; + tree copy; + tree *slot = fundef_copies_table->get (fun); + if (slot == NULL) + { + copy = build_tree_list (NULL, NULL); + /* PURPOSE is body, VALUE is parms, TYPE is result. */ + TREE_PURPOSE (copy) = copy_fn (fun, TREE_VALUE (copy), TREE_TYPE (copy)); } else { copy = *slot; - *slot = (*slot)->prev; + *slot = TREE_CHAIN (copy); } return copy; @@ -1030,10 +1016,10 @@ get_fundef_copy (tree fun) /* Save the copy COPY of function FUN for later reuse by get_fundef_copy(). */ static void -save_fundef_copy (tree fun, fundef_copy *copy) +save_fundef_copy (tree fun, tree copy) { - fundef_copy **slot = &fundef_copies_table.map->get_or_insert (fun, NULL); - copy->prev = *slot; + tree *slot = &fundef_copies_table->get_or_insert (fun, NULL); + TREE_CHAIN (copy) = *slot; *slot = copy; } @@ -1464,10 +1450,10 @@ cxx_eval_call_expression (const constexp tree body, parms, res; /* Reuse or create a new unshared copy of this function's body. */ - fundef_copy *copy = get_fundef_copy (fun); - body = copy->body; - parms = copy->parms; - res = copy->res; + tree copy = get_fundef_copy (fun); + body = TREE_PURPOSE (copy); + parms = TREE_VALUE (copy); + res = TREE_TYPE (copy); /* Associate the bindings with the remapped parms. */ tree bound = new_call.bindings; @@ -5203,4 +5189,14 @@ require_potential_rvalue_constant_expres return potential_constant_expression_1 (t, true, true, tf_warning_or_error); } +/* Finalize constexpr processing after parsing. */ + +void +fini_constexpr (void) +{ + /* The contexpr call and fundef copies tables are no longer needed. */ + constexpr_call_table = NULL; + fundef_copies_table = NULL; +} + #include "gt-cp-constexpr.h" Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 234934) +++ cp/cp-tree.h (working copy) @@ -6879,6 +6879,7 @@ bool cilkplus_an_triplet_types_ok_p tree); /* In constexpr.c */ +extern void fini_constexpr (void); extern bool literal_type_p (tree); extern tree register_constexpr_fundef (tree, tree); extern bool check_constexpr_ctor_body (tree, tree, bool); Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 234934) +++ cp/decl2.c (working copy) @@ -4904,6 +4904,8 @@ c_parse_final_cleanups (void) finish_repo (); + fini_constexpr (); + /* The entire file is now complete. If requested, dump everything to a file. */ dump_tu ();