From fbb838f520127d05190533d3ed9f988c05f8f780 Mon Sep 17 00:00:00 2001 From: Alfie Richards Date: Thu, 9 Jan 2025 15:58:18 +0000 Subject: [PATCH] Change the FMV rules so target_clones defaults must be explicitly stated This is needed to disambiguate cases such as: ```c++ // Translation unit 1 __attribute__ ((target_clone("dotprod, sve"))) int foo(); int foo() { return 1; } ``` ```c // Translation unit 2 __attribute__ ((target_clone("dotprod, sve"))) int foo() { return 2; } ``` Where with the previous specification two dispatchers would be created and two defaults with different contents. This is fixed by requiring default versions in target_clones to be explicitly stated. This makes it bery simple to determine where the dispatcher should be created accross translation units. --- main/acle.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/main/acle.md b/main/acle.md index 66d4f045..9fb73086 100644 --- a/main/acle.md +++ b/main/acle.md @@ -424,6 +424,7 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin * Removed Function Multi Versioning feature dgh. * Document Function Multi Versioning feature dependencies. * Simplified Function Multi Versioning version selection rules. +* Changed the Function Multi Versioning default version rules to be more explicit. * Fixed range of operand `o0` (too small) in AArch64 system register designations. * Fixed SVE2.1 quadword gather load/scatter store intrinsics. * Removed unnecessary Zd argument from `svcvtnb_mf8[_f32_x2]_fpm`. @@ -439,7 +440,6 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin * Changed the status of the SME2p1 ACLE from Alpha to Beta. * Changed the status of the SVE2p1 ACLE from Alpha to Beta. - ### References This document refers to the following documents. @@ -2704,6 +2704,12 @@ The following attributes trigger the multi version code generation: type of the default version. * All the function versions must be declared at the translation unit in which the definition of the default version resides. +* One `default` version of the function is required to be provided + in one of the translation units. + * Implicitly, as a definition without any attribute, + * as a function annotated with `target_version("default")`, + * or, as a function annotated with `target_clones(...)` where one + of the versions is `default`. The attribute `__attribute__((target_version("name")))` expresses the following: @@ -2711,10 +2717,6 @@ following: * When applied to a function it becomes one of the versions. * Multiple function versions may exist in the same or in different translation units. -* One `default` version of the function is required to be provided - in one of the translation units. - * Implicitly, without this attribute, - * or explicitly providing the `default` in the attribute. For example, the below is valid and 2 is used as the default value for `c` when calling the multiversioned function `f`. @@ -2741,11 +2743,6 @@ following: * when applied to a function the compiler emits multiple versions based on the arguments. - * One of them is implicitly the `default`. - * If the `default` matches with another explicitly provided - version in the same translation unit, then the compiler can - emit only one function instead of the two. The explicitly - provided version shall be preferred. * If a name is not recognized the compiler should ignore it[^fmv-note-ignore]. [^fmv-note-ignore]: The intention is to support the usecase of newer code if