public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Richard Biener <richard.guenther@gmail.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	Alexander Monakov <amonakov@ispras.ru>,
	Uros Bizjak <ubizjak@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [stage1] [PATCH] Make target_clones resolver fn static if possible.
Date: Tue, 17 Mar 2020 17:40:17 +0100	[thread overview]
Message-ID: <afd1f306-fc96-88af-fae1-c75dcff36efa@suse.cz> (raw)
In-Reply-To: <CAFiYyc3B=VvTzL5xcbmbNjiDVmv19vaVSPa4RVOFRqsGDn92aw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 271 bytes --]

On 1/23/20 2:09 PM, Richard Biener wrote:
>   The other thing looks like sth for next stage1?

Hi.

I'm sending the second part for next stage1.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed in next stage1?
Thanks,
Martin

[-- Attachment #2: 0001-Make-target_clones-resolver-fn-static-if-possible.patch --]
[-- Type: text/x-patch, Size: 3507 bytes --]

From 6d2113da263d7a6a0bb0adcf22edb074646f1996 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 16 Jan 2020 10:38:41 +0100
Subject: [PATCH] Make target_clones resolver fn static if possible.

gcc/ChangeLog:

2020-03-17  Martin Liska  <mliska@suse.cz>

	PR target/93274
	* config/i386/i386-features.c (make_resolver_func): Drop
	public flag for resolver.
	* config/rs6000/rs6000.c (make_resolver_func): Add comdat
	group for resolver and drop public flag if possible.

gcc/testsuite/ChangeLog:

2020-03-17  Martin Liska  <mliska@suse.cz>

	PR target/93274
	* gcc.target/i386/pr81213-2.c: New test.
	* gcc.target/i386/pr81213.c: Add additional source.
---
 gcc/config/i386/i386-features.c           |  3 +++
 gcc/config/rs6000/rs6000.c                | 12 ++++++++++++
 gcc/testsuite/gcc.target/i386/pr81213-2.c | 11 +++++++++++
 gcc/testsuite/gcc.target/i386/pr81213.c   |  7 +++++--
 4 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr81213-2.c

diff --git a/gcc/config/i386/i386-features.c b/gcc/config/i386/i386-features.c
index 6919c839605..690e6373c27 100644
--- a/gcc/config/i386/i386-features.c
+++ b/gcc/config/i386/i386-features.c
@@ -2777,6 +2777,9 @@ make_resolver_func (const tree default_decl,
       DECL_COMDAT (decl) = 1;
       make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
     }
+  else
+    TREE_PUBLIC (ifunc_alias_decl) = 0;
+
   /* Build result decl and add to function_decl. */
   t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node);
   DECL_CONTEXT (t) = decl;
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 5798f924472..0911ab019cd 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -23887,6 +23887,18 @@ make_resolver_func (const tree default_decl,
   DECL_INITIAL (decl) = make_node (BLOCK);
   DECL_STATIC_CONSTRUCTOR (decl) = 0;
 
+  if (DECL_COMDAT_GROUP (default_decl)
+      || TREE_PUBLIC (default_decl))
+    {
+      /* In this case, each translation unit with a call to this
+	 versioned function will put out a resolver.  Ensure it
+	 is comdat to keep just one copy.  */
+      DECL_COMDAT (decl) = 1;
+      make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
+    }
+  else
+    TREE_PUBLIC (dispatch_decl) = 0;
+
   /* Build result decl and add to function_decl.  */
   tree t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node);
   DECL_CONTEXT (t) = decl;
diff --git a/gcc/testsuite/gcc.target/i386/pr81213-2.c b/gcc/testsuite/gcc.target/i386/pr81213-2.c
new file mode 100644
index 00000000000..a80622cb184
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr81213-2.c
@@ -0,0 +1,11 @@
+__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
+static int
+foo ()
+{
+  return 2;
+}
+
+int bar()
+{
+  return foo();
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr81213.c b/gcc/testsuite/gcc.target/i386/pr81213.c
index 89c47529861..334838631d0 100644
--- a/gcc/testsuite/gcc.target/i386/pr81213.c
+++ b/gcc/testsuite/gcc.target/i386/pr81213.c
@@ -1,6 +1,9 @@
 /* PR ipa/81214.  */
-/* { dg-do compile } */
+/* { dg-do run } */
 /* { dg-require-ifunc "" } */
+/* { dg-additional-sources "pr81213-2.c" } */
+
+int bar();
 
 __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
 static int
@@ -11,7 +14,7 @@ foo ()
 
 int main()
 {
-  return foo();
+  return foo() + bar();
 }
 
 /* { dg-final { scan-assembler "\t.globl\tfoo" } } */
-- 
2.25.1


  parent reply	other threads:[~2020-03-17 16:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-17 11:09 [PATCH] Make target_clones resolver fn static Martin Liška
2020-01-20 10:34 ` Richard Biener
2020-01-20 13:40   ` H.J. Lu
2020-01-20 13:48     ` Alexander Monakov
2020-01-20 13:49       ` H.J. Lu
2020-01-20 14:23         ` Alexander Monakov
2020-01-20 14:31           ` H.J. Lu
2020-01-20 14:54             ` Alexander Monakov
2020-01-20 14:55               ` H.J. Lu
2020-01-20 14:59                 ` Richard Biener
2020-01-21 13:29                   ` Martin Liška
2020-01-23 13:43                     ` Richard Biener
2020-01-23 13:53                       ` Martin Liška
2020-01-23 14:02                         ` Alexander Monakov
2020-01-27 10:59                           ` Martin Liška
2020-03-17 16:40                       ` Martin Liška [this message]
2020-03-23 15:09                         ` [stage1] [PATCH] Make target_clones resolver fn static if possible Martin Liška
2020-03-24 17:21                           ` Jeff Law
2020-03-26  9:23                           ` Jakub Jelinek
2020-03-26  9:46                             ` Martin Liška
2020-03-26  9:48                               ` Jakub Jelinek
2020-01-26 21:18                     ` [PATCH] Make target_clones resolver fn static Jeff Law
2020-01-27 11:05                       ` 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=afd1f306-fc96-88af-fae1-c75dcff36efa@suse.cz \
    --to=mliska@suse.cz \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=richard.guenther@gmail.com \
    --cc=ubizjak@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).