From e98925f693e27eed776eb7ee8191003a97981d21 Mon Sep 17 00:00:00 2001 From: Jiangning Liu Date: Fri, 4 Nov 2011 16:50:04 +0000 Subject: [PATCH] re PR rtl-optimization/38644 (Optimization flag -O1 -fschedule-insns2 causes wrong code) 2011-11-04 Jiangning Liu PR rtl-optimization/38644 * config/arm/arm.c (thumb1_expand_epilogue): Add memory barrier for epilogue having stack adjustment. testcase: * gcc.target/arm/stack-red-zone.c: New. From-SVN: r180964 --- gcc/ChangeLog | 6 ++++++ gcc/config/arm/arm.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/arm/stack-red-zone.c | 12 ++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/stack-red-zone.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d6e9551bc61..2c2c1544858 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-11-04 Jiangning Liu + + PR rtl-optimization/38644 + * config/arm/arm.c (thumb1_expand_epilogue): Add memory barrier + for epilogue having stack adjustment. + 2011-11-04 Georg-Johann Lay PR target/50931 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 5f0d5629462..6ef6f62d28d 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -22216,6 +22216,8 @@ thumb1_expand_epilogue (void) gcc_assert (amount >= 0); if (amount) { + emit_insn (gen_blockage ()); + if (amount < 512) emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, GEN_INT (amount))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d5a6ea510d6..f47a503822c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-11-04 Jiangning Liu + + PR rtl-optimization/38644 + * gcc.target/arm/stack-red-zone.c: New. + 2011-11-04 Paolo Carlini PR c++/48420 diff --git a/gcc/testsuite/gcc.target/arm/stack-red-zone.c b/gcc/testsuite/gcc.target/arm/stack-red-zone.c new file mode 100644 index 00000000000..b9f0f99371e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/stack-red-zone.c @@ -0,0 +1,12 @@ +/* No stack red zone. PR38644. */ +/* { dg-options "-mthumb -O2" } */ +/* { dg-final { scan-assembler "ldrb\[^\n\]*\\n\[\t \]*add\[\t \]*sp" } } */ + +extern int doStreamReadBlock (int *, char *, int size, int); + +char readStream (int *s) +{ + char c = 0; + doStreamReadBlock (s, &c, 1, *s); + return c; +}