__attribute__((target_clones("default", "sse3"))) static void dt_simd_memcpy (const float *const __restrict__ in, float *const __restrict__ out, const int num_elem) { for(int k = 0; k < num_elem; k++) out[k] = in[k]; } void bar(float *in, float *out, int num_elem) { dt_simd_memcpy (in, out, num_elem); } differs in generated code on each invocation of GCC with -fPIC
Probably caused by /* 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) { char *ifunc_name = make_unique_name (default_decl, "ifunc", true); symtab->change_decl_assembler_name (ifunc_alias_decl, get_identifier (ifunc_name)); not sure if easy to avoid.
Yes, it's caused by the needed public visibility.
The usual way to get deterministic uniqueness is to hash over all relevant inputs
IFUNCs don't have to be somehow "globally visible". The comment is there from day 1, but it's not clear why - possibly a misunderstanding? GCC happily accepts a static ifunc, and rest of toolchain should have no problem either: __attribute__((used,ifunc("r_f"))) static void f(); static void *r_f() { return 0; } .type r_f, @function r_f: xorl %eax, %eax ret .size r_f, .-r_f .type f, @gnu_indirect_function .set f,r_f
(In reply to Alexander Monakov from comment #4) > IFUNCs don't have to be somehow "globally visible". The comment is there > from day 1, but it's not clear why - possibly a misunderstanding? GCC > happily accepts a static ifunc, and rest of toolchain should have no problem > either: > > __attribute__((used,ifunc("r_f"))) > static void f(); > > static void *r_f() > { > return 0; > } > .type r_f, @function > r_f: > xorl %eax, %eax > ret > .size r_f, .-r_f > .type f, @gnu_indirect_function > .set f,r_f Great Alexander. Then let me to test the suggested change.
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>: https://gcc.gnu.org/g:c2bd2b4664be8b73f8fd58a64dec1e93871797cc commit r10-6242-gc2bd2b4664be8b73f8fd58a64dec1e93871797cc Author: Martin Liska <mliska@suse.cz> Date: Mon Jan 27 10:48:18 2020 +0100 Do not generate a unique fnname for resolver. PR target/93274 * config/i386/i386-features.c (make_resolver_func): Align the code with ppc64 target implementation. Do not generate a unique name for resolver function. PR target/93274 * gcc.target/i386/pr81213.c: Adjust to not expect a globally unique name.
Fixed on trunk, probably not planning to backport.
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>: https://gcc.gnu.org/g:724ec02c2c6d1b79788be77f68ebb6ca7b5b6acd commit r10-7372-g724ec02c2c6d1b79788be77f68ebb6ca7b5b6acd Author: Martin Liska <mliska@suse.cz> Date: Wed Mar 25 11:03:39 2020 +0100 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.