From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24820 invoked by alias); 28 Dec 2012 17:36:12 -0000 Received: (qmail 24742 invoked by uid 22791); 28 Dec 2012 17:36:11 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_FN,TW_IB X-Spam-Check-By: sourceware.org Received: from mail-vb0-f48.google.com (HELO mail-vb0-f48.google.com) (209.85.212.48) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Dec 2012 17:36:05 +0000 Received: by mail-vb0-f48.google.com with SMTP id fc21so10927605vbb.35 for ; Fri, 28 Dec 2012 09:36:04 -0800 (PST) Received: by 10.52.98.73 with SMTP id eg9mr45534650vdb.18.1356716164377; Fri, 28 Dec 2012 09:36:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.58.215.38 with HTTP; Fri, 28 Dec 2012 09:35:23 -0800 (PST) In-Reply-To: References: From: Steven Bosscher Date: Fri, 28 Dec 2012 17:36:00 -0000 Message-ID: Subject: Re: [patch][RFC] bail out after front-end errors To: Richard Guenther , Jan Hubicha Cc: GCC Mailing List , GCC Patches list Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg01453.txt.bz2 On Tue, Mar 27, 2012 at 10:59 AM, Richard Guenther wrote: > On Tue, Mar 27, 2012 at 10:32 AM, Steven Bosscher wrote: >> On Tue, Mar 27, 2012 at 9:17 AM, Richard Guenther wrote: >>> It would be nice to finally move >>> the call to cgraph_finalize_compilation_unit to the middle-end ... >>> (warning, if you try that you run into an issue with the Java frontend ... :/) >> >> Do you remember what issues that causes? I'm running into a great >> number of issues there already with some varasm fixes (basically just >> cleanups for the tree-ssa and unit-at-a-time era we're supposed to >> live in - except Java). > > I think it was the > > /* Generate hidden aliases for Java. */ > if (candidates) > { > build_java_method_aliases (candidates); > pointer_set_destroy (candidates); > } > > hunk in cp_write_global_declarations that does not work when run > before cgraph_finalize_compilation_unit > (I simply tried to move that call out of, and after calling the > langhook). So the problem materialized when > building libjava I think. Hello, Coming back to this issue... Attached patch is an attempt to resolve this part of the finalize_compilation_unit problem. Instead of emitting aliases with assemble_alias after finalize_compilation_unit, this patch uses cgraph_same_body_alias before it. Bootstrapped&tested on powerpc64-unknown-linux-gnu. Richi, Honza, does this make sense? Ciao! Steven cp/ * decl2.c (collect_candidates_for_java_method_aliases): Remove. (build_java_method_aliases): Rewrite to emit the aliases via the cgraphunit machinery. (cp_write_global_declarations): Adjust for abovementioned changes. Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 194725) +++ cp/decl2.c (working copy) stevenb@stevenb-laptop:~$ cat devel/java_method_aliases.diff cp/ * decl2.c (collect_candidates_for_java_method_aliases): Remove. (build_java_method_aliases): Rewrite to emit the aliases via the cgraphunit machinery. (cp_write_global_declarations): Adjust for abovementioned changes. Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 194725) +++ cp/decl2.c (working copy) @@ -3615,79 +3615,53 @@ generate_ctor_and_dtor_functions_for_priority (spl /* 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 + supported, emit one for each java function that we've emitted. emit a hidden alias. */ -static struct pointer_set_t * -collect_candidates_for_java_method_aliases (void) +static void +build_java_method_aliases (void) { +#ifdef HAVE_GAS_HIDDEN struct cgraph_node *node; - struct pointer_set_t *candidates = NULL; + tree fndecl; + vec candidates = vNULL; + unsigned int ix; -#ifndef HAVE_GAS_HIDDEN - return candidates; -#endif - + /* First collect all candidates. We cannot create the aliases + in place, it confuses the FOR_EACH_FUNCTION iterator. */ FOR_EACH_FUNCTION (node) { - tree fndecl = node->symbol.decl; - + fndecl = node->symbol.decl; if (DECL_CONTEXT (fndecl) && TYPE_P (DECL_CONTEXT (fndecl)) && TYPE_FOR_JAVA (DECL_CONTEXT (fndecl)) && TARGET_USE_LOCAL_THUNK_ALIAS_P (fndecl)) - { - if (candidates == NULL) - candidates = pointer_set_create (); - pointer_set_insert (candidates, fndecl); - } + candidates.safe_push (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 (struct pointer_set_t *candidates) -{ - struct cgraph_node *node; - -#ifndef HAVE_GAS_HIDDEN - return; -#endif - - FOR_EACH_FUNCTION (node) + /* Now add the aliases for the candidates collected above. + Mangle the name in a predictable way; we need to reference + this from a java compiled object file. */ + FOR_EACH_VEC_ELT (candidates, ix, fndecl) { - tree fndecl = node->symbol.decl; + tree oid, nid, alias; + const char *oname; + char *nname; - if (TREE_ASM_WRITTEN (fndecl) - && pointer_set_contains (candidates, 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); + gcc_assert (oname[0] == '_' && oname[1] == 'Z'); + nname = ACONCAT (("_ZGA", oname+2, NULL)); + nid = get_identifier (nname); - oid = DECL_ASSEMBLER_NAME (fndecl); - oname = IDENTIFIER_POINTER (oid); - gcc_assert (oname[0] == '_' && oname[1] == 'Z'); - nname = ACONCAT (("_ZGA", oname+2, NULL)); - nid = get_identifier (nname); - - alias = make_alias_for (fndecl, nid); - TREE_PUBLIC (alias) = 1; - DECL_VISIBILITY (alias) = VISIBILITY_HIDDEN; - - assemble_alias (alias, oid); - } + alias = make_alias_for (fndecl, nid); + TREE_PUBLIC (alias) = 1; + DECL_VISIBILITY (alias) = VISIBILITY_HIDDEN; + node = cgraph_same_body_alias (NULL, alias, fndecl); + gcc_assert (node); } +#endif + return; } /* Return C++ property of T, based on given operation OP. */ @@ -3933,7 +3907,6 @@ cp_write_global_declarations (void) unsigned ssdf_count = 0; int retries = 0; tree decl; - struct pointer_set_t *candidates; locus = input_location; at_eof = 1; @@ -4282,8 +4255,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 hidden aliases for Java. */ + build_java_method_aliases (); timevar_stop (TV_PHASE_DEFERRED); timevar_start (TV_PHASE_OPT_GEN); @@ -4306,13 +4279,6 @@ cp_write_global_declarations (void) perform_deferred_noexcept_checks (); - /* Generate hidden aliases for Java. */ - if (candidates) - { - build_java_method_aliases (candidates); - pointer_set_destroy (candidates); - } - finish_repo (); /* The entire file is now complete. If requested, dump everything