__FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL
has been added to indicate which ACLE version is implemented by the compiler.With LLVM 19 at least one more version other than the default is needed to trigger function multiversioning.
With LLVM 20 a header file declaration:
__attribute__((target_version("default"))) void f(void);
guarantees that there will be a mangled version f.default
. Conversely, LLVM 19 would generate an unmangled symbol here since function multiversioning does not trigger when compiling this code in the absence of other versions.
LLVM can optimize calls to versioned functions when they can be statically resolved. For example:
__attribute__((target_version("mops"))) int f(void);
__attribute__((target_version("sve2"))) int f(void);
__attribute__((target_version("sve"))) int f(void);
__attribute__((target_version("default"))) int f(void) { return 0; }
__attribute__((target_version("mops+sve2"))) int caller(void) {
return f(); // f._Mmops is called directly
}
__attribute__((target_version("mops"))) int caller(void) {
return f(); // f._Mmops is called directly
}
__attribute__((target_version("sve"))) int caller(void) {
return f(); // cannot be optimized since SVE2 may be available on target
}
__attribute__((target_version("default"))) int caller(void) {
return f(); // f.default is called directly
}