aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Krebbel <krebbel@linux.ibm.com>2020-05-14 08:16:27 +0200
committerAndreas Krebbel <krebbel@linux.ibm.com>2020-05-14 08:16:27 +0200
commit868d351e232371eec4b40e83014a617d0d46f985 (patch)
tree2522293ac34cd5af3a0560d149c79f35da6d44ea
parentd3e5bae174d9d2ed115a364d5b404d179458a622 (diff)
downloadgcc-868d351e232371eec4b40e83014a617d0d46f985.zip
gcc-868d351e232371eec4b40e83014a617d0d46f985.tar.gz
gcc-868d351e232371eec4b40e83014a617d0d46f985.tar.bz2
IBM Z: stack clash prot: add missing updates of last_probe_offset
After emitting probes in a loop last_probe_offset needs to be updated. Not doing this usually assumes a too low distance to the last access when emitting the remainder leading to stack probes being omitted. gcc/ChangeLog: 2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com> * config/s390/s390.c (allocate_stack_space): Add missing updates of last_probe_offset. gcc/testsuite/ChangeLog: 2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com> * gcc.target/s390/stack-clash-1.c: New test.
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/s390/s390.c3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/s390/stack-clash-1.c17
4 files changed, 29 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0b326ee..51d3e42 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+ * config/s390/s390.c (allocate_stack_space): Add missing updates
+ of last_probe_offset.
+
+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
* config/s390/s390.md ("allocate_stack"): Call
anti_adjust_stack_and_probe_stack_clash when stack clash
protection is enabled.
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 1833227..b489725 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -10996,6 +10996,8 @@ allocate_stack_space (rtx size, HOST_WIDE_INT last_probe_offset,
stack_pointer_rtx,
offset));
}
+ if (num_probes > 0)
+ last_probe_offset = INTVAL (offset);
dump_stack_clash_frame_info (PROBE_INLINE, residual != 0);
}
else
@@ -11029,6 +11031,7 @@ allocate_stack_space (rtx size, HOST_WIDE_INT last_probe_offset,
s390_prologue_plus_offset (stack_pointer_rtx, temp_reg,
const0_rtx, true);
temp_reg_clobbered_p = true;
+ last_probe_offset = INTVAL (offset);
dump_stack_clash_frame_info (PROBE_LOOP, residual != 0);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bb3e4c8..8ff0bbc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+ * gcc.target/s390/stack-clash-1.c: New test.
+
+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
* gcc.target/s390/stack-clash-3.c: New test.
2020-05-13 Kelvin Nilsen <kelvin@gcc.gnu.org>
diff --git a/gcc/testsuite/gcc.target/s390/stack-clash-1.c b/gcc/testsuite/gcc.target/s390/stack-clash-1.c
new file mode 100644
index 0000000..3d29cab
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/stack-clash-1.c
@@ -0,0 +1,17 @@
+/* Make sure a stack probe is emitted also for the remaining bytes
+ after the loop probing the large chunk. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=z9-ec -fstack-clash-protection" } */
+
+void large_stack() {
+ volatile int stack[8000];
+ int i;
+ for (i = 0; i < sizeof(stack) / sizeof(int); ++i)
+ stack[i] = i;
+}
+
+/* We use a compare for the stack probe. There needs to be one inside
+ a loop and another for the remaining bytes. */
+/* { dg-final { scan-assembler-times "cg\t" 2 { target lp64 } } } */
+/* { dg-final { scan-assembler-times "c\t" 2 { target { ! lp64 } } } } */