xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/global-dtor-no-atexit.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64 %s -fno-use-cxa-atexit -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR7097
4*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64 %s -fno-use-cxa-atexit -mconstructor-aliases -emit-llvm -o - | FileCheck %s
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AC1Ev([[A:%.*]]* @a)
7*f4a2713aSLionel Sambuc // CHECK-NEXT: call i32 @atexit(void ()* @__dtor_a)
8*f4a2713aSLionel Sambuc // CHECK:      define internal void @__dtor_a() [[NUW:#[0-9]+]]
9*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AD1Ev([[A]]* @a)
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AC1Ev([[A]]* @b)
12*f4a2713aSLionel Sambuc // CHECK-NEXT: call i32 @atexit(void ()* @__dtor_b)
13*f4a2713aSLionel Sambuc // CHECK:      define internal void @__dtor_b() [[NUW]]
14*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AD1Ev([[A]]* @b)
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc class A {
17*f4a2713aSLionel Sambuc public:
18*f4a2713aSLionel Sambuc   A();
19*f4a2713aSLionel Sambuc   ~A();
20*f4a2713aSLionel Sambuc };
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc A a, b;
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // PR9593
25*f4a2713aSLionel Sambuc // CHECK-LABEL:      define void @_Z4funcv()
26*f4a2713aSLionel Sambuc // CHECK:      call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a1)
27*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a1)
28*f4a2713aSLionel Sambuc // CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a1)
29*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a1)
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc // CHECK:      call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a2)
32*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a2)
33*f4a2713aSLionel Sambuc // CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a2)
34*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a2)
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc // CHECK:      define internal void @__dtor__ZZ4funcvE2a1() [[NUW]]
37*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a1)
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc // CHECK:      define internal void @__dtor__ZZ4funcvE2a2() [[NUW]]
40*f4a2713aSLionel Sambuc // CHECK:      call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a2)
41*f4a2713aSLionel Sambuc 
func()42*f4a2713aSLionel Sambuc void func() {
43*f4a2713aSLionel Sambuc   static A a1, a2;
44*f4a2713aSLionel Sambuc }
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc // CHECK: attributes [[NUW]] = { nounwind }
47