no_destroy.cpp
2.32 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,NO_EXCEPTIONS
// RUN: %clang_cc1 -fexceptions %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,EXCEPTIONS
struct NonTrivial {
~NonTrivial();
};
// CHECK-NOT: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
[[clang::no_destroy]] NonTrivial nt1;
// CHECK-NOT: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
[[clang::no_destroy]] thread_local NonTrivial nt2;
struct NonTrivial2 {
~NonTrivial2();
};
// CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev{{.*}}nt21
NonTrivial2 nt21;
// CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev{{.*}}nt22
thread_local NonTrivial2 nt22;
// CHECK-LABEL: define void @_Z1fv
void f() {
// CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
static NonTrivial2 nt21;
// CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev
thread_local NonTrivial2 nt22;
}
// CHECK-LABEL: define void @_Z1gv
void g() {
// CHECK-NOT: __cxa_atexit
[[clang::no_destroy]] static NonTrivial2 nt21;
// CHECK-NOT: _tlv_atexit
[[clang::no_destroy]] thread_local NonTrivial2 nt22;
}
// CHECK-LABEL: define internal void @__cxx_global_var_init
// CHECK: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
[[clang::always_destroy]] NonTrivial nt3;
// CHECK-LABEL: define internal void @__cxx_global_var_init
// CHECK: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
[[clang::always_destroy]] thread_local NonTrivial nt4;
struct NonTrivial3 {
NonTrivial3();
~NonTrivial3();
};
[[clang::no_destroy]] NonTrivial3 arr[10];
// CHECK-LABEL: define internal void @__cxx_global_var_init
// CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
// EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
// NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
// CHECK-NOT: call i32 @__cxa_atexit
void h() {
[[clang::no_destroy]] static NonTrivial3 slarr[10];
}
// CHECK-LABEL: define void @_Z1hv
// CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
// EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
// NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
// CHECK-NOT: call i32 @__cxa_atexit
void i() {
[[clang::no_destroy]] thread_local NonTrivial3 tlarr[10];
}
// CHECK-LABEL: define void @_Z1iv
// CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
// EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
// NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
// CHECK-NOT: _tlv_atexit