150
|
1 // RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=UNOPT
|
|
2 // RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -O -disable-llvm-passes | FileCheck %s -check-prefix=CHECK -check-prefix=OPT
|
|
3
|
|
4 typedef __strong id strong_id;
|
|
5 typedef __weak id weak_id;
|
|
6
|
221
|
7 // CHECK-LABEL: define{{.*}} void @_Z8test_newP11objc_object
|
150
|
8 void test_new(id invalue) {
|
|
9 // CHECK: [[INVALUEADDR:%.*]] = alloca i8*
|
|
10 // UNOPT-NEXT: store i8* null, i8** [[INVALUEADDR]]
|
|
11 // UNOPT-NEXT: call void @llvm.objc.storeStrong(i8** [[INVALUEADDR]], i8* [[INVALUE:%.*]])
|
|
12 // OPT-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* [[INVALUE:%.*]])
|
|
13 // OPT-NEXT: store i8* [[T0]], i8** [[INVALUEADDR]]
|
|
14
|
173
|
15 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
|
150
|
16 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
|
17 // CHECK-NEXT: store i8* null, i8**
|
|
18 new strong_id;
|
173
|
19 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
|
150
|
20 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
|
21 // UNOPT-NEXT: store i8* null, i8**
|
|
22 // OPT-NEXT: call i8* @llvm.objc.initWeak(i8** {{.*}}, i8* null)
|
|
23 new weak_id;
|
|
24
|
173
|
25 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
|
150
|
26 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
|
27 // CHECK-NEXT: store i8* null, i8**
|
|
28 new __strong id;
|
173
|
29 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
|
150
|
30 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
|
|
31 // UNOPT-NEXT: store i8* null, i8**
|
|
32 // OPT-NEXT: call i8* @llvm.objc.initWeak(i8** {{.*}}, i8* null)
|
|
33 new __weak id;
|
|
34
|
173
|
35 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
|
150
|
36 // CHECK: call i8* @llvm.objc.retain
|
|
37 // CHECK: store i8*
|
|
38 new __strong id(invalue);
|
|
39
|
173
|
40 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
|
150
|
41 // CHECK: call i8* @llvm.objc.initWeak
|
|
42 new __weak id(invalue);
|
|
43
|
|
44 // UNOPT: call void @llvm.objc.storeStrong
|
|
45 // OPT: call void @llvm.objc.release
|
|
46 // CHECK: ret void
|
|
47 }
|
|
48
|
221
|
49 // CHECK-LABEL: define{{.*}} void @_Z14test_array_new
|
150
|
50 void test_array_new() {
|
173
|
51 // CHECK: call noalias nonnull i8* @_Znam
|
150
|
52 // CHECK: store i64 17, i64*
|
|
53 // CHECK: call void @llvm.memset.p0i8.i64
|
|
54 new strong_id[17];
|
|
55
|
173
|
56 // CHECK: call noalias nonnull i8* @_Znam
|
150
|
57 // CHECK: store i64 17, i64*
|
|
58 // CHECK: call void @llvm.memset.p0i8.i64
|
|
59 new weak_id[17];
|
|
60 // CHECK: ret void
|
|
61 }
|
|
62
|
221
|
63 // CHECK-LABEL: define{{.*}} void @_Z11test_deletePU8__strongP11objc_objectPU6__weakS0_
|
150
|
64 void test_delete(__strong id *sptr, __weak id *wptr) {
|
|
65 // CHECK: br i1
|
|
66 // UNOPT: call void @llvm.objc.storeStrong(i8** {{.*}}, i8* null)
|
|
67 // OPT: load i8*, i8**
|
|
68 // OPT-NEXT: call void @llvm.objc.release
|
|
69 // CHECK: call void @_ZdlPv
|
|
70 delete sptr;
|
|
71
|
|
72 // CHECK: call void @llvm.objc.destroyWeak
|
|
73 // CHECK: call void @_ZdlPv
|
|
74 delete wptr;
|
|
75
|
|
76 // CHECK: ret void
|
|
77 }
|
|
78
|
221
|
79 // CHECK-LABEL: define{{.*}} void @_Z17test_array_deletePU8__strongP11objc_objectPU6__weakS0_
|
150
|
80 void test_array_delete(__strong id *sptr, __weak id *wptr) {
|
|
81 // CHECK: icmp eq i8** [[BEGIN:%.*]], null
|
|
82 // CHECK: [[LEN:%.*]] = load i64, i64* {{%.*}}
|
|
83 // CHECK: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 [[LEN]]
|
|
84 // CHECK-NEXT: icmp eq i8** [[BEGIN]], [[END]]
|
|
85 // CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]],
|
|
86 // CHECK-NEXT: [[CUR]] = getelementptr inbounds i8*, i8** [[PAST]], i64 -1
|
|
87 // UNOPT-NEXT: call void @llvm.objc.storeStrong(i8** [[CUR]], i8* null)
|
|
88 // OPT-NEXT: [[T0:%.*]] = load i8*, i8** [[CUR]]
|
|
89 // OPT-NEXT: llvm.objc.release(i8* [[T0]])
|
|
90 // CHECK-NEXT: icmp eq i8** [[CUR]], [[BEGIN]]
|
|
91 // CHECK: call void @_ZdaPv
|
|
92 delete [] sptr;
|
|
93
|
|
94 // CHECK: icmp eq i8** [[BEGIN:%.*]], null
|
|
95 // CHECK: [[LEN:%.*]] = load i64, i64* {{%.*}}
|
|
96 // CHECK: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 [[LEN]]
|
|
97 // CHECK-NEXT: icmp eq i8** [[BEGIN]], [[END]]
|
|
98 // CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]],
|
|
99 // CHECK-NEXT: [[CUR]] = getelementptr inbounds i8*, i8** [[PAST]], i64 -1
|
|
100 // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[CUR]])
|
|
101 // CHECK-NEXT: icmp eq i8** [[CUR]], [[BEGIN]]
|
|
102 // CHECK: call void @_ZdaPv
|
|
103 delete [] wptr;
|
|
104 }
|