annotate clang/test/CodeGenObjCXX/arc-new-delete.mm @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 79ff65ed7e25
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
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
anatofuz
parents:
diff changeset
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
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 typedef __strong id strong_id;
anatofuz
parents:
diff changeset
5 typedef __weak id weak_id;
anatofuz
parents:
diff changeset
6
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
7 // CHECK-LABEL: define{{.*}} void @_Z8test_newP11objc_object
150
anatofuz
parents:
diff changeset
8 void test_new(id invalue) {
anatofuz
parents:
diff changeset
9 // CHECK: [[INVALUEADDR:%.*]] = alloca i8*
anatofuz
parents:
diff changeset
10 // UNOPT-NEXT: store i8* null, i8** [[INVALUEADDR]]
anatofuz
parents:
diff changeset
11 // UNOPT-NEXT: call void @llvm.objc.storeStrong(i8** [[INVALUEADDR]], i8* [[INVALUE:%.*]])
anatofuz
parents:
diff changeset
12 // OPT-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* [[INVALUE:%.*]])
anatofuz
parents:
diff changeset
13 // OPT-NEXT: store i8* [[T0]], i8** [[INVALUEADDR]]
anatofuz
parents:
diff changeset
14
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
15 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
150
anatofuz
parents:
diff changeset
16 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
anatofuz
parents:
diff changeset
17 // CHECK-NEXT: store i8* null, i8**
anatofuz
parents:
diff changeset
18 new strong_id;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
19 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
150
anatofuz
parents:
diff changeset
20 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
anatofuz
parents:
diff changeset
21 // UNOPT-NEXT: store i8* null, i8**
anatofuz
parents:
diff changeset
22 // OPT-NEXT: call i8* @llvm.objc.initWeak(i8** {{.*}}, i8* null)
anatofuz
parents:
diff changeset
23 new weak_id;
anatofuz
parents:
diff changeset
24
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
25 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
150
anatofuz
parents:
diff changeset
26 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
anatofuz
parents:
diff changeset
27 // CHECK-NEXT: store i8* null, i8**
anatofuz
parents:
diff changeset
28 new __strong id;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
29 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
150
anatofuz
parents:
diff changeset
30 // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
anatofuz
parents:
diff changeset
31 // UNOPT-NEXT: store i8* null, i8**
anatofuz
parents:
diff changeset
32 // OPT-NEXT: call i8* @llvm.objc.initWeak(i8** {{.*}}, i8* null)
anatofuz
parents:
diff changeset
33 new __weak id;
anatofuz
parents:
diff changeset
34
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
35 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
150
anatofuz
parents:
diff changeset
36 // CHECK: call i8* @llvm.objc.retain
anatofuz
parents:
diff changeset
37 // CHECK: store i8*
anatofuz
parents:
diff changeset
38 new __strong id(invalue);
anatofuz
parents:
diff changeset
39
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
40 // CHECK: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm
150
anatofuz
parents:
diff changeset
41 // CHECK: call i8* @llvm.objc.initWeak
anatofuz
parents:
diff changeset
42 new __weak id(invalue);
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 // UNOPT: call void @llvm.objc.storeStrong
anatofuz
parents:
diff changeset
45 // OPT: call void @llvm.objc.release
anatofuz
parents:
diff changeset
46 // CHECK: ret void
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
49 // CHECK-LABEL: define{{.*}} void @_Z14test_array_new
150
anatofuz
parents:
diff changeset
50 void test_array_new() {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
51 // CHECK: call noalias nonnull i8* @_Znam
150
anatofuz
parents:
diff changeset
52 // CHECK: store i64 17, i64*
anatofuz
parents:
diff changeset
53 // CHECK: call void @llvm.memset.p0i8.i64
anatofuz
parents:
diff changeset
54 new strong_id[17];
anatofuz
parents:
diff changeset
55
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
56 // CHECK: call noalias nonnull i8* @_Znam
150
anatofuz
parents:
diff changeset
57 // CHECK: store i64 17, i64*
anatofuz
parents:
diff changeset
58 // CHECK: call void @llvm.memset.p0i8.i64
anatofuz
parents:
diff changeset
59 new weak_id[17];
anatofuz
parents:
diff changeset
60 // CHECK: ret void
anatofuz
parents:
diff changeset
61 }
anatofuz
parents:
diff changeset
62
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
63 // CHECK-LABEL: define{{.*}} void @_Z11test_deletePU8__strongP11objc_objectPU6__weakS0_
150
anatofuz
parents:
diff changeset
64 void test_delete(__strong id *sptr, __weak id *wptr) {
anatofuz
parents:
diff changeset
65 // CHECK: br i1
anatofuz
parents:
diff changeset
66 // UNOPT: call void @llvm.objc.storeStrong(i8** {{.*}}, i8* null)
anatofuz
parents:
diff changeset
67 // OPT: load i8*, i8**
anatofuz
parents:
diff changeset
68 // OPT-NEXT: call void @llvm.objc.release
anatofuz
parents:
diff changeset
69 // CHECK: call void @_ZdlPv
anatofuz
parents:
diff changeset
70 delete sptr;
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 // CHECK: call void @llvm.objc.destroyWeak
anatofuz
parents:
diff changeset
73 // CHECK: call void @_ZdlPv
anatofuz
parents:
diff changeset
74 delete wptr;
anatofuz
parents:
diff changeset
75
anatofuz
parents:
diff changeset
76 // CHECK: ret void
anatofuz
parents:
diff changeset
77 }
anatofuz
parents:
diff changeset
78
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
79 // CHECK-LABEL: define{{.*}} void @_Z17test_array_deletePU8__strongP11objc_objectPU6__weakS0_
150
anatofuz
parents:
diff changeset
80 void test_array_delete(__strong id *sptr, __weak id *wptr) {
anatofuz
parents:
diff changeset
81 // CHECK: icmp eq i8** [[BEGIN:%.*]], null
anatofuz
parents:
diff changeset
82 // CHECK: [[LEN:%.*]] = load i64, i64* {{%.*}}
anatofuz
parents:
diff changeset
83 // CHECK: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 [[LEN]]
anatofuz
parents:
diff changeset
84 // CHECK-NEXT: icmp eq i8** [[BEGIN]], [[END]]
anatofuz
parents:
diff changeset
85 // CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]],
anatofuz
parents:
diff changeset
86 // CHECK-NEXT: [[CUR]] = getelementptr inbounds i8*, i8** [[PAST]], i64 -1
anatofuz
parents:
diff changeset
87 // UNOPT-NEXT: call void @llvm.objc.storeStrong(i8** [[CUR]], i8* null)
anatofuz
parents:
diff changeset
88 // OPT-NEXT: [[T0:%.*]] = load i8*, i8** [[CUR]]
anatofuz
parents:
diff changeset
89 // OPT-NEXT: llvm.objc.release(i8* [[T0]])
anatofuz
parents:
diff changeset
90 // CHECK-NEXT: icmp eq i8** [[CUR]], [[BEGIN]]
anatofuz
parents:
diff changeset
91 // CHECK: call void @_ZdaPv
anatofuz
parents:
diff changeset
92 delete [] sptr;
anatofuz
parents:
diff changeset
93
anatofuz
parents:
diff changeset
94 // CHECK: icmp eq i8** [[BEGIN:%.*]], null
anatofuz
parents:
diff changeset
95 // CHECK: [[LEN:%.*]] = load i64, i64* {{%.*}}
anatofuz
parents:
diff changeset
96 // CHECK: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 [[LEN]]
anatofuz
parents:
diff changeset
97 // CHECK-NEXT: icmp eq i8** [[BEGIN]], [[END]]
anatofuz
parents:
diff changeset
98 // CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]],
anatofuz
parents:
diff changeset
99 // CHECK-NEXT: [[CUR]] = getelementptr inbounds i8*, i8** [[PAST]], i64 -1
anatofuz
parents:
diff changeset
100 // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[CUR]])
anatofuz
parents:
diff changeset
101 // CHECK-NEXT: icmp eq i8** [[CUR]], [[BEGIN]]
anatofuz
parents:
diff changeset
102 // CHECK: call void @_ZdaPv
anatofuz
parents:
diff changeset
103 delete [] wptr;
anatofuz
parents:
diff changeset
104 }