1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
3 @interface WeakPropertyTest {
6 @property () __weak id PROP;
9 @implementation WeakPropertyTest
13 // CHECK: define internal ptr @"\01-[WeakPropertyTest PROP]"
14 // CHECK: [[SELF:%.*]] = alloca ptr,
15 // CHECK-NEXT: [[CMD:%.*]] = alloca ptr,
16 // CHECK-NEXT: store ptr {{%.*}}, ptr [[SELF]]
17 // CHECK-NEXT: store ptr {{%.*}}, ptr [[CMD]]
18 // CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[SELF]]
19 // CHECK-NEXT: [[T1:%.*]] = load i64, ptr @"OBJC_IVAR_$_WeakPropertyTest.PROP"
20 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, ptr [[T0]], i64 [[T1]]
21 // CHECK-NEXT: [[T5:%.*]] = call ptr @llvm.objc.loadWeakRetained(ptr [[T3]])
22 // CHECK-NEXT: [[T6:%.*]] = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr [[T5]])
23 // CHECK-NEXT: ret ptr [[T6]]
25 // CHECK: define internal void @"\01-[WeakPropertyTest setPROP:]"
26 // CHECK: [[SELF:%.*]] = alloca ptr,
27 // CHECK-NEXT: [[CMD:%.*]] = alloca ptr,
28 // CHECK-NEXT: [[PROP:%.*]] = alloca ptr,
29 // CHECK-NEXT: store ptr {{%.*}}, ptr [[SELF]]
30 // CHECK-NEXT: store ptr {{%.*}}, ptr [[CMD]]
31 // CHECK-NEXT: store ptr {{%.*}}, ptr [[PROP]]
32 // CHECK-NEXT: [[V:%.*]] = load ptr, ptr [[PROP]]
33 // CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[SELF]]
34 // CHECK-NEXT: [[T1:%.*]] = load i64, ptr @"OBJC_IVAR_$_WeakPropertyTest.PROP"
35 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, ptr [[T0]], i64 [[T1]]
36 // CHECK-NEXT: call ptr @llvm.objc.storeWeak(ptr [[T3]], ptr [[V]])
37 // CHECK-NEXT: ret void
39 // CHECK: define internal void @"\01-[WeakPropertyTest .cxx_destruct]"
40 // CHECK: [[SELF:%.*]] = alloca ptr,
41 // CHECK-NEXT: [[CMD:%.*]] = alloca ptr,
42 // CHECK-NEXT: store ptr {{%.*}}, ptr [[SELF]]
43 // CHECK-NEXT: store ptr {{%.*}}, ptr [[CMD]]
44 // CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[SELF]]
45 // CHECK-NEXT: [[T1:%.*]] = load i64, ptr @"OBJC_IVAR_$_WeakPropertyTest.PROP"
46 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, ptr [[T0]], i64 [[T1]]
47 // CHECK-NEXT: call void @llvm.objc.destroyWeak(ptr [[T3]])
48 // CHECK-NEXT: ret void