From patchwork Sat Dec 20 04:49:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 423035 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 8E78014009B for ; Sat, 20 Dec 2014 15:50:00 +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:references :in-reply-to:content-type; q=dns; s=default; b=D+Xx1gbPs+28MPsKq 67H8OR43aoAWNf7YvqplKn3W29sXJi5EcXTjZKFJ54MoIUYjr955sxETy2ETvi5P hz9XTECSX1t1srpQl71M5l+xrcQEhBw9nO31v/A5iWjuukznUIbDrfzdsw8D8mR2 dtBgo0ICnb/Y0FsPbseEI6Fag0= 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:references :in-reply-to:content-type; s=default; bh=AI57tn/GkQ8cntYcpb56f5X ZBgQ=; b=nJBKeERyo9EVVsgzb7neLGBVY1e66kLWRwKndqFI/uOkPfhx27/J4US Ey4oCIJXWTbfyXxaToPLfMfb2rLxPp6Tz+A8vQE+6zfS49+qSahU3iY773qwDNfn 0WJu+gDn8baLuGg0ytR4YCDMXys3HmkyiD3tZ042dUg8n7izjF5w= Received: (qmail 26812 invoked by alias); 20 Dec 2014 04:49:50 -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 26800 invoked by uid 89); 20 Dec 2014 04:49:49 -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; Sat, 20 Dec 2014 04:49:47 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBK4njD9017437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Dec 2014 23:49:45 -0500 Received: from reynosa.quesejoda.com (vpn-54-203.rdu2.redhat.com [10.10.54.203]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBK4nhKC014278; Fri, 19 Dec 2014 23:49:44 -0500 Message-ID: <5494FFE6.6010802@redhat.com> Date: Fri, 19 Dec 2014 20:49:42 -0800 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: Jason Merrill , Jan Hubicka CC: Richard Biener , gcc-patches Subject: Re: [debug-early] reuse variable DIEs and fix their context References: <5409220E.6070100@redhat.com> <540E4337.70006@redhat.com> <5412438A.6030305@redhat.com> <54130E15.9030809@redhat.com> <549329C1.9050304@redhat.com> <20141219185315.GC27681@kam.mff.cuni.cz> <20141219185800.GD27681@kam.mff.cuni.cz> <549475F8.2090502@redhat.com> <54947690.5050708@redhat.com> In-Reply-To: <54947690.5050708@redhat.com> On 12/19/14 11:03, Jason Merrill wrote: First of all, my bad Richard. I vaguely remember you mentioning something about Java, but it was early enough in the project that I had no idea what you were talking about. Thanks for your patience. > It looks like java aliases are still using assemble_alias directly; > switching to using same_body aliases like thunks and such should handle > the issue. Ah, I see. Attached is a patch against _MAINLINE_ that fixes the issue I am seeing, without introducing any regressions. Would it be crazy to ask for permission to commit this into mainline, and avoiding dragging this along on the branch? If not, I have a similar patch for the branch I can commit there. Let me know. Thanks for everyone's input. Aldy commit 6ebeefeb10f3396a2dc2b28802f2f432a04e757b Author: Aldy Hernandez Date: Fri Dec 19 20:43:16 2014 -0800 * decl2.c (collect_candidates_for_java_method_aliases): Remove. (build_java_method_aliases): Adapt to use create_same_body_alias instead of assemble_alias. Move variable declarations to definition and tidy up. (cp_write_global_declarations): Call build_java_method_aliases instead of collecting candidates first. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 69201b0..13d09bb 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3972,20 +3972,17 @@ generate_ctor_and_dtor_functions_for_priority (splay_tree_node n, void * data) } /* Java requires that we be able to reference a local address for a - method, and not be confused by PLT entries. If hidden aliases are - supported, collect and return all the functions for which we should - emit a hidden alias. */ + method, and not be confused by PLT entries. If supported, create a + hidden alias for all such methods. */ -static hash_set * -collect_candidates_for_java_method_aliases (void) +static void +build_java_method_aliases (void) { - struct cgraph_node *node; - hash_set *candidates = NULL; - #ifndef HAVE_GAS_HIDDEN - return candidates; + return; #endif + struct cgraph_node *node; FOR_EACH_FUNCTION (node) { tree fndecl = node->decl; @@ -3994,55 +3991,18 @@ collect_candidates_for_java_method_aliases (void) && TYPE_FOR_JAVA (DECL_CONTEXT (fndecl)) && TARGET_USE_LOCAL_THUNK_ALIAS_P (fndecl)) { - if (candidates == NULL) - candidates = new hash_set; - candidates->add (fndecl); - } - } - - return candidates; -} - - -/* Java requires that we be able to reference a local address for a - method, and not be confused by PLT entries. If hidden aliases are - supported, emit one for each java function that we've emitted. - CANDIDATES is the set of FUNCTION_DECLs that were gathered - by collect_candidates_for_java_method_aliases. */ - -static void -build_java_method_aliases (hash_set *candidates) -{ - struct cgraph_node *node; - -#ifndef HAVE_GAS_HIDDEN - return; -#endif - - FOR_EACH_FUNCTION (node) - { - tree fndecl = node->decl; - - if (TREE_ASM_WRITTEN (fndecl) - && candidates->contains (fndecl)) - { /* Mangle the name in a predictable way; we need to reference this from a java compiled object file. */ - tree oid, nid, alias; - const char *oname; - char *nname; - - oid = DECL_ASSEMBLER_NAME (fndecl); - oname = IDENTIFIER_POINTER (oid); + tree oid = DECL_ASSEMBLER_NAME (fndecl); + const char *oname = IDENTIFIER_POINTER (oid); gcc_assert (oname[0] == '_' && oname[1] == 'Z'); - nname = ACONCAT (("_ZGA", oname+2, NULL)); - nid = get_identifier (nname); + char *nname = ACONCAT (("_ZGA", oname + 2, NULL)); - alias = make_alias_for (fndecl, nid); + tree alias = make_alias_for (fndecl, get_identifier (nname)); TREE_PUBLIC (alias) = 1; DECL_VISIBILITY (alias) = VISIBILITY_HIDDEN; - assemble_alias (alias, oid); + cgraph_node::create_same_body_alias (alias, fndecl); } } } @@ -4375,7 +4335,6 @@ cp_write_global_declarations (void) unsigned ssdf_count = 0; int retries = 0; tree decl; - hash_set *candidates; locus = input_location; at_eof = 1; @@ -4726,8 +4685,8 @@ cp_write_global_declarations (void) linkage now. */ pop_lang_context (); - /* Collect candidates for Java hidden aliases. */ - candidates = collect_candidates_for_java_method_aliases (); + /* Generate Java hidden aliases. */ + build_java_method_aliases (); timevar_stop (TV_PHASE_DEFERRED); timevar_start (TV_PHASE_OPT_GEN); @@ -4767,13 +4726,6 @@ cp_write_global_declarations (void) perform_deferred_noexcept_checks (); - /* Generate hidden aliases for Java. */ - if (candidates) - { - build_java_method_aliases (candidates); - delete candidates; - } - finish_repo (); /* The entire file is now complete. If requested, dump everything