Closed
Description
https://clang.godbolt.org/z/heoTnxqz5
Compare:
__attribute__((target_version("dotprod+lse")))
int foo(void) { return 1; }
__attribute__((target_version("default")))
int foo(void) { return 0; }
#ifdef HAS_CALLER
int caller(void) { return foo(); }
#endif
--rtlib=compiler-rt -O2 -DHAS_CALLER=1
vs
--rtlib=compiler-rt -O2
While GCC's version has self-consistent and correct behavior, IMO it would be better to always emit the weak ifunc+resolver along with the definition of the default
version so you can forward-declare the not-attributed version of the function and call these from any other TU.