Skip to content

Commit

Permalink
Change the FMV rules so target_clones defaults must be explicitly stated
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlfieRichardsArm committed Jan 9, 2025
1 parent 7ec1e3a commit fbb838f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions main/acle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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.
Expand Down Expand Up @@ -2704,17 +2704,19 @@ 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:

* 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`.
Expand All @@ -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
Expand Down

0 comments on commit fbb838f

Please sign in to comment.