diff mbox series

[7/7] PowerPC test: Add prefixed stack protect test

Message ID 1591041222-24243-8-git-send-email-meissner@linux.ibm.com
State New
Headers show
Series [1/7] PowerPC tests: Add prefixed/pcrel tests. | expand

Commit Message

Michael Meissner June 1, 2020, 7:53 p.m. UTC
Test that stack protection generates prefixed stack instructions if you are
using large stack frame for -mcpu=future.

2020-06-01  Michael Meissner  <meissner@linux.ibm.com>

	* gcc.target/powerpc/prefix-stack-protect.c: New test.
---
 .../gcc.target/powerpc/prefix-stack-protect.c        | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c

Comments

Segher Boessenkool June 25, 2020, 5:18 p.m. UTC | #1
Hi!

On Mon, Jun 01, 2020 at 03:53:42PM -0400, Michael Meissner wrote:
> Test that stack protection generates prefixed stack instructions if you are
> using large stack frame for -mcpu=future.
> 
> 2020-06-01  Michael Meissner  <meissner@linux.ibm.com>
> 
> 	* gcc.target/powerpc/prefix-stack-protect.c: New test.

> +/* { dg-do compile } */
> +/* { dg-require-effective-target powerpc_prefixed_addr } */

Is this test necessary anymore, does -mcpu=power10 not guarantee that?

Okay for trunk with that looked at.  Thanks!


Segher
Michael Meissner June 27, 2020, 5:50 a.m. UTC | #2
On Thu, Jun 25, 2020 at 12:18:42PM -0500, Segher Boessenkool wrote:
> Hi!
> 
> On Mon, Jun 01, 2020 at 03:53:42PM -0400, Michael Meissner wrote:
> > Test that stack protection generates prefixed stack instructions if you are
> > using large stack frame for -mcpu=future.
> > 
> > 2020-06-01  Michael Meissner  <meissner@linux.ibm.com>
> > 
> > 	* gcc.target/powerpc/prefix-stack-protect.c: New test.
> 
> > +/* { dg-do compile } */
> > +/* { dg-require-effective-target powerpc_prefixed_addr } */
> 
> Is this test necessary anymore, does -mcpu=power10 not guarantee that?

I believe the test is necessary to prevent regressions.  As I said in the test,
we stumbled on this problem when building GLIBC with -mcpu=future/power10.

> Okay for trunk with that looked at.  Thanks!
Segher Boessenkool June 27, 2020, 6:44 p.m. UTC | #3
On Sat, Jun 27, 2020 at 01:50:48AM -0400, Michael Meissner wrote:
> On Thu, Jun 25, 2020 at 12:18:42PM -0500, Segher Boessenkool wrote:
> > > +/* { dg-do compile } */
> > > +/* { dg-require-effective-target powerpc_prefixed_addr } */
> > 
> > Is this test necessary anymore, does -mcpu=power10 not guarantee that?
> 
> I believe the test is necessary to prevent regressions.  As I said in the test,
> we stumbled on this problem when building GLIBC with -mcpu=future/power10.

We now have

  /* Enable -mprefixed by default on power10 systems.  */
  if (TARGET_POWER10 && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0)
    rs6000_isa_flags |= OPTION_MASK_PREFIXED;

so the testsuite can just assume it is enabled on all targets it is
supported for at all.

(The selector doesn't directly *hurt* of course, but it leads to cargo-
culting, future tests using this unneeded selector as well).


Segher
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c b/gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c
new file mode 100644
index 0000000..d0d291b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/prefix-stack-protect.c
@@ -0,0 +1,20 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_prefixed_addr } */
+/* { dg-options "-O2 -mdejagnu-cpu=future -fstack-protector-strong" } */
+
+/* Test that we can handle large stack frames with -fstack-protector-strong and
+   prefixed addressing.  This was originally discovered when trying to build
+   glibc with -mcpu=future, and vfwprintf.c failed because it used
+   -fstack-protector-strong.  */
+
+extern long foo (char *);
+
+long
+bar (void)
+{
+  char buffer[0x20000];
+  return foo (buffer) + 1;
+}
+
+/* { dg-final { scan-assembler {\mpld\M}  } } */
+/* { dg-final { scan-assembler {\mpstd\M} } } */