On 03/09/2024 13:57, Christophe Lyon wrote:
> Hi Torbjörn,
> 
> 
> On 9/3/24 11:30, Torbjörn SVENSSON wrote:
>>
>> Ok for trunk and releases/gcc-14?
>>
>> -- 
>>
>> Some of the test cases were scanning for "bti", but it would,
>> incorrectly, match the ".arch_extenssion pacbti".
>> Also, keep test cases active if a supported Cortex-M core is supplied.
>>
>> gcc/testsuite/ChangeLog:
>>
>>     * gcc.target/arm/bti-1.c: Enable for Cortex-M(52|55|85) and
>>     check for \tbti.
>>     * gcc.target/arm/bti-2.c: Likewise.
>>     * gcc.target/arm/pac-15.c: Likewise.
> For pac-15.c, your patch only enables the test for cortex-m{52|55|85}, 
> there's not scan-assembler for bti :-)
> 
>>     * gcc.target/arm/pac-4.c: Check for \tbti.
>>     * gcc.target/arm/pac-6.c: Likewise.
>>
>> Signed-off-by: Torbjörn SVENSSON <torbjorn.svens...@foss.st.com>
>> Co-authored-by: Yvan ROUX <yvan.r...@foss.st.com>
>> ---
>>   gcc/testsuite/gcc.target/arm/bti-1.c  | 4 ++--
>>   gcc/testsuite/gcc.target/arm/bti-2.c  | 4 ++--
>>   gcc/testsuite/gcc.target/arm/pac-15.c | 2 +-
>>   gcc/testsuite/gcc.target/arm/pac-4.c  | 2 +-
>>   gcc/testsuite/gcc.target/arm/pac-6.c  | 2 +-
>>   5 files changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/gcc/testsuite/gcc.target/arm/bti-1.c 
>> b/gcc/testsuite/gcc.target/arm/bti-1.c
>> index 79dd8010d2d..70a62b5a70c 100644
>> --- a/gcc/testsuite/gcc.target/arm/bti-1.c
>> +++ b/gcc/testsuite/gcc.target/arm/bti-1.c
>> @@ -1,6 +1,6 @@
>>   /* Check that GCC does bti instruction.  */
>>   /* { dg-do compile } */
>> -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" 
>> "-mcpu=*" } } */
>> +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" 
>> "-mcpu=*" } { "-mcpu=cortex-m52*" "-mcpu=cortex-m55*" "-mcpu=cortex-m85*" } 
>> } */
> I'm not sure this is the way forward, but I'll let Richard comment.

We shouldn't need to do this now, but this test will need some reworking to use 
the new feature that I've added today.

> 
>>   /* { dg-options "-march=armv8.1-m.main -mthumb -mfloat-abi=softfp 
>> -mbranch-protection=bti --save-temps" } 

I think we can replace the dg-skip-if and dg-options with
/* { dg-require-effective-target arm_arch_v8_1m_main_ok } */
/* { dg-options "-mfloat-abi=softfp -mbranch-protection=bti --save-temps" } */
/* { dg-add-options arm_arch_v8_1m_main } */

And now the framework knows how to correctly override any -mcpu= option passed 
from the test run configuration.

