From: "Martin Liška" <mliska@suse.cz>
To: Yuri Gribov <tetra2005@gmail.com>
Cc: Jan Hubicka <hubicka@ucw.cz>, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH][v2] Introduce TARGET_SUPPORTS_ALIASES
Date: Mon, 31 Jul 2017 11:22:00 -0000 [thread overview]
Message-ID: <92d3a985-f28d-e2dd-3df3-a50130131787@suse.cz> (raw)
In-Reply-To: <CAJOtW+549pfw9aFdRNmqs0ihxKUaD2Gcm=+CCeNmLXVDKCsR7Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 520 bytes --]
On 07/31/2017 11:57 AM, Yuri Gribov wrote:
> On Mon, Jul 31, 2017 at 9:04 AM, Martin Liška <mliska@suse.cz> wrote:
>> Hi.
>>
>> Doing the transformation suggested by Honza.
>>
>> Patch can bootstrap on ppc64le-redhat-linux and x86_64-linux-gnu and survives regression tests.
>> And I also verified that works on hppa2.0w-hp-hpux11.11 (target w/o aliasing support).
>>
>> Ready to be installed?
>
> A nit - you can probly get rid of ATTRIBUTE_UNUSED in note_mangling_alias now.
>
> -Y
>
Sure.
Done in v2.
Martin
[-- Attachment #2: 0001-Introduce-TARGET_SUPPORTS_ALIASES-v2.patch --]
[-- Type: text/x-patch, Size: 9140 bytes --]
From 78ee08b25d22125cb1fa248bac98ef1e84504761 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 25 Jul 2017 13:11:28 +0200
Subject: [PATCH] Introduce TARGET_SUPPORTS_ALIASES
gcc/c-family/ChangeLog:
2017-07-25 Martin Liska <mliska@suse.cz>
* c-opts.c (c_common_post_options): Replace ASM_OUTPUT_DEF with
TARGET_SUPPORTS_ALIASES.
gcc/ChangeLog:
2017-07-25 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.
gcc/cp/ChangeLog:
2017-07-25 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.
---
gcc/asan.c | 4 +---
gcc/c-family/c-opts.c | 22 ++++++++++++----------
gcc/cgraph.c | 7 ++++---
gcc/cp/decl2.c | 25 +++++++++++--------------
gcc/cp/optimize.c | 6 +++---
gcc/defaults.h | 9 +++++++++
gcc/ipa-visibility.c | 15 +++++----------
gcc/symtab.c | 6 +++---
gcc/varpool.c | 6 +++---
9 files changed, 51 insertions(+), 49 deletions(-)
diff --git a/gcc/asan.c b/gcc/asan.c
index 5f9275f6425..d8cb2b52c8b 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1663,10 +1663,8 @@ asan_protect_global (tree decl)
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
return false;
-#ifndef ASM_OUTPUT_DEF
- if (asan_needs_local_alias (decl))
+ if (!TARGET_SUPPORTS_ALIASES && asan_needs_local_alias (decl))
return false;
-#endif
return true;
}
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 1657e7a4390..0b13a188c1b 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -957,16 +957,18 @@ c_common_post_options (const char **pfilename)
if (flag_extern_tls_init)
{
-#if !defined (ASM_OUTPUT_DEF) || !SUPPORTS_WEAK
- /* Lazy TLS initialization for a variable in another TU requires
- alias and weak reference support. */
- if (flag_extern_tls_init > 0)
- sorry ("external TLS initialization functions not supported "
- "on this target");
- flag_extern_tls_init = 0;
-#else
- flag_extern_tls_init = 1;
-#endif
+ if (!TARGET_SUPPORTS_ALIASES || !SUPPORTS_WEAK)
+ {
+ /* Lazy TLS initialization for a variable in another TU requires
+ alias and weak reference support. */
+ if (flag_extern_tls_init > 0)
+ sorry ("external TLS initialization functions not supported "
+ "on this target");
+
+ flag_extern_tls_init = 0;
+ }
+ else
+ flag_extern_tls_init = 1;
}
if (num_in_fnames > 1)
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d7c9ba61795..849989443b1 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -582,10 +582,11 @@ cgraph_node *
cgraph_node::create_same_body_alias (tree alias, tree decl)
{
cgraph_node *n;
-#ifndef ASM_OUTPUT_DEF
+
/* If aliases aren't supported by the assembler, fail. */
- return NULL;
-#endif
+ if (!TARGET_SUPPORTS_ALIASES)
+ return NULL;
+
/* Langhooks can create same body aliases of symbols not defined.
Those are useless. Drop them on the floor. */
if (symtab->global_info_ready)
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 2a52f8ca3e2..29a2e3cf02d 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3156,11 +3156,9 @@ get_tls_init_fn (tree var)
if (!flag_extern_tls_init && DECL_EXTERNAL (var))
return NULL_TREE;
-#ifdef ASM_OUTPUT_DEF
/* If the variable is internal, or if we can't generate aliases,
call the local init function directly. */
- if (!TREE_PUBLIC (var))
-#endif
+ if (!TREE_PUBLIC (var) || !TARGET_SUPPORTS_ALIASES)
return get_local_tls_init_fn ();
tree sname = mangle_tls_init_fn (var);
@@ -4241,9 +4239,8 @@ handle_tls_init (void)
tree init = TREE_PURPOSE (vars);
one_static_initialization_or_destruction (var, init, true);
-#ifdef ASM_OUTPUT_DEF
/* 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);
if (single_init_fn == NULL_TREE)
@@ -4253,7 +4250,6 @@ handle_tls_init (void)
(single_init_fn, fn);
gcc_assert (alias != NULL);
}
-#endif
}
finish_then_clause (if_stmt);
@@ -4298,17 +4294,18 @@ generate_mangling_alias (tree decl, tree id2)
implementation. */
void
-note_mangling_alias (tree decl ATTRIBUTE_UNUSED, tree id2 ATTRIBUTE_UNUSED)
+note_mangling_alias (tree decl, tree id2)
{
-#ifdef ASM_OUTPUT_DEF
- if (!defer_mangling_aliases)
- generate_mangling_alias (decl, id2);
- else
+ if (TARGET_SUPPORTS_ALIASES)
{
- vec_safe_push (mangling_aliases, decl);
- vec_safe_push (mangling_aliases, id2);
+ if (!defer_mangling_aliases)
+ 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. */
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index a1c387092d4..09ffbda7ca8 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -184,10 +184,10 @@ cdtor_comdat_group (tree complete, tree base)
static bool
can_alias_cdtor (tree fn)
{
-#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */
- return false;
-#endif
+ if (!TARGET_SUPPORTS_ALIASES)
+ return false;
+
/* We can't use an alias if there are virtual bases. */
if (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fn)))
return false;
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 7ad92d920f8..072ef6b6d17 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -863,6 +863,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#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
prefer those that result in fewer dynamic relocations. Assume no
special support here and encode direct references. */
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index 3033f20e3f1..825b3fc36e9 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -337,10 +337,10 @@ varpool_node::externally_visible_p (void)
static bool
can_replace_by_local_alias (symtab_node *node)
{
-#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported, we can't do replacement. */
- return false;
-#endif
+ if (!TARGET_SUPPORTS_ALIASES)
+ return false;
+
/* Weakrefs have a reason to be non-local. Be sure we do not replace
them. */
while (node->transparent_alias && node->definition && !node->weakref)
@@ -461,11 +461,6 @@ update_visibility_by_resolution_info (symtab_node * node)
static void
optimize_weakref (symtab_node *node)
{
-#ifdef ASM_OUTPUT_DEF
- bool aliases_supported = true;
-#else
- bool aliases_supported = false;
-#endif
bool strip_weakref = false;
bool static_alias = false;
@@ -484,8 +479,8 @@ optimize_weakref (symtab_node *node)
/* If we have definition of weakref's target and we know it binds locally,
we can turn weakref to static alias. */
- if (target->definition && decl_binds_to_current_def_p (target->decl)
- && aliases_supported)
+ if (TARGET_SUPPORTS_ALIASES
+ && target->definition && decl_binds_to_current_def_p (target->decl))
strip_weakref = static_alias = true;
/* Otherwise we can turn weakref into transparent alias. This transformation
may break asm statements which directly refers to symbol name and expect
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 0145910023f..1affc1dce1d 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -1763,10 +1763,10 @@ symtab_node::noninterposable_alias (void)
(void *)&new_node, true);
if (new_node)
return new_node;
-#ifndef ASM_OUTPUT_DEF
+
/* If aliases aren't supported by the assembler, fail. */
- return NULL;
-#endif
+ if (!TARGET_SUPPORTS_ALIASES)
+ return NULL;
/* Otherwise create a new one. */
new_decl = copy_node (node->decl);
diff --git a/gcc/varpool.c b/gcc/varpool.c
index ab59c80406b..db3dcee1af8 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -786,10 +786,10 @@ varpool_node::create_extra_name_alias (tree alias, tree decl)
{
varpool_node *alias_node;
-#ifndef ASM_OUTPUT_DEF
/* If aliases aren't supported by the assembler, fail. */
- return NULL;
-#endif
+ if (!TARGET_SUPPORTS_ALIASES)
+ return NULL;
+
alias_node = varpool_node::create_alias (alias, decl);
alias_node->cpp_implicit_alias = true;
--
2.13.3
next prev parent reply other threads:[~2017-07-31 11:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 7:22 [PATCHv2][PING^2][PR 56727] Bypass PLT for recursive calls Yuri Gribov
2017-07-17 9:27 ` Jan Hubicka
2017-07-18 8:27 ` Yuri Gribov
2017-07-24 12:52 ` [PATCH] Fix wrong condition in ipa-visibility.c (PR ipa/81520) Martin Liška
2017-07-24 14:06 ` Jan Hubicka
2017-07-31 8:04 ` [PATCH] Introduce TARGET_SUPPORTS_ALIASES Martin Liška
2017-07-31 9:58 ` Yuri Gribov
2017-07-31 11:22 ` Martin Liška [this message]
2017-08-10 13:49 ` [PATCH][v2] " Jan Hubicka
2023-09-08 12:02 ` More '#ifdef ASM_OUTPUT_DEF' -> 'if (TARGET_SUPPORTS_ALIASES)' etc. (was: [PATCH][v2] Introduce TARGET_SUPPORTS_ALIASES) Thomas Schwinge
2023-09-19 8:47 ` [PING] " Thomas Schwinge
2023-10-25 8:38 ` [PING^2] " Thomas Schwinge
2023-10-25 16:19 ` [PING^2] More '#ifdef ASM_OUTPUT_DEF' -> 'if (TARGET_SUPPORTS_ALIASES)' etc Jeff Law
2017-07-25 4:20 ` [PATCH] Fix wrong condition in ipa-visibility.c (PR ipa/81520) Yuri Gribov
2017-08-02 9:47 ` [PATCHv2][PING^2][PR 56727] Bypass PLT for recursive calls Jan Hubicka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=92d3a985-f28d-e2dd-3df3-a50130131787@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=tetra2005@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).