This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch][RFC] bail out after front-end errors


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<tree> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]