[clang] [FMV] Allow multi versioning without default declaration. (PR #85454)

Alexandros Lamprineas via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 22 13:22:45 PDT 2024


================
@@ -109,9 +109,22 @@ int unused_with_implicit_default_def(void) { return 1; }
 int unused_with_implicit_forward_default_def(void) { return 0; }
 __attribute__((target_version("lse"))) int unused_with_implicit_forward_default_def(void) { return 1; }
 
-// This should generate a normal function.
+// This should generate a target version despite the default not being declared.
 __attribute__((target_version("rdm"))) int unused_without_default(void) { return 0; }
 
+// The following is guarded because in NOFMV we get errors for calling undeclared functions.
+#ifdef __HAVE_FUNCTION_MULTI_VERSIONING
+// This should generate a default declaration, two target versions and the resolver.
+__attribute__((target_version("jscvt"))) int used_def_without_default_decl(void) { return 1; }
+__attribute__((target_version("rdma"))) int used_def_without_default_decl(void) { return 2; }
+
+// This should generate a default declaration and the resolver.
+__attribute__((target_version("jscvt"))) int used_decl_without_default_decl(void);
+__attribute__((target_version("rdma"))) int used_decl_without_default_decl(void);
+
+int caller(void) { return used_def_without_default_decl() + used_decl_without_default_decl(); }
----------------
labrinea wrote:

Let me think about this a little more. The behavior is inconsistent when the order of declaration changes. If the default comes last then it is mangled and a resolver is generated. Perhaps this is preferable in case the other versions reside in another TU.

https://github.com/llvm/llvm-project/pull/85454


More information about the cfe-commits mailing list