[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / stack-clash-protection.c
blobb07e4c4ce90847523ed639171ac9fb5fbd8b79a5
1 // Check the correct function attributes are generated
2 // RUN: %clang_cc1 -triple x86_64-linux -O0 -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s
3 // RUN: %clang_cc1 -triple s390x-linux-gnu -O0 -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s
4 // RUN: %clang_cc1 -triple powerpc64le-linux-gnu -O0 -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s
5 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -O0 -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s
6 // RUN: %clang_cc1 -triple aarch64-linux-gnu -O0 -emit-llvm -o- %s -fstack-clash-protection -mstack-probe-size=8192 | FileCheck %s
8 // CHECK: define{{.*}} void @large_stack() #[[A:.*]] {
9 void large_stack(void) {
10 volatile int stack[20000], i;
11 for (i = 0; i < sizeof(stack) / sizeof(int); ++i)
12 stack[i] = i;
15 // CHECK: define{{.*}} void @vla({{.*}}) #[[A]] {
16 void vla(int n) {
17 volatile int vla[n];
18 __builtin_memset(&vla[0], 0, 1);
21 // CHECK: define{{.*}} void @builtin_alloca({{.*}}) #[[A]] {
22 void builtin_alloca(int n) {
23 volatile void *mem = __builtin_alloca(n);
26 // CHECK: attributes #[[A]] = {{.*}}"probe-stack"="inline-asm" {{.*}}"stack-probe-size"="8192"
28 // CHECK: !{i32 4, !"probe-stack", !"inline-asm"}
29 // CHECK: !{i32 8, !"stack-probe-size", i32 8192}