1 ; RUN: llc -o - %s | FileCheck --check-prefix=SELDAG --check-prefix=CHECK %s
2 ; RUN: llc -global-isel -o - %s | FileCheck --check-prefix=GISEL --check-prefix=CHECK %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5 target triple = "arm64-apple-ios"
10 declare void @llvm.objc.release(ptr)
11 declare void @objc_object(ptr)
13 declare void @foo2(ptr)
15 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
17 declare ptr @_ZN1SD1Ev(ptr nonnull dereferenceable(1))
19 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
22 %struct.S = type { i8 }
24 @g = dso_local global ptr null, align 8
25 @fptr = dso_local global ptr null, align 8
27 define dso_local ptr @rv_marker_1_retain() {
28 ; CHECK-LABEL: _rv_marker_1_retain:
30 ; CHECK-NEXT: mov x29, x29
31 ; CHECK-NEXT: bl _objc_retainAutoreleasedReturnValue
34 %call = call ptr @foo1() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
38 define dso_local ptr @rv_marker_1_unsafeClaim() {
39 ; CHECK-LABEL: _rv_marker_1_unsafeClaim:
41 ; CHECK-NEXT: mov x29, x29
42 ; CHECK-NEXT: bl _objc_unsafeClaimAutoreleasedReturnValue
45 %call = call ptr @foo1() [ "clang.arc.attachedcall"(ptr @objc_unsafeClaimAutoreleasedReturnValue) ]
49 define dso_local void @rv_marker_2_select(i32 %c) {
50 ; CHECK-LABEL: _rv_marker_2_select:
51 ; SELDAG: cinc w0, w8, eq
52 ; GISEL: csinc w0, w8, wzr, eq
53 ; CHECK-NEXT: bl _foo0
54 ; CHECK-NEXT: mov x29, x29
55 ; CHECK-NEXT: bl _objc_retainAutoreleasedReturnValue
56 ; CHECK-NEXT: ldp x29, x30, [sp], #16
60 %tobool.not = icmp eq i32 %c, 0
61 %.sink = select i1 %tobool.not, i32 2, i32 1
62 %call1 = call ptr @foo0(i32 %.sink) [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
63 tail call void @foo2(ptr %call1)
67 define dso_local void @rv_marker_3() personality ptr @__gxx_personality_v0 {
68 ; CHECK-LABEL: _rv_marker_3:
70 ; CHECK-NEXT: mov x29, x29
71 ; CHECK-NEXT: bl _objc_retainAutoreleasedReturnValue
74 %call = call ptr @foo1() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
75 invoke void @objc_object(ptr %call) #5
76 to label %invoke.cont unwind label %lpad
78 invoke.cont: ; preds = %entry
79 tail call void @llvm.objc.release(ptr %call)
82 lpad: ; preds = %entry
83 %0 = landingpad { ptr, i32 }
85 tail call void @llvm.objc.release(ptr %call)
86 resume { ptr, i32 } %0
89 define dso_local void @rv_marker_4() personality ptr @__gxx_personality_v0 {
90 ; CHECK-LABEL: _rv_marker_4:
92 ; CHECK-NEXT: bl _foo1
93 ; CHECK-NEXT: mov x29, x29
94 ; CHECK-NEXT: bl _objc_retainAutoreleasedReturnValue
98 %s = alloca %struct.S, align 1
99 call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %s) #2
100 %call = invoke ptr @foo1() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
101 to label %invoke.cont unwind label %lpad
103 invoke.cont: ; preds = %entry
104 invoke void @objc_object(ptr %call) #5
105 to label %invoke.cont2 unwind label %lpad1
107 invoke.cont2: ; preds = %invoke.cont
108 tail call void @llvm.objc.release(ptr %call)
109 %call3 = call ptr @_ZN1SD1Ev(ptr nonnull dereferenceable(1) %s)
110 call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %s)
113 lpad: ; preds = %entry
114 %0 = landingpad { ptr, i32 }
118 lpad1: ; preds = %invoke.cont
119 %1 = landingpad { ptr, i32 }
121 tail call void @llvm.objc.release(ptr %call)
124 ehcleanup: ; preds = %lpad1, %lpad
125 %.pn = phi { ptr, i32 } [ %1, %lpad1 ], [ %0, %lpad ]
126 %call4 = call ptr @_ZN1SD1Ev(ptr nonnull dereferenceable(1) %s)
127 call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %s)
128 resume { ptr, i32 } %.pn
131 define dso_local ptr @rv_marker_5_indirect_call() {
132 ; CHECK-LABEL: _rv_marker_5_indirect_call:
133 ; CHECK: ldr [[ADDR:x[0-9]+]], [
134 ; CHECK-NEXT: blr [[ADDR]]
135 ; CHECK-NEXT: mov x29, x29
136 ; CHECK-NEXT: bl _objc_retainAutoreleasedReturnValue
138 %0 = load ptr, ptr @fptr, align 8
139 %call = call ptr %0() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
140 tail call void @foo2(ptr %call)
144 declare ptr @foo(i64, i64, i64)
146 define dso_local void @rv_marker_multiarg(i64 %a, i64 %b, i64 %c) {
147 ; CHECK-LABEL: _rv_marker_multiarg:
148 ; CHECK: mov [[TMP:x[0-9]+]], x0
149 ; CHECK-NEXT: mov x0, x2
150 ; CHECK-NEXT: mov x2, [[TMP]]
151 ; CHECK-NEXT: bl _foo
152 ; CHECK-NEXT: mov x29, x29
153 ; CHECK-NEXT: bl _objc_retainAutoreleasedReturnValue
154 call ptr @foo(i64 %c, i64 %b, i64 %a) [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
158 declare ptr @objc_retainAutoreleasedReturnValue(ptr)
159 declare ptr @objc_unsafeClaimAutoreleasedReturnValue(ptr)
160 declare i32 @__gxx_personality_v0(...)