xref: /llvm-project/llvm/test/Transforms/GlobalOpt/cxx-dtor.ll (revision d586bd5ca231a6022f439d4c6e43cfeeb53eb1d6)
1; RUN: opt < %s -S -passes='cgscc(inline),function(early-cse),globalopt' | FileCheck %s
2
3%0 = type { i32, ptr, ptr }
4%struct.A = type { i8 }
5%struct.B = type { }
6
7@a = global %struct.A zeroinitializer, align 1
8@__dso_handle = external global ptr
9@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @_GLOBAL__I_a, ptr null }]
10
11; CHECK-NOT: call i32 @__cxa_atexit
12
13define internal void @__cxx_global_var_init() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" {
14  %1 = call i32 @__cxa_atexit(ptr @_ZN1AD1Ev, ptr @a, ptr @__dso_handle)
15  ret void
16}
17
18define linkonce_odr void @_ZN1AD1Ev(ptr %this) nounwind align 2 {
19  call void @_ZN1BD1Ev(ptr %this)
20  ret void
21}
22
23declare i32 @__cxa_atexit(ptr, ptr, ptr)
24
25define linkonce_odr void @_ZN1BD1Ev(ptr %this) nounwind align 2 {
26  ret void
27}
28
29define internal void @_GLOBAL__I_a() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" {
30  call void @__cxx_global_var_init()
31  ret void
32}
33