1; RUN: opt -S -objc-arc-apelim < %s | FileCheck %s
2; rdar://10227311
3
4@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 }]
5
6@x = global i32 0
7
8declare i32 @bar() nounwind
9
10define i32 @foo() nounwind {
11entry:
12  ret i32 5
13}
14
15define internal void @__cxx_global_var_init() {
16entry:
17  %call = call i32 @foo()
18  store i32 %call, i32* @x, align 4
19  ret void
20}
21
22define internal void @__dxx_global_var_init() {
23entry:
24  %call = call i32 @bar()
25  store i32 %call, i32* @x, align 4
26  ret void
27}
28
29; CHECK: define internal void @_GLOBAL__I_x() {
30; CHECK-NOT: @objc
31; CHECK: }
32define internal void @_GLOBAL__I_x() {
33entry:
34  %0 = call i8* @objc_autoreleasePoolPush() nounwind
35  call void @__cxx_global_var_init()
36  call void @objc_autoreleasePoolPop(i8* %0) nounwind
37  ret void
38}
39
40; CHECK: define internal void @_GLOBAL__I_y() {
41; CHECK: %0 = call i8* @objc_autoreleasePoolPush() [[NUW:#[0-9]+]]
42; CHECK: call void @objc_autoreleasePoolPop(i8* %0) [[NUW]]
43; CHECK: }
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
55; CHECK: attributes #0 = { nounwind }
56