Hi.

We should not allow target_clones being combined with alias attribute.

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

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-05-16  Martin Liska  <mli...@suse.cz>

        PR lto/90500
        * multiple_target.c (expand_target_clones): Do not allow
        target_clones being used with a symbol that is an alias.

gcc/testsuite/ChangeLog:

2019-05-16  Martin Liska  <mli...@suse.cz>

        PR lto/90500
        * gcc.target/i386/pr90500-1.c: New test.
        * gcc.target/i386/pr90500-2.c: New test.
---
 gcc/multiple_target.c                     | 5 ++++-
 gcc/testsuite/gcc.target/i386/pr90500-1.c | 8 ++++++++
 gcc/testsuite/gcc.target/i386/pr90500-2.c | 7 +++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr90500-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr90500-2.c


diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index 0a87241b251..fa194d416fe 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -356,7 +356,7 @@ expand_target_clones (struct cgraph_node *node, bool definition)
     }
 
   if (node->definition
-      && !tree_versionable_function_p (node->decl))
+      && (node->alias || !tree_versionable_function_p (node->decl)))
     {
       auto_diagnostic_group d;
       error_at (DECL_SOURCE_LOCATION (node->decl),
@@ -365,6 +365,9 @@ expand_target_clones (struct cgraph_node *node, bool definition)
       if (lookup_attribute ("noclone", DECL_ATTRIBUTES (node->decl)))
 	reason = G_("function %q+F can never be copied "
 		    "because it has %<noclone%> attribute");
+      else if (node->alias)
+	reason
+	  = "%<target_clones%> cannot be combined with %<alias%> attribute";
       else
 	reason = copy_forbidden (DECL_STRUCT_FUNCTION (node->decl));
       if (reason)
diff --git a/gcc/testsuite/gcc.target/i386/pr90500-1.c b/gcc/testsuite/gcc.target/i386/pr90500-1.c
new file mode 100644
index 00000000000..7ac6a739c05
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr90500-1.c
@@ -0,0 +1,8 @@
+/* PR middle-end/84723 */
+/* { dg-do compile } */
+/* { dg-require-ifunc } */
+
+__attribute__((target_clones("arch=haswell", "default"))) int __tanh() {}
+__typeof(__tanh) tanhf64 __attribute__((alias("__tanh")))/* { dg-error "clones for .target_clones. attribute cannot be created" } */
+  /* { dg-message "'target_clones' cannot be combined with 'alias' attribute" "" { target *-*-* } .-1 } */
+__attribute__((__copy__(__tanh)));
diff --git a/gcc/testsuite/gcc.target/i386/pr90500-2.c b/gcc/testsuite/gcc.target/i386/pr90500-2.c
new file mode 100644
index 00000000000..0fafb8adb21
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr90500-2.c
@@ -0,0 +1,7 @@
+/* PR middle-end/84723 */
+/* { dg-do compile } */
+/* { dg-require-ifunc } */
+
+__attribute__((target_clones("arch=haswell", "default"))) int __tanh() {}
+__typeof(__tanh) tanhf64 __attribute__((alias("__tanh"),target_clones("arch=haswell", "default"))); /* { dg-error "clones for .target_clones. attribute cannot be created" } */
+  /* { dg-message "'target_clones' cannot be combined with 'alias' attribute" "" { target *-*-* } .-1 } */

Reply via email to