1 /* The goal here is to ensure that dynamic allocations via vlas or
2 alloca calls receive probing.
4 Scanning the RTL or assembly code seems like insanity here as does
5 checking for particular allocation sizes and probe offsets. For
6 now we just verify that there's an allocation + probe loop and
7 residual allocation + probe for f?. */
9 /* { dg-do compile } */
10 /* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-expand -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */
11 /* { dg-require-effective-target supports_stack_clash_protection } */
13 __attribute__((noinline
, noclone
)) void
16 asm volatile ("" : : "r" (p
) : "memory");
19 /* Simple VLA, no other locals. */
20 __attribute__((noinline
, noclone
)) void
27 /* Simple VLA, small local frame. */
28 __attribute__((noinline
, noclone
)) void
36 /* Small constant alloca, no other locals. */
37 __attribute__((noinline
, noclone
)) void
40 char *vla
= __builtin_alloca (128);
44 /* Big constant alloca, small local frame. */
45 __attribute__((noinline
, noclone
)) void
49 char *vla
= __builtin_alloca (16384);
53 /* Big constant alloca, small local frame. */
54 __attribute__((noinline
, noclone
)) void
58 char *vla
= __builtin_alloca (32768);
62 /* Nonconstant alloca, no other locals. */
63 __attribute__((noinline
, noclone
)) void
66 char *vla
= __builtin_alloca (x
);
70 /* Nonconstant alloca, small local frame. */
71 __attribute__((noinline
, noclone
)) void
75 char *vla
= __builtin_alloca (x
);
79 /* { dg-final { scan-rtl-dump-times "allocation and probing residuals" 7 "expand" } } */
82 /* { dg-final { scan-rtl-dump-times "allocation and probing in loop" 7 "expand" { target callee_realigns_stack } } } */
83 /* { dg-final { scan-rtl-dump-times "allocation and probing in loop" 4 "expand" { target { ! callee_realigns_stack } } } } */
84 /* { dg-final { scan-rtl-dump-times "allocation and probing in rotated loop" 1 "expand" { target { ! callee_realigns_stack } } } } */
85 /* { dg-final { scan-rtl-dump-times "allocation and probing inline" 1 "expand" { target { ! callee_realigns_stack } } } } */
86 /* { dg-final { scan-rtl-dump-times "skipped dynamic allocation and probing loop" 1 "expand" { target { ! callee_realigns_stack } } } } */