1 ; RUN: opt -S -passes=objc-arc < %s | FileCheck %s
4 ; Delete the weak calls and replace them with just the net retain.
6 ; CHECK: define void @test0(ptr %p) {
7 ; CHECK-NEXT: call ptr @llvm.objc.retain(ptr %p)
10 define void @test0(ptr %p) {
11 %weakBlock = alloca ptr, align 8
12 %tmp7 = call ptr @llvm.objc.initWeak(ptr %weakBlock, ptr %p) nounwind
13 %tmp26 = call ptr @llvm.objc.loadWeakRetained(ptr %weakBlock) nounwind
14 call void @llvm.objc.destroyWeak(ptr %weakBlock) nounwind
18 ; CHECK: define ptr @test1(ptr %p) {
19 ; CHECK-NEXT: call ptr @llvm.objc.retain(ptr %p)
20 ; CHECK-NEXT: ret ptr %p
22 define ptr @test1(ptr %p) {
23 %weakBlock = alloca ptr, align 8
24 %tmp7 = call ptr @llvm.objc.initWeak(ptr %weakBlock, ptr %p) nounwind
25 %tmp26 = call ptr @llvm.objc.loadWeakRetained(ptr %weakBlock) nounwind
26 call void @llvm.objc.destroyWeak(ptr %weakBlock) nounwind
30 ; CHECK: define ptr @test2(ptr %p, ptr %q) {
31 ; CHECK-NEXT: call ptr @llvm.objc.retain(ptr %q)
32 ; CHECK-NEXT: ret ptr %q
34 define ptr @test2(ptr %p, ptr %q) {
35 %weakBlock = alloca ptr, align 8
36 %tmp7 = call ptr @llvm.objc.initWeak(ptr %weakBlock, ptr %p) nounwind
37 %tmp19 = call ptr @llvm.objc.storeWeak(ptr %weakBlock, ptr %q) nounwind
38 %tmp26 = call ptr @llvm.objc.loadWeakRetained(ptr %weakBlock) nounwind
39 call void @llvm.objc.destroyWeak(ptr %weakBlock) nounwind
43 declare ptr @llvm.objc.initWeak(ptr, ptr)
44 declare void @llvm.objc.destroyWeak(ptr)
45 declare ptr @llvm.objc.loadWeakRetained(ptr)
46 declare ptr @llvm.objc.storeWeak(ptr %weakBlock, ptr %q)