From patchwork Wed Jan 14 19:55:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 429072 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 7EA9D140188 for ; Thu, 15 Jan 2015 06:55:57 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=QK4+ihY7Xy4Ina47esGYQDwCsvR+TFURyjWtye069c6 k9QSJV2CRPtdtgEFDOhjBUHSgiEdviSRtVaneGOVJ+YH069fwKLZZjP2TDEfxeVd e+S9V5gAzd1ZzTSqiyQWTG2Sk9xXv6lZoeY0vqfePQ5f6+AftVcGeMF9O1xB9viw = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=O5Tt/3kbV0qnNxMm+QJ0p9FDC54=; b=NTOS3VCJIBMi1HDZ/ K8gELIGKs1x+m3Ghppk9bWOJ/vuu2W16vEdPkRWKttFa+9DJZuN3gL7X41LPk55j Lqv3qnAXSgFU+sR4VQYYxm/ZwIC2BzBD0OYv6fbHK7zKMJob+fraVcb6esYeotb9 CQ0CgQd9DnMad+y4IFrBS9WccQ= Received: (qmail 5873 invoked by alias); 14 Jan 2015 19:55:46 -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 5790 invoked by uid 89); 14 Jan 2015 19:55:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 14 Jan 2015 19:55:33 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0EJtWPM012438 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Jan 2015 14:55:32 -0500 Received: from reynosa.quesejoda.com (vpn-51-38.rdu2.redhat.com [10.10.51.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0EJtUE7004850; Wed, 14 Jan 2015 14:55:31 -0500 Message-ID: <54B6C9B1.2020407@redhat.com> Date: Wed, 14 Jan 2015 11:55:29 -0800 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: gcc-patches CC: jason merrill , Richard Biener Subject: [debug-early] fix C++ mangling issues with deferred_asm_name removal There were some -fcompare-debug regressions when I removed the deferred_asm_name auxiliary data structure from dwarf2out. Jason was kind enough to tackle them (or at least the main one). Apparently there was some bug in the mangling code that necessitated the entire deferred_asm_name vector. I'll let Jason explain further. With this patch I see less guality failures than mainline, so perhaps removing deferred_asm_name can be pushed to mainline as soon as stage1 opens, or earlier if we feel lucky. I will be committing this patch, as well as my deferred_asm_name removal patch to the branch. Thanks. commit 0c817fd43f95029153045b9523c1c8b49291e4a3 Author: Aldy Hernandez Date: Wed Jan 14 10:12:40 2015 -0800 cp/ * decl2.c (mangling_aliases): New variable. (note_mangling_alias, generate_mangling_aliases): New. (cp_write_global_declarations): Call generate_mangling_aliases. (generate_mangling_alias): Split out from... * mangle.c (mangle_decl): ...here. * cp-tree.h: Declare note_mangling_alias. diff --git a/gcc/ChangeLog.debug-early b/gcc/ChangeLog.debug-early index 48d1913..f4fb4ba 100644 --- a/gcc/ChangeLog.debug-early +++ b/gcc/ChangeLog.debug-early @@ -1,3 +1,13 @@ +2015-01-14 Jason Merrill + + cp/ + * decl2.c (mangling_aliases): New variable. + (note_mangling_alias, generate_mangling_aliases): New. + (cp_write_global_declarations): Call generate_mangling_aliases. + (generate_mangling_alias): Split out from... + * mangle.c (mangle_decl): ...here. + * cp-tree.h: Declare note_mangling_alias. + 2015-01-06 Aldy Hernandez * dwarf2out.c: Remove deferred_asm_name. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 98f2e20..5fa96cb 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5431,6 +5431,7 @@ extern tree finish_case_label (location_t, tree, tree); extern tree cxx_maybe_build_cleanup (tree, tsubst_flags_t); /* in decl2.c */ +extern void note_mangling_alias (tree, tree); extern bool check_java_method (tree); extern tree build_memfn_type (tree, tree, cp_cv_quals, cp_ref_qualifier); extern tree build_pointer_ptrmemfn_type (tree); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index abcaeac..691688b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -114,6 +114,10 @@ static GTY(()) vec *deferred_fns; sure are defined. */ static GTY(()) vec *no_linkage_decls; +/* A vector of alternating decls and identifiers, where the latter + is to be an alias for the former if the former is defined. */ +static GTY(()) vec *mangling_aliases; + /* Nonzero if we're done parsing and into end-of-file activities. */ int at_eof; @@ -4253,6 +4257,66 @@ handle_tls_init (void) expand_or_defer_fn (finish_function (0)); } +/* We're at the end of compilation, so generate any mangling aliases that + we've been saving up, if DECL is going to be output and ID2 isn't + already taken by another declaration. */ + +static void +generate_mangling_alias (tree decl, tree id2) +{ + /* If there's a declaration already using this mangled name, + don't create a compatibility alias that conflicts. */ + if (IDENTIFIER_GLOBAL_VALUE (id2)) + return; + + struct cgraph_node *n = NULL; + if (TREE_CODE (decl) == FUNCTION_DECL + && !(n = cgraph_node::get (decl))) + /* Don't create an alias to an unreferenced function. */ + return; + + tree alias = make_alias_for (decl, id2); + SET_IDENTIFIER_GLOBAL_VALUE (id2, alias); + DECL_IGNORED_P (alias) = 1; + TREE_PUBLIC (alias) = TREE_PUBLIC (decl); + DECL_VISIBILITY (alias) = DECL_VISIBILITY (decl); + if (vague_linkage_p (decl)) + DECL_WEAK (alias) = 1; + if (TREE_CODE (decl) == FUNCTION_DECL) + n->create_same_body_alias (alias, decl); + else + varpool_node::create_extra_name_alias (alias, decl); +} + +/* Note that we might want to emit an alias with the symbol ID2 for DECL at + the end of translation, for compatibility across bugs in the mangling + implementation. */ + +void +note_mangling_alias (tree decl, tree id2) +{ +#ifdef ASM_OUTPUT_DEF + if (at_eof) + generate_mangling_alias (decl, id2); + else + { + vec_safe_push (mangling_aliases, decl); + vec_safe_push (mangling_aliases, id2); + } +#endif +} + +static void +generate_mangling_aliases () +{ + while (!vec_safe_is_empty (mangling_aliases)) + { + tree id2 = mangling_aliases->pop(); + tree decl = mangling_aliases->pop(); + generate_mangling_alias (decl, id2); + } +} + /* The entire file is now complete. If requested, dump everything to a file. */ @@ -4593,6 +4657,8 @@ c_parse_final_cleanups (void) } while (reconsider); + generate_mangling_aliases (); + /* All used inline functions must have a definition at this point. */ FOR_EACH_VEC_SAFE_ELT (deferred_fns, i, decl) { diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 71a6e3b..3da81b3 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3512,30 +3512,7 @@ mangle_decl (const tree decl) flag_abi_compat_version, id2); } -#ifdef ASM_OUTPUT_DEF - /* If there's a declaration already using this mangled name, - don't create a compatibility alias that conflicts. */ - if (IDENTIFIER_GLOBAL_VALUE (id2)) - return; - - struct cgraph_node *n = NULL; - if (TREE_CODE (decl) == FUNCTION_DECL - && !(n = cgraph_node::get (decl))) - /* Don't create an alias to an unreferenced function. */ - return; - - tree alias = make_alias_for (decl, id2); - SET_IDENTIFIER_GLOBAL_VALUE (id2, alias); - DECL_IGNORED_P (alias) = 1; - TREE_PUBLIC (alias) = TREE_PUBLIC (decl); - DECL_VISIBILITY (alias) = DECL_VISIBILITY (decl); - if (vague_linkage_p (decl)) - DECL_WEAK (alias) = 1; - if (TREE_CODE (decl) == FUNCTION_DECL) - n->create_same_body_alias (alias, decl); - else - varpool_node::create_extra_name_alias (alias, decl); -#endif + note_mangling_alias (decl, id2); } }