Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / memtag-globals.cpp
blobae2d32ae8a56d9179d03bafcb09daef80455c10f
1 // RUN: %clang_cc1 -triple aarch64-linux-android34 \
2 // RUN: -include %S/Inputs/sanitizer-extra-source.cpp \
3 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \
4 // RUN: -fsanitize=memtag-globals -emit-llvm -o - %s | FileCheck %s
6 // RUN: %clang_cc1 -triple aarch64-linux-android34 \
7 // RUN: -include %S/Inputs/sanitizer-extra-source.cpp \
8 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-src.txt \
9 // RUN: -fsanitize=memtag-globals -emit-llvm -o - %s | \
10 // RUN: FileCheck %s --check-prefix=IGNORELIST
12 int global;
13 int __attribute__((no_sanitize("memtag"))) attributed_global;
14 int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
15 int ignorelisted_global;
16 extern int external_global;
18 void func() {
19 static int static_var = 0;
20 const char *literal = "Hello, world!";
21 external_global = 1;
24 // CHECK: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
25 // CHECK: @{{.*}}global{{.*}} ={{.*}} sanitize_memtag
27 // CHECK: @{{.*}}attributed_global{{.*}} =
28 // CHECK-NOT: sanitize_memtag
29 // CHECK: @{{.*}}disable_instrumentation_global{{.*}} =
30 // CHECK-NOT: sanitize_memtag
31 // CHECK: @{{.*}}ignorelisted_global{{.*}} =
32 // CHECK-NOT: sanitize_memtag
34 // CHECK: @{{.*}}static_var{{.*}} ={{.*}} sanitize_memtag
35 // CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} sanitize_memtag
36 // CHECK: @{{.*}}external_global{{.*}} ={{.*}} sanitize_memtag
38 // IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
40 // IGNORELIST: @{{.*}}global{{.*}} =
41 // IGNORELIST-NOT: sanitize_memtag
42 // IGNORELIST: @{{.*}}attributed_global{{.*}} =
43 // IGNORELIST-NOT: sanitize_memtag
44 // IGNORELIST: @{{.*}}disable_instrumentation_global{{.*}} =
45 // IGNORELIST-NOT: sanitize_memtag
46 // IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} =
47 // IGNORELIST-NOT: sanitize_memtag
48 // IGNORELIST: @{{.*}}static_var{{.*}} =
49 // IGNORELIST-NOT: sanitize_memtag
50 // IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}
51 // IGNORELIST-NOT: sanitize_memtag
52 // IGNORELIST: @{{.*}}external_global{{.*}} =
53 // IGNORELIST-NOT: sanitize_memtag