IBM Z: Define probe_stack expander
Probes emitted by the common code routines still use a store. Define the "probe_stack" pattern to use a compare instead. gcc/ChangeLog: 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. gcc/testsuite/ChangeLog: 2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com> * gcc.target/s390/stack-clash-2.c: New test.
This commit is contained in:
parent
868d351e23
commit
0473885be8
5 changed files with 46 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
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
|
||||
|
|
|
@ -10946,10 +10946,9 @@ s390_prologue_plus_offset (rtx target, rtx reg, rtx offset, bool frame_related_p
|
|||
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. */
|
||||
|
|
|
@ -11017,8 +11017,22 @@
|
|||
|
||||
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.
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
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.
|
||||
|
|
17
gcc/testsuite/gcc.target/s390/stack-clash-2.c
Normal file
17
gcc/testsuite/gcc.target/s390/stack-clash-2.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* { 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 } } } } */
|
Loading…
Add table
Reference in a new issue