[debug-early] reuse variable DIEs and fix their context
diff mbox

Message ID 5494FFE6.6010802@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Dec. 20, 2014, 4:49 a.m. UTC
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 <aldyh@redhat.com>
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.

Comments

Richard Biener Jan. 8, 2015, 12:24 p.m. UTC | #1
On Sat, Dec 20, 2014 at 5:49 AM, Aldy Hernandez <aldyh@redhat.com> wrote:
> 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.

Well, I think it's a bit late now (but only affects Java, so...).  Jasons call.

> 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 fixing this!
Richard.

> Thanks for everyone's input.
> Aldy

Patch
diff mbox

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<tree> *
-collect_candidates_for_java_method_aliases (void)
+static void
+build_java_method_aliases (void)
 {
-  struct cgraph_node *node;
-  hash_set<tree> *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<tree>;
-	  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<tree> *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<tree> *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