+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
+ * config/s390/s390.c (s390_emit_stack_probe): Call the probe_stack
+ expander.
+ * config/s390/s390.md ("@probe_stack2<mode>", "probe_stack"): New
+ expanders.
+
2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
* config/s390/s390.c (allocate_stack_space): Add missing updates
static void
s390_emit_stack_probe (rtx addr)
{
- rtx tmp = gen_rtx_MEM (Pmode, addr);
- MEM_VOLATILE_P (tmp) = 1;
- s390_emit_compare (EQ, gen_rtx_REG (Pmode, 0), tmp);
- emit_insn (gen_blockage ());
+ rtx mem = gen_rtx_MEM (Pmode, addr);
+ MEM_VOLATILE_P (mem) = 1;
+ emit_insn (gen_probe_stack (mem));
}
/* Use a runtime loop if we have to emit more probes than this. */
emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
DONE;
-})
+ })
+
+(define_expand "@probe_stack2<mode>"
+ [(set (reg:CCZ CC_REGNUM)
+ (compare:CCZ (reg:P 0)
+ (match_operand 0 "memory_operand")))
+ (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
+ "")
+(define_expand "probe_stack"
+ [(match_operand 0 "memory_operand")]
+ ""
+{
+ emit_insn (gen_probe_stack2 (Pmode, operands[0]));
+ DONE;
+})
;
; setjmp instruction pattern.
+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
+ * gcc.target/s390/stack-clash-2.c: New test.
+
2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
* gcc.target/s390/stack-clash-1.c: New test.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=z900 -fstack-clash-protection" } */
+
+extern void bar (char *);
+
+void
+foo ()
+{
+ char * mem = __builtin_alloca (20000);
+ bar (mem);
+}
+
+/* For alloca a common code routine emits the probes. Make sure the
+ "probe_stack" expander is used in that case. We want to use mem
+ compares instead of stores. */
+/* { dg-final { scan-assembler-times "cg\t" 5 { target lp64 } } } */
+/* { dg-final { scan-assembler-times "c\t" 5 { target { ! lp64 } } } } */