From 724ec02c2c6d1b79788be77f68ebb6ca7b5b6acd Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 25 Mar 2020 11:03:39 +0100 Subject: [PATCH] Make target_clones resolver fn static if possible. PR target/93274 PR ipa/94271 * config/i386/i386-features.c (make_resolver_func): Drop public flag for resolver. * config/rs6000/rs6000.c (make_resolver_func): Add comdat group for resolver and drop public flag if possible. * multiple_target.c (create_dispatcher_calls): Drop unique_name and resolution as we want to enable LTO privatization of the default symbol. PR target/93274 PR ipa/94271 * gcc.target/i386/pr81213-2.c: New test. * gcc.target/i386/pr81213.c: Add additional source. * gcc.dg/lto/pr94271_0.c: New test. * gcc.dg/lto/pr94271_1.c: New test. --- gcc/ChangeLog | 12 ++++++++++++ gcc/config/i386/i386-features.c | 3 +++ gcc/config/rs6000/rs6000.c | 12 ++++++++++++ gcc/multiple_target.c | 4 ---- gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/gcc.dg/lto/pr94271_0.c | 13 +++++++++++++ gcc/testsuite/gcc.dg/lto/pr94271_1.c | 17 +++++++++++++++++ gcc/testsuite/gcc.target/i386/pr81213-2.c | 11 +++++++++++ gcc/testsuite/gcc.target/i386/pr81213.c | 7 +++++-- 9 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/lto/pr94271_0.c create mode 100644 gcc/testsuite/gcc.dg/lto/pr94271_1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr81213-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 89cfb07b457..c63b65a82b0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2020-03-25 Martin Liska + + PR target/93274 + PR ipa/94271 + * config/i386/i386-features.c (make_resolver_func): Drop + public flag for resolver. + * config/rs6000/rs6000.c (make_resolver_func): Add comdat + group for resolver and drop public flag if possible. + * multiple_target.c (create_dispatcher_calls): Drop unique_name + and resolution as we want to enable LTO privatization of the default + symbol. + 2020-03-25 Martin Liska PR lto/94259 diff --git a/gcc/config/i386/i386-features.c b/gcc/config/i386/i386-features.c index 6528832487e..3c70279dc7c 100644 --- a/gcc/config/i386/i386-features.c +++ b/gcc/config/i386/i386-features.c @@ -2777,6 +2777,9 @@ make_resolver_func (const tree default_decl, DECL_COMDAT (decl) = 1; make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); } + else + TREE_PUBLIC (ifunc_alias_decl) = 0; + /* Build result decl and add to function_decl. */ t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node); DECL_CONTEXT (t) = decl; diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 07f7cf516ba..7505a0e1e8e 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -23894,6 +23894,18 @@ make_resolver_func (const tree default_decl, DECL_INITIAL (decl) = make_node (BLOCK); DECL_STATIC_CONSTRUCTOR (decl) = 0; + if (DECL_COMDAT_GROUP (default_decl) + || TREE_PUBLIC (default_decl)) + { + /* In this case, each translation unit with a call to this + versioned function will put out a resolver. Ensure it + is comdat to keep just one copy. */ + DECL_COMDAT (decl) = 1; + make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); + } + else + TREE_PUBLIC (dispatch_decl) = 0; + /* Build result decl and add to function_decl. */ tree t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node); DECL_CONTEXT (t) = decl; diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c index cccfd2774db..c1cfe8ff978 100644 --- a/gcc/multiple_target.c +++ b/gcc/multiple_target.c @@ -178,10 +178,6 @@ create_dispatcher_calls (struct cgraph_node *node) node->externally_visible = false; node->forced_by_abi = false; node->set_section (NULL); - node->unique_name = ((node->resolution == LDPR_PREVAILING_DEF_IRONLY - || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP) - && !flag_incremental_link); - node->resolution = LDPR_PREVAILING_DEF_IRONLY; DECL_ARTIFICIAL (node->decl) = 1; node->force_output = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 59f15af69ac..3db4098a8d2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2020-03-25 Martin Liska + + PR target/93274 + PR ipa/94271 + * gcc.target/i386/pr81213-2.c: New test. + * gcc.target/i386/pr81213.c: Add additional source. + * gcc.dg/lto/pr94271_0.c: New test. + * gcc.dg/lto/pr94271_1.c: New test. + 2020-03-25 Jakub Jelinek PR debug/94280 diff --git a/gcc/testsuite/gcc.dg/lto/pr94271_0.c b/gcc/testsuite/gcc.dg/lto/pr94271_0.c new file mode 100644 index 00000000000..2ce7d65411a --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr94271_0.c @@ -0,0 +1,13 @@ +/* PR lto/94271 */ +/* { dg-lto-do link } */ + +int a; + +static int __attribute__ ((target_clones ("default", "avx512f"))) fast_clamp () +{} + +void +c () +{ + a = fast_clamp (); +} diff --git a/gcc/testsuite/gcc.dg/lto/pr94271_1.c b/gcc/testsuite/gcc.dg/lto/pr94271_1.c new file mode 100644 index 00000000000..db9bc9df6db --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr94271_1.c @@ -0,0 +1,17 @@ +int aa; + +static inline int __attribute__ ((target_clones ("default", "avx512f"))) +fast_clamp () +{} + +void +b () +{ + aa = fast_clamp (); +} + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr81213-2.c b/gcc/testsuite/gcc.target/i386/pr81213-2.c new file mode 100644 index 00000000000..a80622cb184 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81213-2.c @@ -0,0 +1,11 @@ +__attribute__((target_clones("avx","arch=slm","arch=core-avx2","default"))) +static int +foo () +{ + return 2; +} + +int bar() +{ + return foo(); +} diff --git a/gcc/testsuite/gcc.target/i386/pr81213.c b/gcc/testsuite/gcc.target/i386/pr81213.c index 89c47529861..334838631d0 100644 --- a/gcc/testsuite/gcc.target/i386/pr81213.c +++ b/gcc/testsuite/gcc.target/i386/pr81213.c @@ -1,6 +1,9 @@ /* PR ipa/81214. */ -/* { dg-do compile } */ +/* { dg-do run } */ /* { dg-require-ifunc "" } */ +/* { dg-additional-sources "pr81213-2.c" } */ + +int bar(); __attribute__((target_clones("avx","arch=slm","arch=core-avx2","default"))) static int @@ -11,7 +14,7 @@ foo () int main() { - return foo(); + return foo() + bar(); } /* { dg-final { scan-assembler "\t.globl\tfoo" } } */ -- 2.30.2