Commit a8b522b4 by Martin Liska Committed by Martin Liska

Introduce TARGET_SUPPORTS_ALIASES

2017-08-11  Martin Liska  <mliska@suse.cz>

	* c-opts.c (c_common_post_options): Replace ASM_OUTPUT_DEF with
	TARGET_SUPPORTS_ALIASES.
2017-08-11  Martin Liska  <mliska@suse.cz>

	* asan.c (asan_protect_global): Replace ASM_OUTPUT_DEF with
	TARGET_SUPPORTS_ALIASES.
	* cgraph.c (cgraph_node::create_same_body_alias): Likewise.
	* ipa-visibility.c (can_replace_by_local_alias): Likewise.
	(optimize_weakref): Likewise.
	* symtab.c (symtab_node::noninterposable_alias): Likewise.
	* varpool.c (varpool_node::create_extra_name_alias): Likewise.
	* defaults.h: Introduce TARGET_SUPPORTS_ALIASES.
2017-08-11  Martin Liska  <mliska@suse.cz>

	* decl2.c (get_tls_init_fn): Replace ASM_OUTPUT_DEF with
	TARGET_SUPPORTS_ALIASES.
	(handle_tls_init): Likewise.
	(note_mangling_alias): Likewise.  Remove ATTRIBUTE_UNUSED for
	both arguments.
	* optimize.c (can_alias_cdtor): Likewise.

