Hi.
The patch propagates noreturn attribute for MV functions. However, I noticed
we've got the following ICE when we do the same for TREE_READONLY attr:
$ cat tc.c
double bar() __attribute__((target_clones("avx,avx2,avx512f,default")));
double bar() { return 1.2f; }
int foo() { return (int)bar(); }
$ ./xgcc -B. ~/Programming/testcases/tc.c -O3 -c -fprofile-generate
/home/marxin/Programming/testcases/tc.c: In function ‘foo’:
/home/marxin/Programming/testcases/tc.c:4:5: error: virtual definition of
statement not up to date
4 | int foo() { return (int)bar(); }
| ^~~
_1 = bar ();
during GIMPLE pass: fixup_cfg
Thus my ambition is to propagate only noreturn attr.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
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.to...@gmail.com>
---
gcc/config/i386/i386-features.cc | 1 +
gcc/testsuite/g++.target/i386/pr106816.C | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 gcc/testsuite/g++.target/i386/pr106816.C
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" } } */
--
2.40.0