rs6000: testsuite: Add rop_ok effective-target function

Message ID fd15cd08-440c-fc3a-eef8-6b7a279e4b44@linux.ibm.com
State New
Headers
Series rs6000: testsuite: Add rop_ok effective-target function |

Commit Message

Peter Bergner Nov. 11, 2021, 10:12 p.m. UTC
  This patch adds a new effective-target function that tests whether
it is safe to emit the ROP-protect instructions and updates the
ROP test cases to use it.

Segher, as we discussed offline, this uses the double [] which you said
isn't needed in general regex's, but for some reason is needed in the gcc
testsuite regex.

Tested on powerpc64le*-linux with no regressions.  Ok for mainline?

Peter


gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_rop_ok): New function.
	* gcc.target/powerpc/rop-1.c: Use it.
	* gcc.target/powerpc/rop-2.c: Likewise.
	* gcc.target/powerpc/rop-3.c: Likewise.
	* gcc.target/powerpc/rop-4.c: Likewise.
	* gcc.target/powerpc/rop-5.c: Likewise.
  

Comments

Segher Boessenkool Dec. 2, 2021, 11:15 p.m. UTC | #1
Hi!

On Thu, Nov 11, 2021 at 04:12:08PM -0600, Peter Bergner wrote:
> This patch adds a new effective-target function that tests whether
> it is safe to emit the ROP-protect instructions and updates the
> ROP test cases to use it.
> 
> Segher, as we discussed offline, this uses the double [] which you said
> isn't needed in general regex's, but for some reason is needed in the gcc
> testsuite regex.

> +proc check_effective_target_rop_ok { } {
> +    return [check_effective_target_power10_ok]
> +	   && [check_effective_target_powerpc_elfv2]
> +}

That's not a regular expression ;-)

It is easiest to put [] around each function call, it will take && as
argument if you write is as [checkA && checkB] .  I'm not sure what I
meant, sorry :-)  Writing it as you did is simpler and more idiomatic
than other ways of achieving this.

> Tested on powerpc64le*-linux with no regressions.  Ok for mainline?

What can "*" be there other than the empty string?  Which valuse of "*"
did you test?  :-)

> gcc/testsuite/
> 	* lib/target-supports.exp (check_effective_target_rop_ok): New function.
> 	* gcc.target/powerpc/rop-1.c: Use it.
> 	* gcc.target/powerpc/rop-2.c: Likewise.
> 	* gcc.target/powerpc/rop-3.c: Likewise.
> 	* gcc.target/powerpc/rop-4.c: Likewise.
> 	* gcc.target/powerpc/rop-5.c: Likewise.

> --- a/gcc/testsuite/gcc.target/powerpc/rop-3.c
> +++ b/gcc/testsuite/gcc.target/powerpc/rop-3.c
> @@ -1,5 +1,5 @@
>  /* { dg-do run { target { power10_hw } } } */
> -/* { dg-require-effective-target powerpc_elfv2 } */
> +/* { dg-require-effective-target rop_ok } */
>  /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */

Okay for trunk.  Thanks!


Segher
  
Peter Bergner Dec. 3, 2021, 8:35 p.m. UTC | #2
On 12/2/21 5:15 PM, Segher Boessenkool wrote:
>> Tested on powerpc64le*-linux with no regressions.  Ok for mainline?
> 
> What can "*" be there other than the empty string?  Which valuse of "*"
> did you test?  :-)

Heh, too used to typing powerpc64*-linux.  Yeah, in this case * == "".



> Okay for trunk.  Thanks!

Thanks, pushed.

Peter
  

Patch

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 1c8b1ebb86e..0d9a3ba67ce 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6625,6 +6625,13 @@  proc check_effective_target_powerpc_elfv2 { } {
     }
 }
 
+# Return 1 if this is a PowerPC target supporting -mrop-protect
+
+proc check_effective_target_rop_ok { } {
+    return [check_effective_target_power10_ok]
+	    && [check_effective_target_powerpc_elfv2]
+}
+
 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables.  Return 1 if the
 # test environment appears to run executables on such a simulator.
diff --git a/gcc/testsuite/gcc.target/powerpc/rop-1.c b/gcc/testsuite/gcc.target/powerpc/rop-1.c
index 8cedcb6668a..12893dec027 100644
--- a/gcc/testsuite/gcc.target/powerpc/rop-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/rop-1.c
@@ -1,6 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
 
 /* Verify that ROP-protect instructions are inserted when a
    call is present.  */
diff --git a/gcc/testsuite/gcc.target/powerpc/rop-2.c b/gcc/testsuite/gcc.target/powerpc/rop-2.c
index c556952aec1..5f1d7c39bfc 100644
--- a/gcc/testsuite/gcc.target/powerpc/rop-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/rop-2.c
@@ -1,6 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect -mprivileged" } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
 
 /* Verify that privileged ROP-protect instructions are inserted when a
    call is present.  */
diff --git a/gcc/testsuite/gcc.target/powerpc/rop-3.c b/gcc/testsuite/gcc.target/powerpc/rop-3.c
index 8d03792e3e5..d2ef3bf4bad 100644
--- a/gcc/testsuite/gcc.target/powerpc/rop-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/rop-3.c
@@ -1,5 +1,5 @@ 
 /* { dg-do run { target { power10_hw } } } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
 /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
 
 /* Verify that ROP-protect instructions execute correctly when a
diff --git a/gcc/testsuite/gcc.target/powerpc/rop-4.c b/gcc/testsuite/gcc.target/powerpc/rop-4.c
index dcf47c63fb7..80faa9b3f7b 100644
--- a/gcc/testsuite/gcc.target/powerpc/rop-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/rop-4.c
@@ -1,6 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
 
 /* Verify that no ROP-protect instructions are inserted when no
    call is present.  */
diff --git a/gcc/testsuite/gcc.target/powerpc/rop-5.c b/gcc/testsuite/gcc.target/powerpc/rop-5.c
index f2594df8a44..f7970f1fe25 100644
--- a/gcc/testsuite/gcc.target/powerpc/rop-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/rop-5.c
@@ -1,5 +1,5 @@ 
 /* { dg-do compile } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
 /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
 
 /* Verify that __ROP_PROTECT__ is predefined for -mrop-protect.  */