From-SVN: r251048
parent 4c71a171
2017-08-11 Martin Liska <mliska@suse.cz> 2017-08-11 Martin Liska <mliska@suse.cz>
* asan.c (asan_protect_global): Replace ASM_OUTPUT_DEF with
TARGET_SUPPORTS_ALIASES.
* cgraph.c (cgraph_node::create_same_body_alias): Likewise.
* ipa-visibility.c (can_replace_by_local_alias): Likewise.
(optimize_weakref): Likewise.
* symtab.c (symtab_node::noninterposable_alias): Likewise.
* varpool.c (varpool_node::create_extra_name_alias): Likewise.
* defaults.h: Introduce TARGET_SUPPORTS_ALIASES.
2017-08-11 Martin Liska <mliska@suse.cz>
PR ipa/81213 PR ipa/81213
* config/i386/i386.c (make_resolver_func): Do complete * config/i386/i386.c (make_resolver_func): Do complete
refactoring of the function. refactoring of the function.
......
...@@ -1665,10 +1665,8 @@ asan_protect_global (tree decl) ...@@ -1665,10 +1665,8 @@ asan_protect_global (tree decl)
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))) if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
return false; return false;
#ifndef ASM_OUTPUT_DEF if (!TARGET_SUPPORTS_ALIASES && asan_needs_local_alias (decl))
if (asan_needs_local_alias (decl))
return false; return false;
#endif
return true; return true;
} }
......
2017-08-11 Martin Liska <mliska@suse.cz>
* c-opts.c (c_common_post_options): Replace ASM_OUTPUT_DEF with
TARGET_SUPPORTS_ALIASES.
2017-08-10 David Malcolm <dmalcolm@redhat.com> 2017-08-10 David Malcolm <dmalcolm@redhat.com>
* c-common.c (c_parse_error): Add rich_location * param, using it * c-common.c (c_parse_error): Add rich_location * param, using it
......
...@@ -957,16 +957,18 @@ c_common_post_options (const char **pfilename) ...@@ -957,16 +957,18 @@ c_common_post_options (const char **pfilename)
if (flag_extern_tls_init) if (flag_extern_tls_init)
{ {
#if !defined (ASM_OUTPUT_DEF) || !SUPPORTS_WEAK if (!TARGET_SUPPORTS_ALIASES || !SUPPORTS_WEAK)
/* Lazy TLS initialization for a variable in another TU requires {
alias and weak reference support. */ /* Lazy TLS initialization for a variable in another TU requires
if (flag_extern_tls_init > 0) alias and weak reference support. */
sorry ("external TLS initialization functions not supported " if (flag_extern_tls_init > 0)
"on this target"); sorry ("external TLS initialization functions not supported "
flag_extern_tls_init = 0; "on this target");
#else
flag_extern_tls_init = 1; flag_extern_tls_init = 0;
#endif }
else
flag_extern_tls_init = 1;
} }
if (num_in_fnames > 1) if (num_in_fnames > 1)
......
...@@ -584,10 +584,11 @@ cgraph_node * ...@@ -584,10 +584,11 @@ cgraph_node *
cgraph_node::create_same_body_alias (tree alias, tree decl) cgraph_node::create_same_body_alias (tree alias, tree decl)
{ {
cgraph_node *n; cgraph_node *n;
#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */ /* If aliases aren't supported by the assembler, fail. */
return NULL; if (!TARGET_SUPPORTS_ALIASES)
#endif return NULL;
/* Langhooks can create same body aliases of symbols not defined. /* Langhooks can create same body aliases of symbols not defined.
Those are useless. Drop them on the floor. */ Those are useless. Drop them on the floor. */
if (symtab->global_info_ready) if (symtab->global_info_ready)
......
2017-08-11 Martin Liska <mliska@suse.cz>
* decl2.c (get_tls_init_fn): Replace ASM_OUTPUT_DEF with
TARGET_SUPPORTS_ALIASES.
(handle_tls_init): Likewise.
(note_mangling_alias): Likewise. Remove ATTRIBUTE_UNUSED for
both arguments.
* optimize.c (can_alias_cdtor): Likewise.
2017-08-11 Jason Merrill <jason@redhat.com> 2017-08-11 Jason Merrill <jason@redhat.com>
PR c++/81671 - nullptr_t template parameter PR c++/81671 - nullptr_t template parameter
......
...@@ -3156,11 +3156,9 @@ get_tls_init_fn (tree var) ...@@ -3156,11 +3156,9 @@ get_tls_init_fn (tree var)
if (!flag_extern_tls_init && DECL_EXTERNAL (var)) if (!flag_extern_tls_init && DECL_EXTERNAL (var))
return NULL_TREE; return NULL_TREE;
#ifdef ASM_OUTPUT_DEF
/* If the variable is internal, or if we can't generate aliases, /* If the variable is internal, or if we can't generate aliases,
call the local init function directly. */ call the local init function directly. */
if (!TREE_PUBLIC (var)) if (!TREE_PUBLIC (var) || !TARGET_SUPPORTS_ALIASES)
#endif
return get_local_tls_init_fn (); return get_local_tls_init_fn ();
tree sname = mangle_tls_init_fn (var); tree sname = mangle_tls_init_fn (var);
...@@ -4241,9 +4239,8 @@ handle_tls_init (void) ...@@ -4241,9 +4239,8 @@ handle_tls_init (void)
tree init = TREE_PURPOSE (vars); tree init = TREE_PURPOSE (vars);
one_static_initialization_or_destruction (var, init, true); one_static_initialization_or_destruction (var, init, true);
#ifdef ASM_OUTPUT_DEF
/* Output init aliases even with -fno-extern-tls-init. */ /* Output init aliases even with -fno-extern-tls-init. */
if (TREE_PUBLIC (var)) if (TARGET_SUPPORTS_ALIASES && TREE_PUBLIC (var))
{ {
tree single_init_fn = get_tls_init_fn (var); tree single_init_fn = get_tls_init_fn (var);
if (single_init_fn == NULL_TREE) if (single_init_fn == NULL_TREE)
...@@ -4253,7 +4250,6 @@ handle_tls_init (void) ...@@ -4253,7 +4250,6 @@ handle_tls_init (void)
(single_init_fn, fn); (single_init_fn, fn);
gcc_assert (alias != NULL); gcc_assert (alias != NULL);
} }
#endif
} }
finish_then_clause (if_stmt); finish_then_clause (if_stmt);
...@@ -4298,17 +4294,18 @@ generate_mangling_alias (tree decl, tree id2) ...@@ -4298,17 +4294,18 @@ generate_mangling_alias (tree decl, tree id2)
implementation. */ implementation. */
void void
note_mangling_alias (tree decl ATTRIBUTE_UNUSED, tree id2 ATTRIBUTE_UNUSED) note_mangling_alias (tree decl, tree id2)
{ {
#ifdef ASM_OUTPUT_DEF if (TARGET_SUPPORTS_ALIASES)
if (!defer_mangling_aliases)
generate_mangling_alias (decl, id2);
else
{ {
vec_safe_push (mangling_aliases, decl); if (!defer_mangling_aliases)
vec_safe_push (mangling_aliases, id2); generate_mangling_alias (decl, id2);
else
{
vec_safe_push (mangling_aliases, decl);
vec_safe_push (mangling_aliases, id2);
}
} }
#endif
} }
/* Emit all mangling aliases that were deferred up to this point. */ /* Emit all mangling aliases that were deferred up to this point. */
......
...@@ -184,10 +184,10 @@ cdtor_comdat_group (tree complete, tree base) ...@@ -184,10 +184,10 @@ cdtor_comdat_group (tree complete, tree base)
static bool static bool
can_alias_cdtor (tree fn) can_alias_cdtor (tree fn)
{ {
#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */ /* If aliases aren't supported by the assembler, fail. */
return false; if (!TARGET_SUPPORTS_ALIASES)
#endif return false;
/* We can't use an alias if there are virtual bases. */ /* We can't use an alias if there are virtual bases. */
if (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fn))) if (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fn)))
return false; return false;
......
...@@ -863,6 +863,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -863,6 +863,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#endif #endif
#endif #endif
/* Decide whether target supports aliases. */
#ifndef TARGET_SUPPORTS_ALIASES
#ifdef ASM_OUTPUT_DEF
#define TARGET_SUPPORTS_ALIASES 1
#else
#define TARGET_SUPPORTS_ALIASES 0
#endif
#endif
/* Select a format to encode pointers in exception handling data. We /* Select a format to encode pointers in exception handling data. We
prefer those that result in fewer dynamic relocations. Assume no prefer those that result in fewer dynamic relocations. Assume no
special support here and encode direct references. */ special support here and encode direct references. */
......
...@@ -339,10 +339,10 @@ varpool_node::externally_visible_p (void) ...@@ -339,10 +339,10 @@ varpool_node::externally_visible_p (void)
static bool static bool
can_replace_by_local_alias (symtab_node *node) can_replace_by_local_alias (symtab_node *node)
{ {
#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported, we can't do replacement. */ /* If aliases aren't supported, we can't do replacement. */
return false; if (!TARGET_SUPPORTS_ALIASES)
#endif return false;
/* Weakrefs have a reason to be non-local. Be sure we do not replace /* Weakrefs have a reason to be non-local. Be sure we do not replace
them. */ them. */
while (node->transparent_alias && node->definition && !node->weakref) while (node->transparent_alias && node->definition && !node->weakref)
...@@ -463,11 +463,6 @@ update_visibility_by_resolution_info (symtab_node * node) ...@@ -463,11 +463,6 @@ update_visibility_by_resolution_info (symtab_node * node)
static void static void
optimize_weakref (symtab_node *node) optimize_weakref (symtab_node *node)
{ {
#ifdef ASM_OUTPUT_DEF
bool aliases_supported = true;
#else
bool aliases_supported = false;
#endif
bool strip_weakref = false; bool strip_weakref = false;
bool static_alias = false; bool static_alias = false;
...@@ -486,8 +481,8 @@ optimize_weakref (symtab_node *node) ...@@ -486,8 +481,8 @@ optimize_weakref (symtab_node *node)
/* If we have definition of weakref's target and we know it binds locally, /* If we have definition of weakref's target and we know it binds locally,
we can turn weakref to static alias. */ we can turn weakref to static alias. */
if (target->definition && decl_binds_to_current_def_p (target->decl) if (TARGET_SUPPORTS_ALIASES
&& aliases_supported) && target->definition && decl_binds_to_current_def_p (target->decl))
strip_weakref = static_alias = true; strip_weakref = static_alias = true;
/* Otherwise we can turn weakref into transparent alias. This transformation /* Otherwise we can turn weakref into transparent alias. This transformation
may break asm statements which directly refers to symbol name and expect may break asm statements which directly refers to symbol name and expect
......
...@@ -1765,10 +1765,10 @@ symtab_node::noninterposable_alias (void) ...@@ -1765,10 +1765,10 @@ symtab_node::noninterposable_alias (void)
(void *)&new_node, true); (void *)&new_node, true);
if (new_node) if (new_node)
return new_node; return new_node;
#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */ /* If aliases aren't supported by the assembler, fail. */
return NULL; if (!TARGET_SUPPORTS_ALIASES)
#endif return NULL;
/* Otherwise create a new one. */ /* Otherwise create a new one. */
new_decl = copy_node (node->decl); new_decl = copy_node (node->decl);
......
...@@ -788,10 +788,10 @@ varpool_node::create_extra_name_alias (tree alias, tree decl) ...@@ -788,10 +788,10 @@ varpool_node::create_extra_name_alias (tree alias, tree decl)
{ {
varpool_node *alias_node; varpool_node *alias_node;
#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */ /* If aliases aren't supported by the assembler, fail. */
return NULL; if (!TARGET_SUPPORTS_ALIASES)
#endif return NULL;
alias_node = varpool_node::create_alias (alias, decl); alias_node = varpool_node::create_alias (alias, decl);
alias_node->cpp_implicit_alias = true; alias_node->cpp_implicit_alias = true;
......
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