diff options
author | Jeff Law <law@redhat.com> | 2017-09-19 23:05:12 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-09-19 23:05:12 -0600 |
commit | 8c1dd97000d801abc8c9119304be6bf30c5316c0 (patch) | |
tree | 64eab318b17653e4aec6415328b0b93032cd88c6 /gcc/testsuite | |
parent | ee8f15c69e324cdb1fa553ac14f760f799c425e2 (diff) | |
download | gcc-8c1dd97000d801abc8c9119304be6bf30c5316c0.zip gcc-8c1dd97000d801abc8c9119304be6bf30c5316c0.tar.gz gcc-8c1dd97000d801abc8c9119304be6bf30c5316c0.tar.bz2 |
explow.c: Include "params.h".
2017-09-18 Jeff Law <law@redhat.com>
* explow.c: Include "params.h".
(anti_adjust_stack_and_probe_stack_clash): New function.
(get_stack_check_protect): Likewise.
(compute_stack_clash_protection_loop_data): Likewise.
(emit_stack_clash_protection_loop_start): Likewise.
(emit_stack_clash_protection_loop_end): Likewise.
(allocate_dynamic_stack_space): Use get_stack_check_protect.
Use anti_adjust_stack_and_probe_stack_clash.
* explow.h (compute_stack_clash_protection_loop_data): Prototype.
(emit_stack_clash_protection_loop_start): Likewise.
(emit_stack_clash_protection_loop_end): Likewise.
* rtl.h (get_stack_check_protect): Prototype.
* target.def (stack_clash_protection_final_dynamic_probe): New hook.
* targhooks.c (default_stack_clash_protection_final_dynamic_probe): New.
* targhooks.h (default_stack_clash_protection_final_dynamic_probe):
Prototype.
* doc/tm.texi.in (TARGET_STACK_CLASH_PROTECTION_FINAL_DYNAMIC_PROBE):
Add @hook.
* doc/tm.texi: Rebuilt.
* config/aarch64/aarch64.c (aarch64_expand_prologue): Use
get_stack_check_protect.
* config/alpha/alpha.c (alpha_expand_prologue): Likewise.
* config/arm/arm.c (arm_expand_prologue): Likewise.
(arm_frame_pointer_required): Likewise.
* config/i386/i386.c (ix86_expand_prologue): Likewise.
* config/ia64/ia64.c (ia64_expand_prologue): Likewise.
* config/mips/mips.c (mips_expand_prologue): Likewise.
* config/powerpcspe/powerpcspe.c (rs6000_emit_prologue): Likewise.
* config/rs6000/rs6000.c (rs6000_emit_prologue): Likewise.
* config/sparc/sparc.c (sparc_expand_prologue): Likewise.
(sparc_flat_expand_prologue): Likewise.
* gcc.dg/stack-check-3.c: New test.
From-SVN: r252995
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/stack-check-3.c | 86 |
2 files changed, 88 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a77b546..2219564 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2017-09-19 Jeff Law <law@redhat.com> + * gcc.dg/stack-check-3.c: New test. + * gcc.dg/stack-check-2.c: New test. * lib/target-supports.exp (check_effective_target_supports_stack_clash_protection): New function. diff --git a/gcc/testsuite/gcc.dg/stack-check-3.c b/gcc/testsuite/gcc.dg/stack-check-3.c new file mode 100644 index 0000000..58fb656 --- /dev/null +++ b/gcc/testsuite/gcc.dg/stack-check-3.c @@ -0,0 +1,86 @@ +/* The goal here is to ensure that dynamic allocations via vlas or + alloca calls receive probing. + + Scanning the RTL or assembly code seems like insanity here as does + checking for particular allocation sizes and probe offsets. For + now we just verify that there's an allocation + probe loop and + residual allocation + probe for f?. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-expand -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=4096 --param stack-clash-protection-guard-size=4096" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +__attribute__((noinline, noclone)) void +foo (char *p) +{ + asm volatile ("" : : "r" (p) : "memory"); +} + +/* Simple VLA, no other locals. */ +__attribute__((noinline, noclone)) void +f0 (int x) +{ + char vla[x]; + foo (vla); +} + +/* Simple VLA, small local frame. */ +__attribute__((noinline, noclone)) void +f1 (int x) +{ + char locals[128]; + char vla[x]; + foo (vla); +} + +/* Small constant alloca, no other locals. */ +__attribute__((noinline, noclone)) void +f2 (int x) +{ + char *vla = __builtin_alloca (128); + foo (vla); +} + +/* Big constant alloca, small local frame. */ +__attribute__((noinline, noclone)) void +f3 (int x) +{ + char locals[128]; + char *vla = __builtin_alloca (16384); + foo (vla); +} + +/* Big constant alloca, small local frame. */ +__attribute__((noinline, noclone)) void +f3a (int x) +{ + char locals[128]; + char *vla = __builtin_alloca (32768); + foo (vla); +} + +/* Nonconstant alloca, no other locals. */ +__attribute__((noinline, noclone)) void +f4 (int x) +{ + char *vla = __builtin_alloca (x); + foo (vla); +} + +/* Nonconstant alloca, small local frame. */ +__attribute__((noinline, noclone)) void +f5 (int x) +{ + char locals[128]; + char *vla = __builtin_alloca (x); + foo (vla); +} + +/* { dg-final { scan-rtl-dump-times "allocation and probing residuals" 7 "expand" } } */ + + +/* { dg-final { scan-rtl-dump-times "allocation and probing in loop" 7 "expand" { target callee_realigns_stack } } } */ +/* { dg-final { scan-rtl-dump-times "allocation and probing in loop" 4 "expand" { target { ! callee_realigns_stack } } } } */ +/* { dg-final { scan-rtl-dump-times "allocation and probing in rotated loop" 1 "expand" { target { ! callee_realigns_stack } } } } */ +/* { dg-final { scan-rtl-dump-times "allocation and probing inline" 1 "expand" { target { ! callee_realigns_stack } } } } */ +/* { dg-final { scan-rtl-dump-times "skipped dynamic allocation and probing loop" 1 "expand" { target { ! callee_realigns_stack } } } } */ |