Add warning for use of non-spec FMV in Aarch64
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
Commit Message
This patch adds a warning whenever FMV is used for Aarch64.
The reasoning for this is the ACLE [1] spec for FMV has diverged
significantly from the current implementation and we want to prevent
future compatability issues.
There is a patch for and ACLE compliant version of target_version and
target_clone coming eventually but it won't make gcc-15.
This has been bootstrap and regression tested for Aarch64.
Is this okay for master and packport to gcc-14?
[1] https://github.com/ARM-software/acle/blob/main/main/acle.md#function-multi-versioning
gcc/ChangeLog:
* config/aarch64/aarch64.cc
(aarch64_mangle_decl_assembler_name): Add experimental warning.
* config/aarch64/aarch64.opt: Add command line option to disable
warning.
gcc/testsuite/ChangeLog:
* g++.target/aarch64/mv-1.C: Add CLI flag
* g++.target/aarch64/mv-symbols1.C: Add CLI flag
* g++.target/aarch64/mv-symbols2.C: Add CLI flag
* g++.target/aarch64/mv-symbols3.C: Add CLI flag
* g++.target/aarch64/mv-symbols4.C: Add CLI flag
* g++.target/aarch64/mv-symbols5.C: Add CLI flag
* g++.target/aarch64/mvc-symbols1.C: Add CLI flag
* g++.target/aarch64/mvc-symbols2.C: Add CLI flag
* g++.target/aarch64/mvc-symbols3.C: Add CLI flag
* g++.target/aarch64/mvc-symbols4.C: Add CLI flag
* g++.target/aarch64/mv-warning1.C: New test.
---
gcc/config/aarch64/aarch64.cc | 3 +++
gcc/config/aarch64/aarch64.opt | 4 ++++
gcc/testsuite/g++.target/aarch64/mv-1.C | 1 +
gcc/testsuite/g++.target/aarch64/mv-symbols1.C | 1 +
gcc/testsuite/g++.target/aarch64/mv-symbols2.C | 1 +
gcc/testsuite/g++.target/aarch64/mv-symbols3.C | 1 +
gcc/testsuite/g++.target/aarch64/mv-symbols4.C | 1 +
gcc/testsuite/g++.target/aarch64/mv-symbols5.C | 1 +
gcc/testsuite/g++.target/aarch64/mv-warning1.C | 9 +++++++++
gcc/testsuite/g++.target/aarch64/mvc-symbols1.C | 1 +
gcc/testsuite/g++.target/aarch64/mvc-symbols2.C | 1 +
gcc/testsuite/g++.target/aarch64/mvc-symbols3.C | 1 +
gcc/testsuite/g++.target/aarch64/mvc-symbols4.C | 1 +
13 files changed, 26 insertions(+)
create mode 100644 gcc/testsuite/g++.target/aarch64/mv-warning1.C
Comments
Hi Alfie,
> On 9 Jan 2025, at 10:58, alfie.richards@arm.com wrote:
>
> This patch adds a warning whenever FMV is used for Aarch64.
>
> The reasoning for this is the ACLE [1] spec for FMV has diverged
> significantly from the current implementation and we want to prevent
> future compatability issues.
>
> There is a patch for and ACLE compliant version of target_version and
> target_clone coming eventually but it won't make gcc-15.
>
> This has been bootstrap and regression tested for Aarch64.
> Is this okay for master and packport to gcc-14?
>
> [1] https://github.com/ARM-software/acle/blob/main/main/acle.md#function-multi-versioning
> gcc/ChangeLog:
>
> * config/aarch64/aarch64.cc
> (aarch64_mangle_decl_assembler_name): Add experimental warning.
> * config/aarch64/aarch64.opt: Add command line option to disable
> warning.
>
> gcc/testsuite/ChangeLog:
>
> * g++.target/aarch64/mv-1.C: Add CLI flag
> * g++.target/aarch64/mv-symbols1.C: Add CLI flag
> * g++.target/aarch64/mv-symbols2.C: Add CLI flag
> * g++.target/aarch64/mv-symbols3.C: Add CLI flag
> * g++.target/aarch64/mv-symbols4.C: Add CLI flag
> * g++.target/aarch64/mv-symbols5.C: Add CLI flag
> * g++.target/aarch64/mvc-symbols1.C: Add CLI flag
> * g++.target/aarch64/mvc-symbols2.C: Add CLI flag
> * g++.target/aarch64/mvc-symbols3.C: Add CLI flag
> * g++.target/aarch64/mvc-symbols4.C: Add CLI flag
> * g++.target/aarch64/mv-warning1.C: New test.
> ---
> gcc/config/aarch64/aarch64.cc | 3 +++
> gcc/config/aarch64/aarch64.opt | 4 ++++
> gcc/testsuite/g++.target/aarch64/mv-1.C | 1 +
> gcc/testsuite/g++.target/aarch64/mv-symbols1.C | 1 +
> gcc/testsuite/g++.target/aarch64/mv-symbols2.C | 1 +
> gcc/testsuite/g++.target/aarch64/mv-symbols3.C | 1 +
> gcc/testsuite/g++.target/aarch64/mv-symbols4.C | 1 +
> gcc/testsuite/g++.target/aarch64/mv-symbols5.C | 1 +
> gcc/testsuite/g++.target/aarch64/mv-warning1.C | 9 +++++++++
> gcc/testsuite/g++.target/aarch64/mvc-symbols1.C | 1 +
> gcc/testsuite/g++.target/aarch64/mvc-symbols2.C | 1 +
> gcc/testsuite/g++.target/aarch64/mvc-symbols3.C | 1 +
> gcc/testsuite/g++.target/aarch64/mvc-symbols4.C | 1 +
> 13 files changed, 26 insertions(+)
> create mode 100644 gcc/testsuite/g++.target/aarch64/mv-warning1.C
>
> <0001-Add-warning-for-use-of-non-spec-FMV-in-Aarch64.patch>
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 91de13159cb..afc0749fd67 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -20347,6 +20347,9 @@ aarch64_mangle_decl_assembler_name (tree decl, tree id)
if (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_FUNCTION_VERSIONED (decl))
{
+ warning_at(DECL_SOURCE_LOCATION(decl), OPT_Wexperimental_fmv_target,
+ "function multi-versioning support is experimental");
+
Some wording nits.
Space before the “(“.
I think there should be no ‘-‘ here to keep consistent with the ACLE wording. Not sure whether Function Multi Versioning should be capitalised. What do you think?
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 36bc719b822..55670eeb74f 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -431,3 +431,7 @@ handling. One means we try to form pairs involving one or more existing
individual writeback accesses where possible. A value of two means we
also try to opportunistically form writeback opportunities by folding in
trailing destructive updates of the base register used by a pair.
+
+Wexperimental-fmv-target
+Target Var(warn_experimental_fmv) Warning Init(1)
+Warn about usage of experimental function multi versioning
Should this have aarch64 in the name somehow? It feels awkward to have aarch64 in the name, but the option is not generic.
In any case, this should be documented in invoke.texi.
I also think that from a user experience POV if they get this warning they may ask what the recommendation is.
Should they change their source? Be prepared that the spec will change in future releases??
The documentation should give some guidance
Thanks,
Kyrill
Hi Kyrylo,
(resending due to missing CC)
On 09/01/2025 10:41, Kyrylo Tkachov wrote:
> diff --git a/gcc/config/aarch64/aarch64.cc
> b/gcc/config/aarch64/aarch64.cc
> index 91de13159cb..afc0749fd67 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -20347,6 +20347,9 @@ aarch64_mangle_decl_assembler_name (tree decl,
> tree id)
> if (TREE_CODE (decl) == FUNCTION_DECL
> && DECL_FUNCTION_VERSIONED (decl))
> {
> + warning_at(DECL_SOURCE_LOCATION(decl), OPT_Wexperimental_fmv_target,
> + "function multi-versioning support is experimental");
> +
> Some wording nits.
>
> Space before the “(“.
Thank you, I will fix.
> I think there should be no ‘-‘ here to keep consistent with the ACLE
> wording. Not sure whether Function Multi Versioning should be
> capitalised. What do you think?
Ah yes, best to follow the ACLE for formatting I suppose. I will
capitalise and remove the hyphen to match.
> diff --git a/gcc/config/aarch64/aarch64.opt
> b/gcc/config/aarch64/aarch64.opt
> index 36bc719b822..55670eeb74f 100644
> --- a/gcc/config/aarch64/aarch64.opt
> +++ b/gcc/config/aarch64/aarch64.opt
> @@ -431,3 +431,7 @@ handling. One means we try to form pairs involving
> one or more existing
> individual writeback accesses where possible. A value of two means we
> also try to opportunistically form writeback opportunities by folding in
> trailing destructive updates of the base register used by a pair.
> +
> +Wexperimental-fmv-target
> +Target Var(warn_experimental_fmv) Warning Init(1)
> +Warn about usage of experimental function multi versioning
>
> Should this have aarch64 in the name somehow? It feels awkward to have
> aarch64 in the name, but the option is not generic.
I was following the Wopenacc-dims in designing this which is a target
specific option for gcn
that isn't named overly specifically.
I also don't think this necessarily has to be limited to Aarch64. I'm
aware other ports have
specified the behaviour of target_version like Aarch64 has which GCC
currently doesn't conform to
and so may want to issue the same warning.
> In any case, this should be documented in invoke.texi.
Will send a patch adding this.
> I also think that from a user experience POV if they get this warning
> they may ask what the recommendation is.
> Should they change their source? Be prepared that the spec will change
> in future releases??
> The documentation should give some guidance
I have added to the warning (in upcoming patch) that the behaviour is
likely to change.
I will also add similar to the documentation.
Thank you for the feedback! I will get an updated patch to you shortly.
Alfie Richards
>
@@ -20347,6 +20347,9 @@ aarch64_mangle_decl_assembler_name (tree decl, tree id)
if (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_FUNCTION_VERSIONED (decl))
{
+ warning_at(DECL_SOURCE_LOCATION(decl), OPT_Wexperimental_fmv_target,
+ "function multi-versioning support is experimental");
+
aarch64_fmv_feature_mask feature_mask = get_feature_mask_for_version (decl);
std::string name = IDENTIFIER_POINTER (id);
@@ -431,3 +431,7 @@ handling. One means we try to form pairs involving one or more existing
individual writeback accesses where possible. A value of two means we
also try to opportunistically form writeback opportunities by folding in
trailing destructive updates of the base register used by a pair.
+
+Wexperimental-fmv-target
+Target Var(warn_experimental_fmv) Warning Init(1)
+Warn about usage of experimental function multi versioning
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_version("default")))
int foo ()
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
int foo ()
{
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_version("default")))
int foo ()
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_version("default")))
int foo ();
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_version("default")))
int foo ()
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_version("default")))
int foo ();
new file mode 100644
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0" } */
+
+__attribute__((target_version("default")))
+int foo () { return 1; }/* { dg-warning "function multi-versioning support is experimental" } */
+
+__attribute__((target_version("rng")))
+int foo () { return 1; }/* { dg-warning "function multi-versioning support is experimental" } */
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_clones("default", "dotprod", "sve+sve2")))
int foo ()
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_clones("default", "dotprod", "sve+sve2")))
int foo ()
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_clones("default", "dotprod", "sve+sve2")))
int foo ();
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O0" } */
+/* { dg-additional-options "-Wno-experimental-fmv-target" } */
__attribute__((target_clones("default", "dotprod", "sve+sve2")))
int foo ();