IBM Z: Fix mode in probe_stack pattern

The probe pattern uses Pmode but the middle-end wants to emit a
word_mode probe check.  This - as usual - breaks on Z with -m31
-mzarch were word_mode doesn't match Pmode.

gcc/ChangeLog:

	* config/s390/s390.md ("@probe_stack2<mode>"): Change mode
	iterator to W.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/stack-clash-4.c: New test.
This commit is contained in:
Andreas Krebbel 2020-12-03 17:04:11 +01:00
parent 62fb1b9e0d
commit 65af6bc9f8
2 changed files with 13 additions and 3 deletions

View File

@ -11116,8 +11116,8 @@
(define_expand "@probe_stack2<mode>"
[(set (reg:CCZ CC_REGNUM)
(compare:CCZ (reg:P 0)
(match_operand 0 "memory_operand")))
(compare:CCZ (reg:W 0)
(match_operand:W 0 "memory_operand")))
(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
"")
@ -11125,7 +11125,7 @@
[(match_operand 0 "memory_operand")]
""
{
emit_insn (gen_probe_stack2 (Pmode, operands[0]));
emit_insn (gen_probe_stack2 (word_mode, operands[0]));
DONE;
})

View File

@ -0,0 +1,10 @@
/* { dg-do compile } */
/* { dg-options "-O1 -m31 -mzarch -fstack-clash-protection" } */
extern void c(char*);
void
a() {
char *b = __builtin_alloca(3);
c(b);
}