public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/PR106816-mv-attributes)] ipa: propagate attributes for target attribute clones
Date: Fri, 31 Mar 2023 12:46:45 +0000 (GMT)	[thread overview]
Message-ID: <20230331124645.CC13E385800A@sourceware.org> (raw)

https://gcc.gnu.org/g:816b951f2ae3f81485597170f83ce15e70a27c35

commit 816b951f2ae3f81485597170f83ce15e70a27c35
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Mar 31 12:16:34 2023 +0200

    ipa: propagate attributes for target attribute clones
    
            PR ipa/106816
    
    gcc/ChangeLog:
    
            * config/i386/i386-features.cc (ix86_get_function_versions_dispatcher):
            Propagate function attributes for clones.
    
    gcc/testsuite/ChangeLog:
    
            * g++.target/i386/pr106816.C: New test.
    
    Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>

Diff:
---
 gcc/config/i386/i386-features.cc         |  1 +
 gcc/testsuite/g++.target/i386/pr106816.C | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index c09abf8fc20..f2b0d59a73c 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3379,6 +3379,7 @@ ix86_get_function_versions_dispatcher (void *decl)
       /* Right now, the dispatching is done via ifunc.  */
       dispatch_decl = make_dispatcher_decl (default_node->decl);
       TREE_NOTHROW (dispatch_decl) = TREE_NOTHROW (fn);
+      TREE_THIS_VOLATILE (dispatch_decl) = TREE_THIS_VOLATILE (fn);
 
       dispatcher_node = cgraph_node::get_create (dispatch_decl);
       gcc_assert (dispatcher_node != NULL);
diff --git a/gcc/testsuite/g++.target/i386/pr106816.C b/gcc/testsuite/g++.target/i386/pr106816.C
new file mode 100644
index 00000000000..0f5cc1f13dd
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr106816.C
@@ -0,0 +1,23 @@
+// PR ipa/106816
+
+// { dg-do compile }
+// { dg-require-ifunc "" }
+// { dg-options "-O2 -fdump-tree-optimized" }
+
+__attribute__((noreturn, target("default"))) void f()
+{
+  for (;;) {}
+}
+
+__attribute__((noreturn, target("sse4.2,bmi"))) void f()
+{
+  for (;;) {}
+}
+
+int main()
+{
+  f();
+  return 12345;
+}
+
+/* { dg-final { scan-tree-dump-not "12345" "optimized" } } */

             reply	other threads:[~2023-03-31 12:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31 12:46 Martin Liska [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-03-31 11:54 Martin Liska
2023-03-31 10:18 Martin Liska

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=20230331124645.CC13E385800A@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).