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 Feb 3, 2025
1 parent 16545a6 commit 6e875c1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions main/acle.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin
* Added `svdot[_n_f16_mf8]_fpm` and `svdot[_n_f32_mf8]_fpm`.
* Added Guarded Control Stack (GCS) at
[**Beta**](#current-status-and-anticipated-changes) quality level.
* Changed the Function Multi Versioning default version rules to be more explicit.

### References

Expand Down Expand Up @@ -2721,17 +2722,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 @@ -2758,11 +2761,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 6e875c1

Please sign in to comment.