summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-11 08:10:42 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-11 08:10:42 +0000
commitf4b56643a351a482689a8084946768818fbf1a56 (patch)
treedc6950b1cffedac5672fb2c607bb404862c93de8
parentf283da529cee4915581bdfd10a0213886d54142d (diff)
downloadgcc-f4b56643a351a482689a8084946768818fbf1a56.tar.gz
Fix ifunc and resolver (PR ipa/81213).
2017-08-11 Martin Liska <mliska@suse.cz> PR ipa/81213 * config/i386/i386.c (make_resolver_func): Do complete refactoring of the function. 2017-08-11 Martin Liska <mliska@suse.cz> PR ipa/81213 * gcc.target/i386/pr81213.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251047 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/i386/i386.c37
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/i386/pr81213.c19
4 files changed, 48 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c73897fd9cd..48e94f7754e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-08-11 Martin Liska <mliska@suse.cz>
+
+ PR ipa/81213
+ * config/i386/i386.c (make_resolver_func): Do complete
+ refactoring of the function.
+
2017-08-10 Uros Bizjak <ubizjak@gmail.com>
PR target/81708
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1135372be2a..b04321a8d40 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -33913,30 +33913,30 @@ ix86_get_function_versions_dispatcher (void *decl)
}
/* Make the resolver function decl to dispatch the versions of
- a multi-versioned function, DEFAULT_DECL. Create an
+ a multi-versioned function, DEFAULT_DECL. IFUNC_ALIAS_DECL is
+ ifunc alias that will point to the created resolver. Create an
empty basic block in the resolver and store the pointer in
EMPTY_BB. Return the decl of the resolver function. */
static tree
make_resolver_func (const tree default_decl,
- const tree dispatch_decl,
+ const tree ifunc_alias_decl,
basic_block *empty_bb)
{
char *resolver_name;
tree decl, type, decl_name, t;
- bool is_uniq = false;
/* IFUNC's have to be globally visible. So, if the default_decl is
not, then the name of the IFUNC should be made unique. */
if (TREE_PUBLIC (default_decl) == 0)
- is_uniq = true;
+ {
+ char *ifunc_name = make_unique_name (default_decl, "ifunc", true);
+ symtab->change_decl_assembler_name (ifunc_alias_decl,
+ get_identifier (ifunc_name));
+ XDELETEVEC (ifunc_name);
+ }
- /* Append the filename to the resolver function if the versions are
- not externally visible. This is because the resolver function has
- to be externally visible for the loader to find it. So, appending
- the filename will prevent conflicts with a resolver function from
- another module which is based on the same version name. */
- resolver_name = make_unique_name (default_decl, "resolver", is_uniq);
+ resolver_name = make_unique_name (default_decl, "resolver", false);
/* The resolver function should return a (void *). */
type = build_function_type_list (ptr_type_node, NULL_TREE);
@@ -33949,13 +33949,12 @@ make_resolver_func (const tree default_decl,
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 0;
- /* IFUNC resolvers have to be externally visible. */
- TREE_PUBLIC (decl) = 1;
+ TREE_PUBLIC (decl) = 0;
DECL_UNINLINABLE (decl) = 1;
/* Resolver is not external, body is generated. */
DECL_EXTERNAL (decl) = 0;
- DECL_EXTERNAL (dispatch_decl) = 0;
+ DECL_EXTERNAL (ifunc_alias_decl) = 0;
DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = make_node (BLOCK);
@@ -33986,14 +33985,14 @@ make_resolver_func (const tree default_decl,
pop_cfun ();
- gcc_assert (dispatch_decl != NULL);
- /* Mark dispatch_decl as "ifunc" with resolver as resolver_name. */
- DECL_ATTRIBUTES (dispatch_decl)
- = make_attribute ("ifunc", resolver_name, DECL_ATTRIBUTES (dispatch_decl));
+ gcc_assert (ifunc_alias_decl != NULL);
+ /* Mark ifunc_alias_decl as "ifunc" with resolver as resolver_name. */
+ DECL_ATTRIBUTES (ifunc_alias_decl)
+ = make_attribute ("ifunc", resolver_name,
+ DECL_ATTRIBUTES (ifunc_alias_decl));
/* Create the alias for dispatch to resolver here. */
- /*cgraph_create_function_alias (dispatch_decl, decl);*/
- cgraph_node::create_same_body_alias (dispatch_decl, decl);
+ cgraph_node::create_same_body_alias (ifunc_alias_decl, decl);
XDELETEVEC (resolver_name);
return decl;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3100618583a..76c07405a0d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-11 Martin Liska <mliska@suse.cz>
+
+ PR ipa/81213
+ * gcc.target/i386/pr81213.c: New test.
+
2017-08-10 Uros Bizjak <ubizjak@gmail.com>
PR target/81708
diff --git a/gcc/testsuite/gcc.target/i386/pr81213.c b/gcc/testsuite/gcc.target/i386/pr81213.c
new file mode 100644
index 00000000000..13e15d5fef0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr81213.c
@@ -0,0 +1,19 @@
+/* PR ipa/81214. */
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+
+__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default")))
+static int
+foo ()
+{
+ return -2;
+}
+
+int main()
+{
+ return foo();
+}
+
+/* { dg-final { scan-assembler "\t.globl\tfoo\\..*\\.ifunc" } } */
+/* { dg-final { scan-assembler "foo.resolver:" } } */
+/* { dg-final { scan-assembler "foo\\..*\\.ifunc, @gnu_indirect_function" } } */