blob: 2dec3c48c6eb8a96897586796ef29851c23d4b8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
// RUN: echo "src:%s" > %t
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=thread -fsanitize-blacklist=%t | FileCheck -check-prefix=BL %s
// REQUIRES: shell
// The sanitize_thread attribute should be attached to functions
// when ThreadSanitizer is enabled, unless no_sanitize_thread attribute
// is present.
// WITHOUT: NoTSAN1{{.*}}) #[[NOATTR:[0-9]+]]
// BL: NoTSAN1{{.*}}) #[[NOATTR:[0-9]+]]
// TSAN: NoTSAN1{{.*}}) #[[NOATTR:[0-9]+]]
__attribute__((no_sanitize_thread))
int NoTSAN1(int *a) { return *a; }
// WITHOUT: NoTSAN2{{.*}}) #[[NOATTR]]
// BL: NoTSAN2{{.*}}) #[[NOATTR]]
// TSAN: NoTSAN2{{.*}}) #[[NOATTR]]
__attribute__((no_sanitize_thread))
int NoTSAN2(int *a);
int NoTSAN2(int *a) { return *a; }
// WITHOUT: TSANOk{{.*}}) #[[NOATTR]]
// BL: TSANOk{{.*}}) #[[NOATTR]]
// TSAN: TSANOk{{.*}}) #[[WITH:[0-9]+]]
int TSANOk(int *a) { return *a; }
// WITHOUT: TemplateTSANOk{{.*}}) #[[NOATTR]]
// BL: TemplateTSANOk{{.*}}) #[[NOATTR]]
// TSAN: TemplateTSANOk{{.*}}) #[[WITH]]
template<int i>
int TemplateTSANOk() { return i; }
// WITHOUT: TemplateNoTSAN{{.*}}) #[[NOATTR]]
// BL: TemplateNoTSAN{{.*}}) #[[NOATTR]]
// TSAN: TemplateNoTSAN{{.*}}) #[[NOATTR]]
template<int i>
__attribute__((no_sanitize_thread))
int TemplateNoTSAN() { return i; }
int force_instance = TemplateTSANOk<42>()
+ TemplateNoTSAN<42>();
// Check that __cxx_global_var_init* get the sanitize_thread attribute.
int global1 = 0;
int global2 = *(int*)((char*)&global1+1);
// WITHOUT: @__cxx_global_var_init{{.*}}#[[NOATTR]]
// BL: @__cxx_global_var_init{{.*}}#[[NOATTR]]
// TSAN: @__cxx_global_var_init{{.*}}#[[WITH]]
// WITHOUT: attributes #[[NOATTR]] = { nounwind{{.*}} }
// BL: attributes #[[NOATTR]] = { nounwind{{.*}} }
// TSAN: attributes #[[NOATTR]] = { nounwind{{.*}} }
// TSAN: attributes #[[WITH]] = { nounwind{{.*}} sanitize_thread
|