xref: /aosp_15_r20/external/llvm/test/Transforms/ObjCARC/apelim.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -objc-arc-apelim < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; rdar://10227311
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker@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*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker@x = global i32 0
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdeclare i32 @bar() nounwind
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine i32 @foo() nounwind {
11*9880d681SAndroid Build Coastguard Workerentry:
12*9880d681SAndroid Build Coastguard Worker  ret i32 5
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workerdefine internal void @__cxx_global_var_init() {
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  %call = call i32 @foo()
18*9880d681SAndroid Build Coastguard Worker  store i32 %call, i32* @x, align 4
19*9880d681SAndroid Build Coastguard Worker  ret void
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdefine internal void @__dxx_global_var_init() {
23*9880d681SAndroid Build Coastguard Workerentry:
24*9880d681SAndroid Build Coastguard Worker  %call = call i32 @bar()
25*9880d681SAndroid Build Coastguard Worker  store i32 %call, i32* @x, align 4
26*9880d681SAndroid Build Coastguard Worker  ret void
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; CHECK: define internal void @_GLOBAL__I_x() {
30*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: @objc
31*9880d681SAndroid Build Coastguard Worker; CHECK: }
32*9880d681SAndroid Build Coastguard Workerdefine internal void @_GLOBAL__I_x() {
33*9880d681SAndroid Build Coastguard Workerentry:
34*9880d681SAndroid Build Coastguard Worker  %0 = call i8* @objc_autoreleasePoolPush() nounwind
35*9880d681SAndroid Build Coastguard Worker  call void @__cxx_global_var_init()
36*9880d681SAndroid Build Coastguard Worker  call void @objc_autoreleasePoolPop(i8* %0) nounwind
37*9880d681SAndroid Build Coastguard Worker  ret void
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker; CHECK: define internal void @_GLOBAL__I_y() {
41*9880d681SAndroid Build Coastguard Worker; CHECK: %0 = call i8* @objc_autoreleasePoolPush() [[NUW:#[0-9]+]]
42*9880d681SAndroid Build Coastguard Worker; CHECK: call void @objc_autoreleasePoolPop(i8* %0) [[NUW]]
43*9880d681SAndroid Build Coastguard Worker; CHECK: }
44*9880d681SAndroid Build Coastguard Workerdefine internal void @_GLOBAL__I_y() {
45*9880d681SAndroid Build Coastguard Workerentry:
46*9880d681SAndroid Build Coastguard Worker  %0 = call i8* @objc_autoreleasePoolPush() nounwind
47*9880d681SAndroid Build Coastguard Worker  call void @__dxx_global_var_init()
48*9880d681SAndroid Build Coastguard Worker  call void @objc_autoreleasePoolPop(i8* %0) nounwind
49*9880d681SAndroid Build Coastguard Worker  ret void
50*9880d681SAndroid Build Coastguard Worker}
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerdeclare i8* @objc_autoreleasePoolPush()
53*9880d681SAndroid Build Coastguard Workerdeclare void @objc_autoreleasePoolPop(i8*)
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #0 = { nounwind }
56