1; RUN: opt -S -objc-arc-apelim < %s | FileCheck %s
2
3; See PR26774
4
5@llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_x }, { i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_y }]
6
7@x = global i32 0
8
9declare i32 @bar() nounwind
10
11define linkonce_odr i32 @foo() nounwind {
12entry:
13  ret i32 5
14}
15
16define internal void @__cxx_global_var_init() {
17entry:
18  %call = call i32 @foo()
19  store i32 %call, i32* @x, align 4
20  ret void
21}
22
23define internal void @__dxx_global_var_init() {
24entry:
25  %call = call i32 @bar()
26  store i32 %call, i32* @x, align 4
27  ret void
28}
29
30; CHECK-LABEL: define internal void @_GLOBAL__I_x() {
31define internal void @_GLOBAL__I_x() {
32entry:
33; CHECK:  call i8* @objc_autoreleasePoolPush()
34; CHECK-NEXT:  call void @__cxx_global_var_init()
35; CHECK-NEXT:  call void @objc_autoreleasePoolPop(i8* %0)
36; CHECK-NEXT:  ret void
37
38  %0 = call i8* @objc_autoreleasePoolPush() nounwind
39  call void @__cxx_global_var_init()
40  call void @objc_autoreleasePoolPop(i8* %0) nounwind
41  ret void
42}
43
44define internal void @_GLOBAL__I_y() {
45entry:
46  %0 = call i8* @objc_autoreleasePoolPush() nounwind
47  call void @__dxx_global_var_init()
48  call void @objc_autoreleasePoolPop(i8* %0) nounwind
49  ret void
50}
51
52declare i8* @objc_autoreleasePoolPush()
53declare void @objc_autoreleasePoolPop(i8*)
54