[aarch64] target: Support whitespaces in target attr/pragma.

Message ID 8dd8a6ab-24ca-9c59-1b3b-5fdca48896fa@suse.cz
State New
Headers
Series [aarch64] target: Support whitespaces in target attr/pragma. |

Commit Message

Martin Liška Oct. 19, 2021, 9:16 a.m. UTC
  Hello.

The patch does the same as g:df592811f950301ed3b10a08e476dad0f2eff26a for aarch64.

Tested locally with cross compiler.

Ready for master?
Thanks,
Martin

	PR target/102375

gcc/ChangeLog:

	* config/aarch64/aarch64.c (aarch64_process_one_target_attr):
	Strip whitespaces.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pr102375.c: New test.
---
  gcc/config/aarch64/aarch64.c                | 1 +
  gcc/testsuite/gcc.target/aarch64/pr102375.c | 4 ++++
  2 files changed, 5 insertions(+)
  create mode 100644 gcc/testsuite/gcc.target/aarch64/pr102375.c
  

Comments

Richard Sandiford Oct. 19, 2021, 10:52 a.m. UTC | #1
Martin Liška <mliska@suse.cz> writes:
> Hello.
>
> The patch does the same as g:df592811f950301ed3b10a08e476dad0f2eff26a for aarch64.
>
> Tested locally with cross compiler.
>
> Ready for master?
>
> Thanks,
> Martin
>
> 	PR target/102375
>
> gcc/ChangeLog:
>
> 	* config/aarch64/aarch64.c (aarch64_process_one_target_attr):
> 	Strip whitespaces.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.target/aarch64/pr102375.c: New test.
> ---
>   gcc/config/aarch64/aarch64.c                | 1 +
>   gcc/testsuite/gcc.target/aarch64/pr102375.c | 4 ++++
>   2 files changed, 5 insertions(+)
>   create mode 100644 gcc/testsuite/gcc.target/aarch64/pr102375.c
>
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 76d99d247ae..4c3e491ab14 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -17624,6 +17624,7 @@ aarch64_process_one_target_attr (char *arg_str)
>     bool invert = false;
>   
>     size_t len = strlen (arg_str);
> +  arg_str = strip_whitespaces (arg_str, &len);

It looks like this ought to happen after the alloca and copy, since it
modifies the string.

Thanks,
Richard

>   
>     if (len == 0)
>       {
> diff --git a/gcc/testsuite/gcc.target/aarch64/pr102375.c b/gcc/testsuite/gcc.target/aarch64/pr102375.c
> new file mode 100644
> index 00000000000..fa75d319b2d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/pr102375.c
> @@ -0,0 +1,4 @@
> +/* PR target/102375 */
> +/* { dg-do compile } */
> +
> +void calculate(void) __attribute__ ((target ("+sve, +sve2")));
  
Martin Liška Oct. 19, 2021, 12:25 p.m. UTC | #2
On 10/19/21 12:52, Richard Sandiford wrote:
> It looks like this ought to happen after the alloca and copy, since it
> modifies the string.

Oh yeah, good point.

Ready to be installed with the change?
Thanks,
Martin
  
Richard Sandiford Oct. 19, 2021, 12:31 p.m. UTC | #3
Martin Liška <mliska@suse.cz> writes:
> On 10/19/21 12:52, Richard Sandiford wrote:
>> It looks like this ought to happen after the alloca and copy, since it
>> modifies the string.
>
> Oh yeah, good point.
>
> Ready to be installed with the change?
> Thanks,
> Martin
>
> From 68df4cba3bccb714a14e3c795e6d9e4a44c54318 Mon Sep 17 00:00:00 2001
> From: Martin Liska <mliska@suse.cz>
> Date: Tue, 19 Oct 2021 11:11:16 +0200
> Subject: [PATCH] target: Support whitespaces in target attr/pragma.
>
> 	PR target/102375
>
> gcc/ChangeLog:
>
> 	* config/aarch64/aarch64.c (aarch64_process_one_target_attr):
> 	Strip whitespaces.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.target/aarch64/pr102375.c: New test.

OK, thanks.

Richard

> ---
>  gcc/config/aarch64/aarch64.c                | 1 +
>  gcc/testsuite/gcc.target/aarch64/pr102375.c | 4 ++++
>  2 files changed, 5 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/pr102375.c
>
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 76d99d247ae..fdf341812f4 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -17633,6 +17633,7 @@ aarch64_process_one_target_attr (char *arg_str)
>  
>    char *str_to_check = (char *) alloca (len + 1);
>    strcpy (str_to_check, arg_str);
> +  str_to_check = strip_whitespaces (str_to_check, &len);
>  
>    /* We have something like __attribute__ ((target ("+fp+nosimd"))).
>       It is easier to detect and handle it explicitly here rather than going
> diff --git a/gcc/testsuite/gcc.target/aarch64/pr102375.c b/gcc/testsuite/gcc.target/aarch64/pr102375.c
> new file mode 100644
> index 00000000000..fa75d319b2d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/pr102375.c
> @@ -0,0 +1,4 @@
> +/* PR target/102375 */
> +/* { dg-do compile } */
> +
> +void calculate(void) __attribute__ ((target ("+sve, +sve2")));
  

Patch

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 76d99d247ae..4c3e491ab14 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -17624,6 +17624,7 @@  aarch64_process_one_target_attr (char *arg_str)
    bool invert = false;
  
    size_t len = strlen (arg_str);
+  arg_str = strip_whitespaces (arg_str, &len);
  
    if (len == 0)
      {
diff --git a/gcc/testsuite/gcc.target/aarch64/pr102375.c b/gcc/testsuite/gcc.target/aarch64/pr102375.c
new file mode 100644
index 00000000000..fa75d319b2d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr102375.c
@@ -0,0 +1,4 @@ 
+/* PR target/102375 */
+/* { dg-do compile } */
+
+void calculate(void) __attribute__ ((target ("+sve, +sve2")));