aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2017-09-20 23:48:31 +0200
committerSegher Boessenkool <segher@gcc.gnu.org>2017-09-20 23:48:31 +0200
commit6073d0028debf7cbd80dc0678402cbe2c6ea652d (patch)
treefc2fcb802e5a5fb4290674455ed642597118e67b /gcc
parent9283471ba0d8b605a5ddf8cbd2814d81d4dd8550 (diff)
downloadgcc-6073d0028debf7cbd80dc0678402cbe2c6ea652d.zip
gcc-6073d0028debf7cbd80dc0678402cbe2c6ea652d.tar.gz
gcc-6073d0028debf7cbd80dc0678402cbe2c6ea652d.tar.bz2
rs6000: Don't touch below the stack pointer (PR77687)
With the 32-bit SVR4 ABI we don't have a red zone, so we have to restore the callee-saved registers before we restore the stack pointer. The previous fix for this PR failed in two ways, for huge frames: first, we use a negative offset from r11 in that case, so the (mem:BLK 11) access does no good; second, sched does not handle accesses to mem:BLK correctly in this case (does not make dependencies). This patch fixes it by doing a store to (mem:BLK (scratch)) instead. This means no unrelated (not to stack) loads/stores can be moved over the stack restore either, but so be it. PR target/77687 * config/rs6000/rs6000.md (stack_restore_tie): Store to a scratch address instead of to r1 and r11. gcc/testsuite/ PR target/77687 * gcc.target/powerpc/pr77687.c: New testcase. From-SVN: r253033
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/rs6000/rs6000.md6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr77687.c20
4 files changed, 33 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1bbb3bf..371b790 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-20 Segher Boessenkool <segher@kernel.crashing.org>
+
+ PR target/77687
+ * config/rs6000/rs6000.md (stack_restore_tie): Store to a scratch
+ address instead of to r1 and r11.
+
2017-09-20 Sebastian Peryt <sebastian.peryt@intel.com>
* config.gcc: Support "knm".
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 7f17628..13ba743 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -13161,14 +13161,12 @@
; Some 32-bit ABIs do not have a red zone, so the stack deallocation has to
; stay behind all restores from the stack, it cannot be reordered to before
-; one. See PR77687. This insn is an add or mr, and a stack_tie on the
-; operands of that.
+; one. See PR77687. This insn is an add or mr, and a memory clobber.
(define_insn "stack_restore_tie"
[(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
(plus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
(match_operand:SI 2 "reg_or_cint_operand" "O,rI")))
- (set (mem:BLK (match_dup 0)) (const_int 0))
- (set (mem:BLK (match_dup 1)) (const_int 0))]
+ (set (mem:BLK (scratch)) (const_int 0))]
"TARGET_32BIT"
"@
mr %0,%1
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 801adf0..eebb33d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-19 Segher Boessenkool <segher@kernel.crashing.org>
+
+ PR target/77687
+ * gcc.target/powerpc/pr77687.c: New testcase.
+
2017-09-20 Jakub Jelinek <jakub@redhat.com>
P0409R2 - allow lambda capture [=, this]
diff --git a/gcc/testsuite/gcc.target/powerpc/pr77687.c b/gcc/testsuite/gcc.target/powerpc/pr77687.c
new file mode 100644
index 0000000..95b27ae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr77687.c
@@ -0,0 +1,20 @@
+/* { dg-options "-std=gnu99 -O2" } */
+/* { dg-final { scan-assembler-not {\mmr r?1,r?11\M.*11.*\mblr\M} } } */
+
+/* PR77687: We used to do stack accesses (via r11) after restoring r1. */
+
+void g(int, char *);
+const char * dum = "hello";
+
+void f(int x)
+{
+ char big[200000];
+ start:
+ g(x, big);
+ g(x, big);
+ register void *p asm("r11") = &&start;
+ asm("" : : "r"(p));
+ asm("" : : :"r28");
+ asm("" : : :"r29");
+ asm("" : : :"r30");
+}