From: Jan Hubicka <hubicka@ucw.cz>
To: Martin Li?ka <mliska@suse.cz>
Cc: gcc-patches@gcc.gnu.org, Michael Meissner <meissner@linux.vnet.ibm.com>
Subject: Re: [PATCH] Fix removal of ifunc (PR ipa/81214).
Date: Fri, 30 Jun 2017 12:38:00 -0000 [thread overview]
Message-ID: <20170630123821.GE25586@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <aeaac298-912a-9618-eaa4-7d082619a194@suse.cz>
> Hello.
>
> Following patch fixes the issue where we do not emit ifunc and resolver
> for function that are not called in a compilation unit or and not
> referenced.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> i386.exp tests work on x86_64-linux-gnu.
OK,
Honza
>
> Ready to be installed?
> Martin
>
> gcc/testsuite/ChangeLog:
>
> 2017-06-29 Martin Liska <mliska@suse.cz>
>
> PR ipa/81214
> * gcc.target/i386/pr81214.c: New test.
>
> gcc/ChangeLog:
>
> 2017-06-29 Martin Liska <mliska@suse.cz>
>
> PR ipa/81214
> * multiple_target.c (create_dispatcher_calls): Make ifunc
> also for function that don't have calls or are not referenced.
> ---
> gcc/multiple_target.c | 64 ++++++++++++++++-----------------
> gcc/testsuite/gcc.target/i386/pr81214.c | 14 ++++++++
> 2 files changed, 46 insertions(+), 32 deletions(-)
> create mode 100644 gcc/testsuite/gcc.target/i386/pr81214.c
>
>
> diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
> index eddc7d3744b..0d7cc3a2939 100644
> --- a/gcc/multiple_target.c
> +++ b/gcc/multiple_target.c
> @@ -68,6 +68,38 @@ create_dispatcher_calls (struct cgraph_node *node)
> || !is_function_default_version (node->decl))
> return;
>
> + if (!targetm.has_ifunc_p ())
> + {
> + error_at (DECL_SOURCE_LOCATION (node->decl),
> + "the call requires ifunc, which is not"
> + " supported by this target");
> + return;
> + }
> + else if (!targetm.get_function_versions_dispatcher)
> + {
> + error_at (DECL_SOURCE_LOCATION (node->decl),
> + "target does not support function version dispatcher");
> + return;
> + }
> +
> + tree idecl = targetm.get_function_versions_dispatcher (node->decl);
> + if (!idecl)
> + {
> + error_at (DECL_SOURCE_LOCATION (node->decl),
> + "default target_clones attribute was not set");
> + return;
> + }
> +
> + cgraph_node *inode = cgraph_node::get (idecl);
> + gcc_assert (inode);
> + tree resolver_decl = targetm.generate_version_dispatcher_body (inode);
> +
> + /* Update aliases. */
> + inode->alias = true;
> + inode->alias_target = resolver_decl;
> + if (!inode->analyzed)
> + inode->resolve_alias (cgraph_node::get (resolver_decl));
> +
> auto_vec<cgraph_edge *> edges_to_redirect;
> auto_vec<ipa_ref *> references_to_redirect;
>
> @@ -80,38 +112,6 @@ create_dispatcher_calls (struct cgraph_node *node)
>
> if (!edges_to_redirect.is_empty () || !references_to_redirect.is_empty ())
> {
> - if (!targetm.has_ifunc_p ())
> - {
> - error_at (DECL_SOURCE_LOCATION (node->decl),
> - "the call requires ifunc, which is not"
> - " supported by this target");
> - return;
> - }
> - else if (!targetm.get_function_versions_dispatcher)
> - {
> - error_at (DECL_SOURCE_LOCATION (node->decl),
> - "target does not support function version dispatcher");
> - return;
> - }
> -
> - tree idecl = targetm.get_function_versions_dispatcher (node->decl);
> - if (!idecl)
> - {
> - error_at (DECL_SOURCE_LOCATION (node->decl),
> - "default target_clones attribute was not set");
> - return;
> - }
> -
> - cgraph_node *inode = cgraph_node::get (idecl);
> - gcc_assert (inode);
> - tree resolver_decl = targetm.generate_version_dispatcher_body (inode);
> -
> - /* Update aliases. */
> - inode->alias = true;
> - inode->alias_target = resolver_decl;
> - if (!inode->analyzed)
> - inode->resolve_alias (cgraph_node::get (resolver_decl));
> -
> /* Redirect edges. */
> unsigned i;
> cgraph_edge *e;
> diff --git a/gcc/testsuite/gcc.target/i386/pr81214.c b/gcc/testsuite/gcc.target/i386/pr81214.c
> new file mode 100644
> index 00000000000..2584decdb3c
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr81214.c
> @@ -0,0 +1,14 @@
> +/* PR ipa/81214. */
> +/* { dg-do compile } */
> +/* { dg-require-ifunc "" } */
> +
> +__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
> +int
> +foo ()
> +{
> + return -2;
> +}
> +
> +/* { dg-final { scan-assembler "\t.globl\tfoo" } } */
> +/* { dg-final { scan-assembler "foo.resolver:" } } */
> +/* { dg-final { scan-assembler "foo, @gnu_indirect_function" } } */
>
next prev parent reply other threads:[~2017-06-30 12:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 8:49 Martin Liška
2017-06-30 12:38 ` Jan Hubicka [this message]
2017-07-03 13:44 ` Rainer Orth
2017-07-04 7:42 ` Martin Liška
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=20170630123821.GE25586@atrey.karlin.mff.cuni.cz \
--to=hubicka@ucw.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=meissner@linux.vnet.ibm.com \
--cc=mliska@suse.cz \
/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).