1 ; RUN: opt -pre-isel-intrinsic-lowering -S -o - %s | FileCheck %s
2 ; RUN: opt -passes='pre-isel-intrinsic-lowering' -S -o - %s | FileCheck %s
4 ; Make sure calls to the objc intrinsics are translated to calls in to the
7 define i8* @test_objc_autorelease(i8* %arg0) {
8 ; CHECK-LABEL: test_objc_autorelease
10 ; CHECK-NEXT: %0 = call i8* @objc_autorelease(i8* %arg0)
11 ; CHECK-NEXT: ret i8* %0
13 %0 = call i8* @llvm.objc.autorelease(i8* %arg0)
17 define void @test_objc_autoreleasePoolPop(i8* %arg0) {
18 ; CHECK-LABEL: test_objc_autoreleasePoolPop
20 ; CHECK-NEXT: call void @objc_autoreleasePoolPop(i8* %arg0)
21 ; CHECK-NEXT: ret void
23 call void @llvm.objc.autoreleasePoolPop(i8* %arg0)
27 define i8* @test_objc_autoreleasePoolPush() {
28 ; CHECK-LABEL: test_objc_autoreleasePoolPush
30 ; CHECK-NEXT: %0 = call i8* @objc_autoreleasePoolPush()
31 ; CHECK-NEXT: ret i8* %0
33 %0 = call i8* @llvm.objc.autoreleasePoolPush()
37 define i8* @test_objc_autoreleaseReturnValue(i8* %arg0) {
38 ; CHECK-LABEL: test_objc_autoreleaseReturnValue
40 ; CHECK-NEXT: %0 = call i8* @objc_autoreleaseReturnValue(i8* %arg0)
41 ; CHECK-NEXT: ret i8* %0
43 %0 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %arg0)
47 define void @test_objc_copyWeak(i8** %arg0, i8** %arg1) {
48 ; CHECK-LABEL: test_objc_copyWeak
50 ; CHECK-NEXT: call void @objc_copyWeak(i8** %arg0, i8** %arg1)
51 ; CHECK-NEXT: ret void
53 call void @llvm.objc.copyWeak(i8** %arg0, i8** %arg1)
57 define void @test_objc_destroyWeak(i8** %arg0) {
58 ; CHECK-LABEL: test_objc_destroyWeak
60 ; CHECK-NEXT: call void @objc_destroyWeak(i8** %arg0)
61 ; CHECK-NEXT: ret void
63 call void @llvm.objc.destroyWeak(i8** %arg0)
67 define i8* @test_objc_initWeak(i8** %arg0, i8* %arg1) {
68 ; CHECK-LABEL: test_objc_initWeak
70 ; CHECK-NEXT: %0 = call i8* @objc_initWeak(i8** %arg0, i8* %arg1)
71 ; CHECK-NEXT: ret i8* %0
73 %0 = call i8* @llvm.objc.initWeak(i8** %arg0, i8* %arg1)
77 define i8* @test_objc_loadWeak(i8** %arg0) {
78 ; CHECK-LABEL: test_objc_loadWeak
80 ; CHECK-NEXT: %0 = call i8* @objc_loadWeak(i8** %arg0)
81 ; CHECK-NEXT: ret i8* %0
83 %0 = call i8* @llvm.objc.loadWeak(i8** %arg0)
87 define i8* @test_objc_loadWeakRetained(i8** %arg0) {
88 ; CHECK-LABEL: test_objc_loadWeakRetained
90 ; CHECK-NEXT: %0 = call i8* @objc_loadWeakRetained(i8** %arg0)
91 ; CHECK-NEXT: ret i8* %0
93 %0 = call i8* @llvm.objc.loadWeakRetained(i8** %arg0)
97 define void @test_objc_moveWeak(i8** %arg0, i8** %arg1) {
98 ; CHECK-LABEL: test_objc_moveWeak
100 ; CHECK-NEXT: call void @objc_moveWeak(i8** %arg0, i8** %arg1)
101 ; CHECK-NEXT: ret void
103 call void @llvm.objc.moveWeak(i8** %arg0, i8** %arg1)
107 define void @test_objc_release(i8* %arg0) {
108 ; CHECK-LABEL: test_objc_release
110 ; CHECK-NEXT: call void @objc_release(i8* %arg0)
111 ; CHECK-NEXT: ret void
113 call void @llvm.objc.release(i8* %arg0)
117 define i8* @test_objc_retain(i8* %arg0) {
118 ; CHECK-LABEL: test_objc_retain
120 ; CHECK-NEXT: %0 = call i8* @objc_retain(i8* %arg0)
121 ; CHECK-NEXT: ret i8* %0
123 %0 = call i8* @llvm.objc.retain(i8* %arg0)
127 define i8* @test_objc_retainAutorelease(i8* %arg0) {
128 ; CHECK-LABEL: test_objc_retainAutorelease
130 ; CHECK-NEXT: %0 = call i8* @objc_retainAutorelease(i8* %arg0)
131 ; CHECK-NEXT: ret i8* %0
133 %0 = call i8* @llvm.objc.retainAutorelease(i8* %arg0)
137 define i8* @test_objc_retainAutoreleaseReturnValue(i8* %arg0) {
138 ; CHECK-LABEL: test_objc_retainAutoreleaseReturnValue
140 ; CHECK-NEXT: %0 = tail call i8* @objc_retainAutoreleaseReturnValue(i8* %arg0)
141 ; CHECK-NEXT: ret i8* %0
143 %0 = tail call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* %arg0)
147 define i8* @test_objc_retainAutoreleasedReturnValue(i8* %arg0) {
148 ; CHECK-LABEL: test_objc_retainAutoreleasedReturnValue
150 ; CHECK-NEXT: %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %arg0)
151 ; CHECK-NEXT: ret i8* %0
153 %0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %arg0)
157 define i8* @test_objc_retainBlock(i8* %arg0) {
158 ; CHECK-LABEL: test_objc_retainBlock
160 ; CHECK-NEXT: %0 = call i8* @objc_retainBlock(i8* %arg0)
161 ; CHECK-NEXT: ret i8* %0
163 %0 = call i8* @llvm.objc.retainBlock(i8* %arg0)
167 define void @test_objc_storeStrong(i8** %arg0, i8* %arg1) {
168 ; CHECK-LABEL: test_objc_storeStrong
170 ; CHECK-NEXT: call void @objc_storeStrong(i8** %arg0, i8* %arg1)
171 ; CHECK-NEXT: ret void
173 call void @llvm.objc.storeStrong(i8** %arg0, i8* %arg1)
177 define i8* @test_objc_storeWeak(i8** %arg0, i8* %arg1) {
178 ; CHECK-LABEL: test_objc_storeWeak
180 ; CHECK-NEXT: %0 = call i8* @objc_storeWeak(i8** %arg0, i8* %arg1)
181 ; CHECK-NEXT: ret i8* %0
183 %0 = call i8* @llvm.objc.storeWeak(i8** %arg0, i8* %arg1)
187 define i8* @test_objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0) {
188 ; CHECK-LABEL: test_objc_unsafeClaimAutoreleasedReturnValue
190 ; CHECK-NEXT: %0 = call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0)
191 ; CHECK-NEXT: ret i8* %0
193 %0 = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %arg0)
197 define i8* @test_objc_retainedObject(i8* %arg0) {
198 ; CHECK-LABEL: test_objc_retainedObject
200 ; CHECK-NEXT: %0 = call i8* @objc_retainedObject(i8* %arg0)
201 ; CHECK-NEXT: ret i8* %0
203 %0 = call i8* @llvm.objc.retainedObject(i8* %arg0)
207 define i8* @test_objc_unretainedObject(i8* %arg0) {
208 ; CHECK-LABEL: test_objc_unretainedObject
210 ; CHECK-NEXT: %0 = call i8* @objc_unretainedObject(i8* %arg0)
211 ; CHECK-NEXT: ret i8* %0
213 %0 = call i8* @llvm.objc.unretainedObject(i8* %arg0)
217 define i8* @test_objc_unretainedPointer(i8* %arg0) {
218 ; CHECK-LABEL: test_objc_unretainedPointer
220 ; CHECK-NEXT: %0 = call i8* @objc_unretainedPointer(i8* %arg0)
221 ; CHECK-NEXT: ret i8* %0
223 %0 = call i8* @llvm.objc.unretainedPointer(i8* %arg0)
227 define i8* @test_objc_retain_autorelease(i8* %arg0) {
228 ; CHECK-LABEL: test_objc_retain_autorelease
230 ; CHECK-NEXT: %0 = call i8* @objc_retain_autorelease(i8* %arg0)
231 ; CHECK-NEXT: ret i8* %0
233 %0 = call i8* @llvm.objc.retain.autorelease(i8* %arg0)
237 define i32 @test_objc_sync_enter(i8* %arg0) {
238 ; CHECK-LABEL: test_objc_sync_enter
240 ; CHECK-NEXT: %0 = call i32 @objc_sync_enter(i8* %arg0)
241 ; CHECK-NEXT: ret i32 %0
243 %0 = call i32 @llvm.objc.sync.enter(i8* %arg0)
247 define i32 @test_objc_sync_exit(i8* %arg0) {
248 ; CHECK-LABEL: test_objc_sync_exit
250 ; CHECK-NEXT: %0 = call i32 @objc_sync_exit(i8* %arg0)
251 ; CHECK-NEXT: ret i32 %0
253 %0 = call i32 @llvm.objc.sync.exit(i8* %arg0)
257 declare i8* @llvm.objc.autorelease(i8*)
258 declare void @llvm.objc.autoreleasePoolPop(i8*)
259 declare i8* @llvm.objc.autoreleasePoolPush()
260 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
261 declare void @llvm.objc.copyWeak(i8**, i8**)
262 declare void @llvm.objc.destroyWeak(i8**)
263 declare extern_weak i8* @llvm.objc.initWeak(i8**, i8*)
264 declare i8* @llvm.objc.loadWeak(i8**)
265 declare i8* @llvm.objc.loadWeakRetained(i8**)
266 declare void @llvm.objc.moveWeak(i8**, i8**)
267 declare void @llvm.objc.release(i8*)
268 declare i8* @llvm.objc.retain(i8*)
269 declare i8* @llvm.objc.retainAutorelease(i8*)
270 declare i8* @llvm.objc.retainAutoreleaseReturnValue(i8*)
271 declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
272 declare i8* @llvm.objc.retainBlock(i8*)
273 declare void @llvm.objc.storeStrong(i8**, i8*)
274 declare i8* @llvm.objc.storeWeak(i8**, i8*)
275 declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*)
276 declare i8* @llvm.objc.retainedObject(i8*)
277 declare i8* @llvm.objc.unretainedObject(i8*)
278 declare i8* @llvm.objc.unretainedPointer(i8*)
279 declare i8* @llvm.objc.retain.autorelease(i8*)
280 declare i32 @llvm.objc.sync.enter(i8*)
281 declare i32 @llvm.objc.sync.exit(i8*)
283 attributes #0 = { nounwind }
285 ; CHECK: declare i8* @objc_autorelease(i8*)
286 ; CHECK: declare void @objc_autoreleasePoolPop(i8*)
287 ; CHECK: declare i8* @objc_autoreleasePoolPush()
288 ; CHECK: declare i8* @objc_autoreleaseReturnValue(i8*)
289 ; CHECK: declare void @objc_copyWeak(i8**, i8**)
290 ; CHECK: declare void @objc_destroyWeak(i8**)
291 ; CHECK: declare extern_weak i8* @objc_initWeak(i8**, i8*)
292 ; CHECK: declare i8* @objc_loadWeak(i8**)
293 ; CHECK: declare i8* @objc_loadWeakRetained(i8**)
294 ; CHECK: declare void @objc_moveWeak(i8**, i8**)
295 ; CHECK: declare void @objc_release(i8*) [[NLB:#[0-9]+]]
296 ; CHECK: declare i8* @objc_retain(i8*) [[NLB]]
297 ; CHECK: declare i8* @objc_retainAutorelease(i8*)
298 ; CHECK: declare i8* @objc_retainAutoreleaseReturnValue(i8*)
299 ; CHECK: declare i8* @objc_retainAutoreleasedReturnValue(i8*)
300 ; CHECK: declare i8* @objc_retainBlock(i8*)
301 ; CHECK: declare void @objc_storeStrong(i8**, i8*)
302 ; CHECK: declare i8* @objc_storeWeak(i8**, i8*)
303 ; CHECK: declare i8* @objc_unsafeClaimAutoreleasedReturnValue(i8*)
304 ; CHECK: declare i8* @objc_retainedObject(i8*)
305 ; CHECK: declare i8* @objc_unretainedObject(i8*)
306 ; CHECK: declare i8* @objc_unretainedPointer(i8*)
307 ; CHECK: declare i8* @objc_retain_autorelease(i8*)
308 ; CHECK: declare i32 @objc_sync_enter(i8*)
309 ; CHECK: declare i32 @objc_sync_exit(i8*)
311 ; CHECK: attributes #0 = { nounwind }
312 ; CHECK: attributes [[NLB]] = { nonlazybind }