Fix removal of ifunc (PR ipa/81214).
authorMartin Liska <mliska@suse.cz>
Fri, 30 Jun 2017 13:51:19 +0000 (15:51 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 30 Jun 2017 13:51:19 +0000 (13:51 +0000)
2017-06-30  Martin Liska  <mliska@suse.cz>

PR ipa/81214
* gcc.target/i386/pr81214.c: New test.
2017-06-30  Martin Liska  <mliska@suse.cz>

PR ipa/81214
* multiple_target.c (create_dispatcher_calls): Make ifunc
also for function that don't have calls or are not referenced.

From-SVN: r249840

gcc/ChangeLog
gcc/multiple_target.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr81214.c [new file with mode: 0644]

index a898fd40917734bdabf1d827174de823d8b9ca24..d6a709b617e69dce194ca4b7a858b2d4ed8cd9ba 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-30  Martin Liska  <mliska@suse.cz>
+
+       PR ipa/81214
+       * multiple_target.c (create_dispatcher_calls): Make ifunc
+       also for function that don't have calls or are not referenced.
+
 2017-06-30  Richard Biener  <rguenther@suse.de>
 
        * tree-vect-slp.c (vect_slp_analyze_node_operations): Only
index eddc7d3744b7a805495a30e24c81dc2ca0018813..0d7cc3a2939193f5c1a23f02f01030059d4e5f98 100644 (file)
@@ -68,6 +68,38 @@ create_dispatcher_calls (struct cgraph_node *node)
       || !is_function_default_version (node->decl))
     return;
 
+  if (!targetm.has_ifunc_p ())
+    {
+      error_at (DECL_SOURCE_LOCATION (node->decl),
+               "the call requires ifunc, which is not"
+               " supported by this target");
+      return;
+    }
+  else if (!targetm.get_function_versions_dispatcher)
+    {
+      error_at (DECL_SOURCE_LOCATION (node->decl),
+               "target does not support function version dispatcher");
+      return;
+    }
+
+  tree idecl = targetm.get_function_versions_dispatcher (node->decl);
+  if (!idecl)
+    {
+      error_at (DECL_SOURCE_LOCATION (node->decl),
+               "default target_clones attribute was not set");
+      return;
+    }
+
+  cgraph_node *inode = cgraph_node::get (idecl);
+  gcc_assert (inode);
+  tree resolver_decl = targetm.generate_version_dispatcher_body (inode);
+
+  /* Update aliases.  */
+  inode->alias = true;
+  inode->alias_target = resolver_decl;
+  if (!inode->analyzed)
+    inode->resolve_alias (cgraph_node::get (resolver_decl));
+
   auto_vec<cgraph_edge *> edges_to_redirect;
   auto_vec<ipa_ref *> references_to_redirect;
 
@@ -80,38 +112,6 @@ create_dispatcher_calls (struct cgraph_node *node)
 
   if (!edges_to_redirect.is_empty () || !references_to_redirect.is_empty ())
     {
-      if (!targetm.has_ifunc_p ())
-       {
-         error_at (DECL_SOURCE_LOCATION (node->decl),
-                   "the call requires ifunc, which is not"
-                   " supported by this target");
-         return;
-       }
-      else if (!targetm.get_function_versions_dispatcher)
-       {
-         error_at (DECL_SOURCE_LOCATION (node->decl),
-                   "target does not support function version dispatcher");
-         return;
-       }
-
-      tree idecl = targetm.get_function_versions_dispatcher (node->decl);
-      if (!idecl)
-       {
-         error_at (DECL_SOURCE_LOCATION (node->decl),
-                   "default target_clones attribute was not set");
-         return;
-       }
-
-      cgraph_node *inode = cgraph_node::get (idecl);
-      gcc_assert (inode);
-      tree resolver_decl = targetm.generate_version_dispatcher_body (inode);
-
-      /* Update aliases.  */
-      inode->alias = true;
-      inode->alias_target = resolver_decl;
-      if (!inode->analyzed)
-       inode->resolve_alias (cgraph_node::get (resolver_decl));
-
       /* Redirect edges.  */
       unsigned i;
       cgraph_edge *e;
index 30c087edb09ed02cbd54d07c58fc577d63db28c9..4d8372047ac59ed860f5cff6918f3deb8d7e2028 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-30  Martin Liska  <mliska@suse.cz>
+
+       PR ipa/81214
+       * gcc.target/i386/pr81214.c: New test.
+
 2017-06-30  Nathan Sidwell  <nathan@acm.org>
 
        * g++.dg/plugin/decl-plugin-test.C: Expect special ctor name.
diff --git a/gcc/testsuite/gcc.target/i386/pr81214.c b/gcc/testsuite/gcc.target/i386/pr81214.c
new file mode 100644 (file)
index 0000000..2584dec
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR ipa/81214.  */
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+
+__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
+int
+foo ()
+{
+  return -2;
+}
+
+/* { dg-final { scan-assembler "\t.globl\tfoo" } } */
+/* { dg-final { scan-assembler "foo.resolver:" } } */
+/* { dg-final { scan-assembler "foo, @gnu_indirect_function" } } */