Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / stack-protector.c
blob9b93f775ffe799c267679c5fac21fc29f286654e
1 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=NOSSP %s
2 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SSP %s
3 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SSPSTRONG %s
4 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SSPREQ %s
6 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s
7 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s
8 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSP %s
9 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPSTRONG %s
10 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPREQ %s
12 typedef __SIZE_TYPE__ size_t;
14 int printf(const char * _Format, ...);
15 size_t strlen(const char *s);
16 char *strcpy(char *s1, const char *s2);
18 // DEF: define {{.*}}void @test1(ptr noundef %msg) #[[A:.*]] {
19 void test1(const char *msg) {
20 char a[strlen(msg) + 1];
21 strcpy(a, msg);
22 printf("%s\n", a);
25 // DEF: define {{.*}}void @test2(ptr noundef %msg) #[[B:.*]] {
26 __attribute__((no_stack_protector))
27 void test2(const char *msg) {
28 char a[strlen(msg) + 1];
29 strcpy(a, msg);
30 printf("%s\n", a);
33 // NOSSP-NOT: attributes #[[A]] = {{.*}} ssp
34 // SSP: attributes #[[A]] = {{.*}} ssp{{ }}
35 // SSPSTRONG: attributes #[[A]] = {{.*}} sspstrong
36 // SSPREQ: attributes #[[A]] = {{.*}} sspreq
38 // SAFESTACK-NOSSP: attributes #[[A]] = {{.*}} safestack
39 // SAFESTACK-NOSSP-NOT: ssp
41 // SAFESTACK-SSP: attributes #[[A]] = {{.*}} safestack ssp{{ }}
42 // SAFESTACK-SSPSTRONG: attributes #[[A]] = {{.*}} safestack sspstrong
43 // SAFESTACK-SSPREQ: attributes #[[A]] = {{.*}} safestack sspreq
45 // NOSSP-NOT: attributes #[[B]] = {{.*}} ssp
46 // SSP-NOT: attributes #[[B]] = {{.*}} ssp{{ }}
47 // SSPSTRONG-NOT: attributes #[[B]] = {{.*}} sspstrong
48 // SSPREQ-NOT: attributes #[[B]] = {{.*}} sspreq
50 // SAFESTACK-SSP: attributes #[[B]] = {{.*}} safestack
51 // SAFESTACK-SSP-NOT: attributes #[[B]] = {{.*}} safestack ssp{{ }}
52 // SAFESTACK-SSPSTRONG: attributes #[[B]] = {{.*}} safestack
53 // SAFESTACK-SSPSTRONG-NOT: attributes #[[B]] = {{.*}} safestack sspstrong
54 // SAFESTACK-SSPREQ: attributes #[[B]] = {{.*}} safestack
55 // SAFESTACK-SSPREQ-NOT: attributes #[[B]] = {{.*}} safestack sspreq