*/
>>     int
>> @@ -9,4 +9,4 @@ main (void)
>>     return 0;
>>   }
>>   -/* { dg-final { scan-assembler "bti" } } */
>> +/* { dg-final { scan-assembler "\tbti" } } */
>> diff --git a/gcc/testsuite/gcc.target/arm/bti-2.c 
>> b/gcc/testsuite/gcc.target/arm/bti-2.c
>> index 33910563849..44c04d3df68 100644
>> --- a/gcc/testsuite/gcc.target/arm/bti-2.c
>> +++ b/gcc/testsuite/gcc.target/arm/bti-2.c
>> @@ -1,7 +1,7 @@
>>   /* { dg-do compile } */
>>   /* -Os to create jump table.  */
>>   /* { dg-options "-Os" } */
>> -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" 
>> "-mcpu=*" } } */
>> +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" 
>> "-mcpu=*" } { "-mcpu=cortex-m52*" "-mcpu=cortex-m55*" "-mcpu=cortex-m85*" } 
>> } */
>>   /* { dg-options "-march=armv8.1-m.main -mthumb -mfloat-abi=softfp 
>> -mbranch-protection=bti --save-temps" } */
>>     extern int f1 (void);
>> @@ -55,4 +55,4 @@ lab2:
>>     return 2;
>>   }
>>   -/* { dg-final { scan-assembler-times "bti" 15 } } */
>> +/* { dg-final { scan-assembler-times "\tbti" 15 } } */
>> diff --git a/gcc/testsuite/gcc.target/arm/pac-15.c 
>> b/gcc/testsuite/gcc.target/arm/pac-15.c
>> index e1054902955..a2582e64d0a 100644
>> --- a/gcc/testsuite/gcc.target/arm/pac-15.c
>> +++ b/gcc/testsuite/gcc.target/arm/pac-15.c
>> @@ -1,7 +1,7 @@
>>   /* Check that GCC does .save and .cfi_offset directives with RA_AUTH_CODE 
>> pseudo hard-register.  */
>>   /* { dg-do compile } */
>>   /* { dg-require-effective-target mbranch_protection_ok } */
>> -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" 
>> "-mcpu=*" } } */
>> +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" 
>> "-mcpu=*" } { "-mcpu=cortex-m52*" "-mcpu=cortex-m55*" "-mcpu=cortex-m85*" } 
>> } */
>>   /* { dg-options "-march=armv8.1-m.main+mve+pacbti 
>> -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard 
>> -fasynchronous-unwind-tables -g -O0" } */

This one will need to use arm_arch_v8_1m_main_pacbti, but is otherwise similar.

>>     #include "stdio.h"
> How about
> -/* { dg-final { scan-assembler-times "pac       ip, lr, sp" 3 } } */
> +/* { dg-final { scan-assembler-times "\tpac\tip, lr, sp" 3 } } */
> ?
> 
>> diff --git a/gcc/testsuite/gcc.target/arm/pac-4.c 
>> b/gcc/testsuite/gcc.target/arm/pac-4.c
>> index cf915cdba50..81907079d77 100644
>> --- a/gcc/testsuite/gcc.target/arm/pac-4.c
>> +++ b/gcc/testsuite/gcc.target/arm/pac-4.c
>> @@ -5,6 +5,6 @@
>>     #include "pac.h"
>>   -/* { dg-final { scan-assembler-not "\tbti\t" } } */
>> +/* { dg-final { scan-assembler-not "\tbti" } } */
>>   /* { dg-final { scan-assembler-not "\tpac\t" } } */
>>   /* { dg-final { scan-assembler-not "\tpacbti\t" } } */
>> diff --git a/gcc/testsuite/gcc.target/arm/pac-6.c 
>> b/gcc/testsuite/gcc.target/arm/pac-6.c
>> index c5329f0ef48..15260c5c028 100644
>> --- a/gcc/testsuite/gcc.target/arm/pac-6.c
>> +++ b/gcc/testsuite/gcc.target/arm/pac-6.c
>> @@ -15,4 +15,4 @@ int bar()
>>     /* { dg-final { scan-assembler "pac\tip, lr, sp" } } */
>>   /* { dg-final { scan-assembler "aut\tip, lr, sp" } } */
> Why not prefix those two with '\t' too?
> 
>> -/* { dg-final { scan-assembler-not "bti" } } */
>> +/* { dg-final { scan-assembler-not "\tbti" } } */
> 
> In all pac-*.c tests, I noticed many scan-assembler directives without 
> leading '\t' (for pac, aut, pacbti instructions for instance).
> 
> Shouldn't we add it there too?
> 
> Thanks,
> 
> Christophe

R.

Reply via email to