Commit 09c5f835 by Aldy Hernandez Committed by Aldy Hernandez

decl2.c (collect_candidates_for_java_method_aliases): Remove.

	* 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.

From-SVN: r222933
parent 9c330d02
2015-05-08 Aldy Hernandez <aldyh@redhat.com>
* 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.
2015-05-07 Jason Merrill <jason@redhat.com> 2015-05-07 Jason Merrill <jason@redhat.com>
PR c++/59012 PR c++/59012
......
...@@ -3996,20 +3996,17 @@ generate_ctor_and_dtor_functions_for_priority (splay_tree_node n, void * data) ...@@ -3996,20 +3996,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 /* 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 method, and not be confused by PLT entries. If supported, create a
supported, collect and return all the functions for which we should hidden alias for all such methods. */
emit a hidden alias. */
static hash_set<tree> * static void
collect_candidates_for_java_method_aliases (void) build_java_method_aliases (void)
{ {
struct cgraph_node *node;
hash_set<tree> *candidates = NULL;
#ifndef HAVE_GAS_HIDDEN #ifndef HAVE_GAS_HIDDEN
return candidates; return;
#endif #endif
struct cgraph_node *node;
FOR_EACH_FUNCTION (node) FOR_EACH_FUNCTION (node)
{ {
tree fndecl = node->decl; tree fndecl = node->decl;
...@@ -4018,55 +4015,18 @@ collect_candidates_for_java_method_aliases (void) ...@@ -4018,55 +4015,18 @@ collect_candidates_for_java_method_aliases (void)
&& TYPE_FOR_JAVA (DECL_CONTEXT (fndecl)) && TYPE_FOR_JAVA (DECL_CONTEXT (fndecl))
&& TARGET_USE_LOCAL_THUNK_ALIAS_P (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 /* Mangle the name in a predictable way; we need to reference
this from a java compiled object file. */ this from a java compiled object file. */
tree oid, nid, alias; tree oid = DECL_ASSEMBLER_NAME (fndecl);
const char *oname; const char *oname = IDENTIFIER_POINTER (oid);
char *nname;
oid = DECL_ASSEMBLER_NAME (fndecl);
oname = IDENTIFIER_POINTER (oid);
gcc_assert (oname[0] == '_' && oname[1] == 'Z'); gcc_assert (oname[0] == '_' && oname[1] == 'Z');
nname = ACONCAT (("_ZGA", oname+2, NULL)); char *nname = ACONCAT (("_ZGA", oname + 2, NULL));
nid = get_identifier (nname);
alias = make_alias_for (fndecl, nid); tree alias = make_alias_for (fndecl, get_identifier (nname));
TREE_PUBLIC (alias) = 1; TREE_PUBLIC (alias) = 1;
DECL_VISIBILITY (alias) = VISIBILITY_HIDDEN; DECL_VISIBILITY (alias) = VISIBILITY_HIDDEN;
assemble_alias (alias, oid); cgraph_node::create_same_body_alias (alias, fndecl);
} }
} }
} }
...@@ -4399,7 +4359,6 @@ cp_write_global_declarations (void) ...@@ -4399,7 +4359,6 @@ cp_write_global_declarations (void)
unsigned ssdf_count = 0; unsigned ssdf_count = 0;
int retries = 0; int retries = 0;
tree decl; tree decl;
hash_set<tree> *candidates;
locus = input_location; locus = input_location;
at_eof = 1; at_eof = 1;
...@@ -4750,8 +4709,8 @@ cp_write_global_declarations (void) ...@@ -4750,8 +4709,8 @@ cp_write_global_declarations (void)
linkage now. */ linkage now. */
pop_lang_context (); pop_lang_context ();
/* Collect candidates for Java hidden aliases. */ /* Generate Java hidden aliases. */
candidates = collect_candidates_for_java_method_aliases (); build_java_method_aliases ();
timevar_stop (TV_PHASE_DEFERRED); timevar_stop (TV_PHASE_DEFERRED);
timevar_start (TV_PHASE_OPT_GEN); timevar_start (TV_PHASE_OPT_GEN);
...@@ -4791,13 +4750,6 @@ cp_write_global_declarations (void) ...@@ -4791,13 +4750,6 @@ cp_write_global_declarations (void)
perform_deferred_noexcept_checks (); perform_deferred_noexcept_checks ();
/* Generate hidden aliases for Java. */
if (candidates)
{
build_java_method_aliases (candidates);
delete candidates;
}
finish_repo (); finish_repo ();
/* The entire file is now complete. If requested, dump everything /* The entire file is now complete. If requested, dump everything
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment