1 ; RUN: opt -pre-isel-intrinsic-lowering -S -o - %s | FileCheck %s
3 ; Make sure calls to the objc intrinsics are translated to calls in to the
6 define i8* @test_objc_autorelease(i8* %arg0) {
7 ; CHECK-LABEL: test_objc_autorelease
9 ; CHECK-NEXT: %0 = notail call i8* @objc_autorelease(i8* %arg0)
10 ; CHECK-NEXT: ret i8* %0
12 %0 = call i8* @llvm.objc.autorelease(i8* %arg0)
16 define void @test_objc_autoreleasePoolPop(i8* %arg0) {
17 ; CHECK-LABEL: test_objc_autoreleasePoolPop
19 ; CHECK-NEXT: call void @objc_autoreleasePoolPop(i8* %arg0)
20 ; CHECK-NEXT: ret void
22 call void @llvm.objc.autoreleasePoolPop(i8* %arg0)
26 define i8* @test_objc_autoreleasePoolPush() {
27 ; CHECK-LABEL: test_objc_autoreleasePoolPush
29 ; CHECK-NEXT: %0 = call i8* @objc_autoreleasePoolPush()
30 ; CHECK-NEXT: ret i8* %0
32 %0 = call i8* @llvm.objc.autoreleasePoolPush()
36 define i8* @test_objc_autoreleaseReturnValue(i8* %arg0) {
37 ; CHECK-LABEL: test_objc_autoreleaseReturnValue
39 ; CHECK-NEXT: %0 = tail call i8* @objc_autoreleaseReturnValue(i8* %arg0)
40 ; CHECK-NEXT: ret i8* %0
42 %0 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %arg0)
46 define void @test_objc_copyWeak(i8** %arg0, i8** %arg1) {
47 ; CHECK-LABEL: test_objc_copyWeak
49 ; CHECK-NEXT: call void @objc_copyWeak(i8** %arg0, i8** %arg1)
50 ; CHECK-NEXT: ret void
52 call void @llvm.objc.copyWeak(i8** %arg0, i8** %arg1)
56 define void @test_objc_destroyWeak(i8** %arg0) {
57 ; CHECK-LABEL: test_objc_destroyWeak
59 ; CHECK-NEXT: call void @objc_destroyWeak(i8** %arg0)
60 ; CHECK-NEXT: ret void
62 call void @llvm.objc.destroyWeak(i8** %arg0)
66 define i8* @test_objc_initWeak(i8** %arg0, i8* %arg1) {
67 ; CHECK-LABEL: test_objc_initWeak
69 ; CHECK-NEXT: %0 = call i8* @objc_initWeak(i8** %arg0, i8* %arg1)
70 ; CHECK-NEXT: ret i8* %0
72 %0 = call i8* @llvm.objc.initWeak(i8** %arg0, i8* %arg1)
76 define i8* @test_objc_loadWeak(i8** %arg0) {
77 ; CHECK-LABEL: test_objc_loadWeak
79 ; CHECK-NEXT: %0 = call i8* @objc_loadWeak(i8** %arg0)
80 ; CHECK-NEXT: ret i8* %0
82 %0 = call i8* @llvm.objc.loadWeak(i8** %arg0)
86 define i8* @test_objc_loadWeakRetained(i8** %arg0) {
87 ; CHECK-LABEL: test_objc_loadWeakRetained
89 ; CHECK-NEXT: %0 = call i8* @objc_loadWeakRetained(i8** %arg0)
90 ; CHECK-NEXT: ret i8* %0
92 %0 = call i8* @llvm.objc.loadWeakRetained(i8** %arg0)
96 define void @test_objc_moveWeak(i8** %arg0, i8** %arg1) {
97 ; CHECK-LABEL: test_objc_moveWeak
99 ; CHECK-NEXT: call void @objc_moveWeak(i8** %arg0, i8** %arg1)
100 ; CHECK-NEXT: ret void
102 call void @llvm.objc.moveWeak(i8** %arg0, i8** %arg1)
106 define void @test_objc_release(i8* %arg0) {
107 ; CHECK-LABEL: test_objc_release
109 ; CHECK-NEXT: call void @objc_release(i8* %arg0)
110 ; CHECK-NEXT: ret void
112 call void @llvm.objc.release(i8* %arg0)
116 define i8* @test_objc_retain(i8* %arg0) {
117 ; CHECK-LABEL: test_objc_retain
119 ; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %arg0)
120 ; CHECK-NEXT: ret i8* %0
122 %0 = call i8* @llvm.objc.retain(i8* %arg0)
126 define i8* @test_objc_retainAutorelease(i8* %arg0) {
127 ; CHECK-LABEL: test_objc_retainAutorelease
129 ; CHECK-NEXT: %0 = call i8* @objc_retainAutorelease(i8* %arg0)
130 ; CHECK-NEXT: ret i8* %0
132 %0 = call i8* @llvm.objc.retainAutorelease(i8* %arg0)
136 define i8* @test_objc_retainAutoreleaseReturnValue(i8* %arg0) {
137 ; CHECK-LABEL: test_objc_retainAutoreleaseReturnValue
139 ; CHECK-NEXT: %0 = tail call i8* @objc_retainAutoreleaseReturnValue(i8* %arg0)
140 ; CHECK-NEXT: ret i8* %0
142 %0 = tail call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* %arg0)
146 define i8* @test_objc_retainAutoreleasedReturnValue(i8* %arg0) {
147 ; CHECK-LABEL: test_objc_retainAutoreleasedReturnValue
149 ; CHECK-NEXT: %0 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %arg0)
150 ; CHECK-NEXT: ret i8* %0
152 %0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %arg0)
156 define i8* @test_objc_retainBlock(i8* %arg0) {
157 ; CHECK-LABEL: test_objc_retainBlock
159 ; CHECK-NEXT: %0 = call i8* @objc_retainBlock(i8* %arg0)
160 ; CHECK-NEXT: ret i8* %0
162 %0 = call i8* @llvm.objc.retainBlock(i8* %arg0)
166 define void @test_objc_storeStrong(i8** %arg0, i8* %arg1) {
167 ; CHECK-LABEL: test_objc_storeStrong
169 ; CHECK-NEXT: call void @objc_storeStrong(i8** %arg0, i8* %arg1)
170 ; CHECK-NEXT: ret void
172 call void @llvm.objc.storeStrong(i8** %arg0, i8* %arg1)
176 define i8* @test_objc_storeWeak(i8** %arg0, i8* %arg1) {
177 ; CHECK-LABEL: test_objc_storeWeak
179 ; CHECK-NEXT: %0 = call i8* @objc_storeWeak(i8** %arg0, i8* %arg1)
180 ; CHECK-NEXT: ret i8* %0
182 %0 = call i8* @llvm.objc.storeWeak(i8** %arg0, i8* %arg1)
186 define i8* @test_objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0) {
187 ; CHECK-LABEL: test_objc_unsafeClaimAutoreleasedReturnValue
189 ; CHECK-NEXT: %0 = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0)
190 ; CHECK-NEXT: ret i8* %0
192 %0 = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %arg0)
196 define i8* @test_objc_retainedObject(i8* %arg0) {
197 ; CHECK-LABEL: test_objc_retainedObject
199 ; CHECK-NEXT: %0 = call i8* @objc_retainedObject(i8* %arg0)
200 ; CHECK-NEXT: ret i8* %0
202 %0 = call i8* @llvm.objc.retainedObject(i8* %arg0)
206 define i8* @test_objc_unretainedObject(i8* %arg0) {
207 ; CHECK-LABEL: test_objc_unretainedObject
209 ; CHECK-NEXT: %0 = call i8* @objc_unretainedObject(i8* %arg0)
210 ; CHECK-NEXT: ret i8* %0
212 %0 = call i8* @llvm.objc.unretainedObject(i8* %arg0)
216 define i8* @test_objc_unretainedPointer(i8* %arg0) {
217 ; CHECK-LABEL: test_objc_unretainedPointer
219 ; CHECK-NEXT: %0 = call i8* @objc_unretainedPointer(i8* %arg0)
220 ; CHECK-NEXT: ret i8* %0
222 %0 = call i8* @llvm.objc.unretainedPointer(i8* %arg0)
226 define i8* @test_objc_retain_autorelease(i8* %arg0) {
227 ; CHECK-LABEL: test_objc_retain_autorelease
229 ; CHECK-NEXT: %0 = call i8* @objc_retain_autorelease(i8* %arg0)
230 ; CHECK-NEXT: ret i8* %0
232 %0 = call i8* @llvm.objc.retain.autorelease(i8* %arg0)
236 define i32 @test_objc_sync_enter(i8* %arg0) {
237 ; CHECK-LABEL: test_objc_sync_enter
239 ; CHECK-NEXT: %0 = call i32 @objc_sync_enter(i8* %arg0)
240 ; CHECK-NEXT: ret i32 %0
242 %0 = call i32 @llvm.objc.sync.enter(i8* %arg0)
246 define i32 @test_objc_sync_exit(i8* %arg0) {
247 ; CHECK-LABEL: test_objc_sync_exit
249 ; CHECK-NEXT: %0 = call i32 @objc_sync_exit(i8* %arg0)
250 ; CHECK-NEXT: ret i32 %0
252 %0 = call i32 @llvm.objc.sync.exit(i8* %arg0)
256 declare i8* @llvm.objc.autorelease(i8*)
257 declare void @llvm.objc.autoreleasePoolPop(i8*)
258 declare i8* @llvm.objc.autoreleasePoolPush()
259 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
260 declare void @llvm.objc.copyWeak(i8**, i8**)
261 declare void @llvm.objc.destroyWeak(i8**)
262 declare extern_weak i8* @llvm.objc.initWeak(i8**, i8*)
263 declare i8* @llvm.objc.loadWeak(i8**)
264 declare i8* @llvm.objc.loadWeakRetained(i8**)
265 declare void @llvm.objc.moveWeak(i8**, i8**)
266 declare void @llvm.objc.release(i8*)
267 declare i8* @llvm.objc.retain(i8*)
268 declare i8* @llvm.objc.retainAutorelease(i8*)
269 declare i8* @llvm.objc.retainAutoreleaseReturnValue(i8*)
270 declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
271 declare i8* @llvm.objc.retainBlock(i8*)
272 declare void @llvm.objc.storeStrong(i8**, i8*)
273 declare i8* @llvm.objc.storeWeak(i8**, i8*)
274 declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*)
275 declare i8* @llvm.objc.retainedObject(i8*)
276 declare i8* @llvm.objc.unretainedObject(i8*)
277 declare i8* @llvm.objc.unretainedPointer(i8*)
278 declare i8* @llvm.objc.retain.autorelease(i8*)
279 declare i32 @llvm.objc.sync.enter(i8*)
280 declare i32 @llvm.objc.sync.exit(i8*)
282 attributes #0 = { nounwind }
284 ; CHECK: declare i8* @objc_autorelease(i8*)
285 ; CHECK: declare void @objc_autoreleasePoolPop(i8*)
286 ; CHECK: declare i8* @objc_autoreleasePoolPush()
287 ; CHECK: declare i8* @objc_autoreleaseReturnValue(i8*)
288 ; CHECK: declare void @objc_copyWeak(i8**, i8**)
289 ; CHECK: declare void @objc_destroyWeak(i8**)
290 ; CHECK: declare extern_weak i8* @objc_initWeak(i8**, i8*)
291 ; CHECK: declare i8* @objc_loadWeak(i8**)
292 ; CHECK: declare i8* @objc_loadWeakRetained(i8**)
293 ; CHECK: declare void @objc_moveWeak(i8**, i8**)
294 ; CHECK: declare void @objc_release(i8*) [[NLB:#[0-9]+]]
295 ; CHECK: declare i8* @objc_retain(i8*) [[NLB]]
296 ; CHECK: declare i8* @objc_retainAutorelease(i8*)
297 ; CHECK: declare i8* @objc_retainAutoreleaseReturnValue(i8*)
298 ; CHECK: declare i8* @objc_retainAutoreleasedReturnValue(i8*)
299 ; CHECK: declare i8* @objc_retainBlock(i8*)
300 ; CHECK: declare void @objc_storeStrong(i8**, i8*)
301 ; CHECK: declare i8* @objc_storeWeak(i8**, i8*)
302 ; CHECK: declare i8* @objc_unsafeClaimAutoreleasedReturnValue(i8*)
303 ; CHECK: declare i8* @objc_retainedObject(i8*)
304 ; CHECK: declare i8* @objc_unretainedObject(i8*)
305 ; CHECK: declare i8* @objc_unretainedPointer(i8*)
306 ; CHECK: declare i8* @objc_retain_autorelease(i8*)
307 ; CHECK: declare i32 @objc_sync_enter(i8*)
308 ; CHECK: declare i32 @objc_sync_exit(i8*)
310 ; CHECK: attributes #0 = { nounwind }
311 ; CHECK: attributes [[NLB]] = { nonlazybind }