From b4e9251d1e73c34f9b99fedcc7e6374edc96adb2 Mon Sep 17 00:00:00 2001 From: James Greenhalgh Date: Fri, 19 Sep 2014 09:31:01 +0000 Subject: [PATCH] [PATCH AArch64]: Add constraint letter for stack_protect_test pattern gcc/ * config/aarch64/aarch64.md (stack_protect_test_): Mark scratch register as an output to placate register renaming. gcc/testsuite/ * gcc.dg/ssp-3.c: New. * gcc.dg/ssp-4.c: Likewise. From-SVN: r215385 --- gcc/ChangeLog | 5 +++++ gcc/config/aarch64/aarch64.md | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/ssp-3.c | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/ssp-4.c | 18 ++++++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/ssp-3.c create mode 100644 gcc/testsuite/gcc.dg/ssp-4.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e627a781fed9..80bafa44e0db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-09-19 James Greenhalgh + + * config/aarch64/aarch64.md (stack_protect_test_): Mark + scratch register as written. + 2014-09-19 Andreas Krebbel * config/s390/s390.c (s390_emit_epilogue): Remove bogus diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index c60038a9015d..f15a516bb055 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -4031,7 +4031,7 @@ (unspec:PTR [(match_operand:PTR 1 "memory_operand" "m") (match_operand:PTR 2 "memory_operand" "m")] UNSPEC_SP_TEST)) - (clobber (match_scratch:PTR 3 "&r"))] + (clobber (match_scratch:PTR 3 "=&r"))] "" "ldr\t%3, %x1\;ldr\t%0, %x2\;eor\t%0, %3, %0" [(set_attr "length" "12") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a7f110914c1..4e3fb0cf297e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-19 James Greenhalgh + + * gcc.dg/ssp-3.c: New. + * gcc.dg/ssp-4.c: Likewise. + 2014-09-19 Andreas Krebbel * gcc.target/s390/dfp-conv1.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/ssp-3.c b/gcc/testsuite/gcc.dg/ssp-3.c new file mode 100644 index 000000000000..98c12da8ba22 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ssp-3.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-fstack-protector-strong -O1 -frename-registers" } */ +/* { dg-require-effective-target fstack_protector } */ + +extern int bar (const char *s, int *argc); +extern int baz (const char *s); + +char +foo (const char *s) +{ + int argc; + int ret; + if ( !bar (s, &argc)) + ret = baz (s); + return *s; +} diff --git a/gcc/testsuite/gcc.dg/ssp-4.c b/gcc/testsuite/gcc.dg/ssp-4.c new file mode 100644 index 000000000000..402033c240de --- /dev/null +++ b/gcc/testsuite/gcc.dg/ssp-4.c @@ -0,0 +1,18 @@ +/* { dg-do assemble } */ +/* { dg-options "-fstack-protector-strong -O1 -frename-registers" } */ +/* { dg-require-effective-target fstack_protector } */ + +typedef unsigned int uint32_t; +struct ctx +{ + uint32_t A; +}; + +void * +buffer_copy (const struct ctx *ctx, void *resbuf) +{ + uint32_t buffer[4]; + buffer[0] = (ctx->A); + __builtin_memcpy (resbuf, buffer, sizeof (buffer)); + return resbuf; +}