public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR106816-mv-attributes)] ipa: propagate attributes for target attribute clones
@ 2023-03-31 12:46 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2023-03-31 12:46 UTC (permalink / raw)
  To: gcc-cvs

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" } } */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/marxin/heads/PR106816-mv-attributes)] ipa: propagate attributes for target attribute clones
@ 2023-03-31 11:54 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2023-03-31 11:54 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0a6fa4833bbaa648c225366584f114e47b2c5746

commit 0a6fa4833bbaa648c225366584f114e47b2c5746
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         |  2 ++
 gcc/testsuite/g++.target/i386/pr106816.C | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index c09abf8fc20..5ec9761fdb8 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3379,6 +3379,8 @@ 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);
+      DECL_PURE_P (dispatch_decl) = DECL_PURE_P (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" } } */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/marxin/heads/PR106816-mv-attributes)] ipa: propagate attributes for target attribute clones
@ 2023-03-31 10:18 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2023-03-31 10:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:71310118a0426ae898c0bc20e9dc3b2dfdacd6b8

commit 71310118a0426ae898c0bc20e9dc3b2dfdacd6b8
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         |  3 +++
 gcc/testsuite/g++.target/i386/pr106816.C | 23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index c09abf8fc20..68e44fd2ae4 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3379,6 +3379,9 @@ 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);
+      TREE_READONLY (dispatch_decl) = TREE_READONLY (fn);
+      DECL_PURE_P (dispatch_decl) = DECL_PURE_P (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" } } */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-31 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31 12:46 [gcc(refs/users/marxin/heads/PR106816-mv-attributes)] ipa: propagate attributes for target attribute clones Martin Liska
  -- strict thread matches above, loose matches on Subject: below --
2023-03-31 11:54 Martin Liska
2023-03-31 10:18 Martin Liska

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).