arm: Don't ICE on arm_mve.h pragma without MVE types [PR117408]

Message ID 20241101210617.1037923-1-torbjorn.svensson@foss.st.com
State Superseded
Delegated to: Christophe Lyon
Headers
Series arm: Don't ICE on arm_mve.h pragma without MVE types [PR117408] |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Build failed

Commit Message

Torbjorn SVENSSON Nov. 1, 2024, 9:06 p.m. UTC
  There is one more problem, that this patch does not address, and that is
that there are warnings like below, but I do not know what's causing them.

.../gcc/testsuite/gcc.target/arm/pr117408-1.c:8:9: warning: 'pure' attribute on function returning 'void' [-Wattributes]
.../gcc/testsuite/gcc.target/arm/pr117408-2.c:8:9: warning: 'pure' attribute on function returning 'void' [-Wattributes]

Both warnignss are repeted several times and generated by the #pragma-line.
Should I dg-prune-output warning lines or is this ok as-is for trunk and
releases/gcc-14?

--

Starting with r14-435-g00d97bf3b5a, doing `#pragma arm "arm_mve.h"
false` or `#pragma arm "arm_mve.h" true` without first doing
`#pragma arm "arm_mve_types.h"` causes GCC to ICE.

gcc/ChangeLog:

      PR target/117408
      * config/arm/arm-mve-builtins.cc(handle_arm_mve_h): Detect if MVE
      types is missing and if so, return error.

gcc/testsuite/ChangeLog:

      PR target/117408
      * gcc.target/arm/mve/pr117408-1.c: New test.
      * gcc.target/arm/mve/pr117408-2.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 gcc/config/arm/arm-mve-builtins.cc            | 6 ++++++
 gcc/testsuite/gcc.target/arm/mve/pr117408-1.c | 7 +++++++
 gcc/testsuite/gcc.target/arm/mve/pr117408-2.c | 7 +++++++
 3 files changed, 20 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
  

Comments

Christophe Lyon Nov. 7, 2024, 10:46 a.m. UTC | #1
Hi,


On Fri, 1 Nov 2024 at 22:10, Torbjörn SVENSSON
<torbjorn.svensson@foss.st.com> wrote:
>
> There is one more problem, that this patch does not address, and that is
> that there are warnings like below, but I do not know what's causing them.
>
> .../gcc/testsuite/gcc.target/arm/pr117408-1.c:8:9: warning: 'pure' attribute on function returning 'void' [-Wattributes]
> .../gcc/testsuite/gcc.target/arm/pr117408-2.c:8:9: warning: 'pure' attribute on function returning 'void' [-Wattributes]
>
> Both warnignss are repeted several times and generated by the #pragma-line.
> Should I dg-prune-output warning lines or is this ok as-is for trunk and
> releases/gcc-14?
>

It seems this warning is related to a patch series I pushed recently.
I didn't see them in my builds, but I'll have a look.

Regarding your patch, the precommit CI has reported that it breaks the build:
gcc/config/arm/arm-mve-builtins.cc:540:51: error: expected ';' before 'return'

Maybe the error message should be more helpful, and tell the user what to do?

Thanks,

Christophe


> --
>
> Starting with r14-435-g00d97bf3b5a, doing `#pragma arm "arm_mve.h"
> false` or `#pragma arm "arm_mve.h" true` without first doing
> `#pragma arm "arm_mve_types.h"` causes GCC to ICE.
>
> gcc/ChangeLog:
>
>       PR target/117408
>       * config/arm/arm-mve-builtins.cc(handle_arm_mve_h): Detect if MVE
>       types is missing and if so, return error.
>
> gcc/testsuite/ChangeLog:
>
>       PR target/117408
>       * gcc.target/arm/mve/pr117408-1.c: New test.
>       * gcc.target/arm/mve/pr117408-2.c: Likewise.
>
> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
> ---
>  gcc/config/arm/arm-mve-builtins.cc            | 6 ++++++
>  gcc/testsuite/gcc.target/arm/mve/pr117408-1.c | 7 +++++++
>  gcc/testsuite/gcc.target/arm/mve/pr117408-2.c | 7 +++++++
>  3 files changed, 20 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
>  create mode 100644 gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
>
> diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc
> index af1908691b6..c730fe1f0b9 100644
> --- a/gcc/config/arm/arm-mve-builtins.cc
> +++ b/gcc/config/arm/arm-mve-builtins.cc
> @@ -535,6 +535,12 @@ handle_arm_mve_h (bool preserve_user_namespace)
>        return;
>      }
>
> +  if (!handle_arm_mve_types_p)
> +    {
> +      error ("this definition requires MVE types")
> +      return;
> +    }
> +
>    /* Define MVE functions.  */
>    function_table = new hash_table<registered_function_hasher> (1023);
>    function_builder builder;
> diff --git a/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c b/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
> new file mode 100644
> index 00000000000..5dddf86efa0
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target arm_v8_1m_mve_ok } */
> +/* { dg-add-options arm_v8_1m_mve } */
> +
> +/* It doesn't really matter if this produces errors missing types,
> +      but it mustn't trigger an ICE.  */
> +#pragma GCC arm "arm_mve.h" false /* { dg-error "this definition requires MVE types" } */
> diff --git a/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c b/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
> new file mode 100644
> index 00000000000..6451ee3577e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target arm_v8_1m_mve_ok } */
> +/* { dg-add-options arm_v8_1m_mve } */
> +
> +/* It doesn't really matter if this produces errors missing types,
> +      but it mustn't trigger an ICE.  */
> +#pragma GCC arm "arm_mve.h" true /* { dg-error "this definition requires MVE types" } */
> --
> 2.25.1
>
  

Patch

diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc
index af1908691b6..c730fe1f0b9 100644
--- a/gcc/config/arm/arm-mve-builtins.cc
+++ b/gcc/config/arm/arm-mve-builtins.cc
@@ -535,6 +535,12 @@  handle_arm_mve_h (bool preserve_user_namespace)
       return;
     }
 
+  if (!handle_arm_mve_types_p)
+    {
+      error ("this definition requires MVE types")
+      return;
+    }
+
   /* Define MVE functions.  */
   function_table = new hash_table<registered_function_hasher> (1023);
   function_builder builder;
diff --git a/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c b/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
new file mode 100644
index 00000000000..5dddf86efa0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_1m_mve_ok } */
+/* { dg-add-options arm_v8_1m_mve } */
+
+/* It doesn't really matter if this produces errors missing types,
+      but it mustn't trigger an ICE.  */
+#pragma GCC arm "arm_mve.h" false /* { dg-error "this definition requires MVE types" } */
diff --git a/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c b/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
new file mode 100644
index 00000000000..6451ee3577e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_1m_mve_ok } */
+/* { dg-add-options arm_v8_1m_mve } */
+
+/* It doesn't really matter if this produces errors missing types,
+      but it mustn't trigger an ICE.  */
+#pragma GCC arm "arm_mve.h" true /* { dg-error "this definition requires MVE types" } */