1 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin10 -Wno-objc-root-class -Wno-incompatible-pointer-types -Wno-arc-unsafe-retained-assign -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-passes -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin10 -Wno-objc-root-class -Wno-incompatible-pointer-types -Wno-arc-unsafe-retained-assign -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=CHECK-GLOBALS %s
4 // rdar://13129783. Check both native/non-native arc platforms. Here we check
5 // that they treat nonlazybind differently.
6 // RUN: %clang_cc1 -no-opaque-pointers -fobjc-runtime=macosx-10.6.0 -triple x86_64-apple-darwin10 -Wno-objc-root-class -Wno-incompatible-pointer-types -Wno-arc-unsafe-retained-assign -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=ARC-ALIEN %s
7 // RUN: %clang_cc1 -no-opaque-pointers -fobjc-runtime=macosx-10.7.0 -triple x86_64-apple-darwin11 -Wno-objc-root-class -Wno-incompatible-pointer-types -Wno-arc-unsafe-retained-assign -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=ARC-NATIVE %s
9 // ARC-ALIEN: declare extern_weak void @llvm.objc.storeStrong(i8**, i8*)
10 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.retain(i8*)
11 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.autoreleaseReturnValue(i8*)
12 // ARC-ALIEN: declare i8* @objc_msgSend(i8*, i8*, ...) [[NLB:#[0-9]+]]
13 // ARC-ALIEN: declare extern_weak void @llvm.objc.release(i8*)
14 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
15 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.initWeak(i8**, i8*)
16 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.storeWeak(i8**, i8*)
17 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.loadWeakRetained(i8**)
18 // ARC-ALIEN: declare extern_weak void @llvm.objc.destroyWeak(i8**)
19 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.autorelease(i8*)
20 // ARC-ALIEN: declare extern_weak i8* @llvm.objc.retainAutorelease(i8*)
22 // ARC-NATIVE: declare void @llvm.objc.storeStrong(i8**, i8*)
23 // ARC-NATIVE: declare i8* @llvm.objc.retain(i8*)
24 // ARC-NATIVE: declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
25 // ARC-NATIVE: declare i8* @objc_msgSend(i8*, i8*, ...) [[NLB:#[0-9]+]]
26 // ARC-NATIVE: declare void @llvm.objc.release(i8*)
27 // ARC-NATIVE: declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
28 // ARC-NATIVE: declare i8* @llvm.objc.initWeak(i8**, i8*)
29 // ARC-NATIVE: declare i8* @llvm.objc.storeWeak(i8**, i8*)
30 // ARC-NATIVE: declare i8* @llvm.objc.loadWeakRetained(i8**)
31 // ARC-NATIVE: declare void @llvm.objc.destroyWeak(i8**)
32 // ARC-NATIVE: declare i8* @llvm.objc.autorelease(i8*)
33 // ARC-NATIVE: declare i8* @llvm.objc.retainAutorelease(i8*)
35 // CHECK-LABEL: define{{.*}} void @test0
37 // CHECK: [[X:%.*]] = alloca i8*
38 // CHECK-NEXT: [[PARM:%.*]] = call i8* @llvm.objc.retain(i8* {{.*}})
39 // CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
40 // CHECK-NEXT: [[TMP:%.*]] = load i8*, i8** [[X]]
41 // CHECK-NEXT: call void @llvm.objc.release(i8* [[TMP]])
42 // CHECK-NEXT: ret void
45 // CHECK-LABEL: define{{.*}} i8* @test1(i8*
47 // CHECK: [[X:%.*]] = alloca i8*
48 // CHECK-NEXT: [[Y:%.*]] = alloca i8*
49 // CHECK-NEXT: [[PARM:%.*]] = call i8* @llvm.objc.retain(i8* {{%.*}})
50 // CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
51 // CHECK-NEXT: [[YPTR1:%.*]] = bitcast i8** [[Y]] to i8*
52 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[YPTR1]])
53 // CHECK-NEXT: store i8* null, i8** [[Y]]
54 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[Y]]
55 // CHECK-NEXT: [[RET:%.*]] = call i8* @llvm.objc.retain(i8* [[T0]])
56 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[Y]]
57 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
58 // CHECK-NEXT: [[YPTR2:%.*]] = bitcast i8** [[Y]] to i8*
59 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[YPTR2]])
60 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
61 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
62 // CHECK-NEXT: [[T1:%.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* [[RET]])
63 // CHECK-NEXT: ret i8* [[T1]]
69 + (void) class_method;
74 // The self pointer of a class method is not retained.
75 // CHECK: define internal void @"\01+[Test2 class_method]"
80 // CHECK-NEXT: ret void
81 + (void) class_method {}
83 // The self pointer of an instance method is not retained.
84 // CHECK: define internal void @"\01-[Test2 inst_method]"
89 // CHECK-NEXT: ret void
90 - (void) inst_method {}
95 - (id) initWith: (int) x;
99 // CHECK-LABEL: define{{.*}} void @test3_unelided()
100 void test3_unelided(void) {
101 extern void test3_helper(void);
103 // CHECK: [[X:%.*]] = alloca [[TEST3:%.*]]*
104 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast [[TEST3]]** [[X]] to i8*
105 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
106 // CHECK-NEXT: store [[TEST3]]* null, [[TEST3]]** [[X]], align
110 // CHECK-NEXT: load {{.*}}, {{.*}}* @"OBJC_CLASSLIST_REFERENCES_
111 // CHECK-NEXT: bitcast
112 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
113 // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
114 // CHECK-NEXT: bitcast
115 // CHECK-NEXT: bitcast
116 // CHECK-NEXT: call void @llvm.objc.release(i8*
119 // CHECK-NEXT: [[T0:%.*]] = load [[TEST3]]*, [[TEST3]]** [[X]]
120 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST3]]* [[T0]] to i8*
121 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
122 // CHECK-NEXT: [[COPY:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend {{.*}})(i8* noundef [[T1]],
123 // CHECK-NEXT: call void @llvm.objc.release(i8* [[COPY]]) [[NUW:#[0-9]+]]
126 // CHECK-NEXT: [[T0:%.*]] = load [[TEST3]]*, [[TEST3]]** [[X]]
127 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST3]]* [[T0]] to i8*
128 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]]
129 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast [[TEST3]]** [[X]] to i8*
130 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
131 // CHECK-NEXT: ret void
134 // CHECK-LABEL: define{{.*}} void @test3()
136 // CHECK: [[X:%.*]] = alloca i8*
137 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
138 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
140 id x = [[Test3 alloc] initWith: 5];
143 // CHECK-NEXT: load {{.*}}, {{.*}}* @"OBJC_CLASSLIST_REFERENCES_
144 // CHECK-NEXT: bitcast
145 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
146 // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
147 // CHECK-NEXT: bitcast
149 // Call to -initWith: with elided retain of consumed argument.
150 // CHECK-NEXT: bitcast
151 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
152 // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8*
153 // CHECK-NEXT: bitcast
154 // CHECK-NEXT: [[INIT:%.*]] = bitcast
155 // Assignment for initialization, retention elided.
156 // CHECK-NEXT: store i8* [[INIT]], i8** [[X]]
159 // CHECK-NEXT: [[V:%.*]] = load i8*, i8** [[X]]
160 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
161 // CHECK-NEXT: [[COPY:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend {{.*}})(i8* noundef [[V]],
164 // CHECK-NEXT: [[TMP:%.*]] = load i8*, i8** [[X]]
165 // CHECK-NEXT: store i8* [[COPY]], i8** [[X]]
166 // CHECK-NEXT: call void @llvm.objc.release(i8* [[TMP]]) [[NUW]]
171 // CHECK-NEXT: [[TMP:%.*]] = load i8*, i8** [[X]]
172 // CHECK-NEXT: call void @llvm.objc.release(i8* [[TMP]]) [[NUW]]
173 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
174 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
175 // CHECK-NEXT: ret void
178 // CHECK-LABEL: define{{.*}} i8* @test4()
181 // CHECK: load {{.*}}, {{.*}}* @"OBJC_CLASSLIST_REFERENCES_
182 // CHECK-NEXT: bitcast
183 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
184 // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
185 // CHECK-NEXT: [[ALLOC:%.*]] = bitcast
187 // Call to -initWith: with elided retain of consumed argument.
188 // CHECK-NEXT: [[ALLOC:%.*]] = bitcast
189 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
190 // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* noundef [[ALLOC]],
192 // Initialization of return value, occurring within full-expression.
193 // Retain/release elided.
194 // CHECK-NEXT: bitcast
195 // CHECK-NEXT: [[INIT:%.*]] = bitcast
196 // CHECK-NEXT: [[RET:%.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* [[INIT]])
198 // CHECK-NEXT: ret i8* [[RET]]
200 return [[Test3 alloc] initWith: 6];
209 // CHECK-LABEL: define{{.*}} void @test5
210 void test5(Test5 *x, id y) {
212 // CHECK: [[X:%.*]] = alloca [[TEST5:%.*]]*,
213 // CHECK-NEXT: [[Y:%.*]] = alloca i8*
214 // CHECK-NEXT: bitcast [[TEST5]]* {{%.*}} to i8*
215 // CHECK-NEXT: call i8* @llvm.objc.retain
216 // CHECK-NEXT: [[PARMX:%.*]] = bitcast i8* {{%.*}} to [[TEST5]]*
217 // CHECK-NEXT: store [[TEST5]]* [[PARMX]], [[TEST5]]** [[X]]
218 // CHECK-NEXT: call i8* @llvm.objc.retain
221 // CHECK-NEXT: load [[TEST5]]*, [[TEST5]]** [[X]]
222 // CHECK-NEXT: load i64, i64* @"OBJC_IVAR_$_Test5.var"
223 // CHECK-NEXT: bitcast
224 // CHECK-NEXT: getelementptr
225 // CHECK-NEXT: [[VAR:%.*]] = bitcast
226 // CHECK-NEXT: [[TMP:%.*]] = load i8*, i8** [[VAR]]
227 // CHECK-NEXT: store i8* null, i8** [[VAR]]
228 // CHECK-NEXT: call void @llvm.objc.release(i8* [[TMP]]) [[NUW]]
231 // CHECK-NEXT: [[YVAL:%.*]] = load i8*, i8** [[Y]]
232 // CHECK-NEXT: load [[TEST5]]*, [[TEST5]]** [[X]]
233 // CHECK-NEXT: load i64, i64* @"OBJC_IVAR_$_Test5.var"
234 // CHECK-NEXT: bitcast
235 // CHECK-NEXT: getelementptr
236 // CHECK-NEXT: [[VAR:%.*]] = bitcast
237 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* [[YVAL]]) [[NUW]]
238 // CHECK-NEXT: [[TMP:%.*]] = load i8*, i8** [[VAR]]
239 // CHECK-NEXT: store i8* [[T0]], i8** [[VAR]]
240 // CHECK-NEXT: call void @llvm.objc.release(i8* [[TMP]]) [[NUW]]
244 // CHECK-NEXT: [[TMP:%.*]] = load i8*, i8** [[Y]]
245 // CHECK-NEXT: call void @llvm.objc.release(i8* [[TMP]]) [[NUW]]
246 // CHECK-NEXT: [[T0:%.*]] = load [[TEST5]]*, [[TEST5]]** [[X]]
247 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST5]]* [[T0]] to i8*
248 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]]
249 // CHECK-NEXT: ret void
252 id test6_helper(void) __attribute__((ns_returns_retained));
253 // CHECK-LABEL: define{{.*}} void @test6()
255 // CHECK: [[X:%.*]] = alloca i8*
256 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
257 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
258 // CHECK-NEXT: [[CALL:%.*]] = call i8* @test6_helper()
259 // CHECK-NEXT: store i8* [[CALL]], i8** [[X]]
260 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
261 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
262 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
263 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
264 // CHECK-NEXT: ret void
265 id x = test6_helper();
268 void test7_helper(id __attribute__((ns_consumed)));
269 // CHECK-LABEL: define{{.*}} void @test7()
271 // CHECK: [[X:%.*]] = alloca i8*
272 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
273 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
274 // CHECK-NEXT: store i8* null, i8** [[X]]
275 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[X]]
276 // CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retain(i8* [[T0]]) [[NUW]]
277 // CHECK-NEXT: call void @test7_helper(i8* noundef [[T1]])
278 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
279 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
280 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
281 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
282 // CHECK-NEXT: ret void
287 id test8_helper(void) __attribute__((ns_returns_retained));
289 __unsafe_unretained id x = test8_helper();
290 // CHECK: [[X:%.*]] = alloca i8*
291 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
292 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
293 // CHECK-NEXT: [[T0:%.*]] = call i8* @test8_helper()
294 // CHECK-NEXT: store i8* [[T0]], i8** [[X]]
295 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]], !clang.imprecise_release
296 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
297 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
298 // CHECK-NEXT: ret void
302 @property (retain) Test10 *me;
308 // CHECK-LABEL: define{{.*}} void @test10()
309 // CHECK: [[X:%.*]] = alloca [[TEST10:%.*]]*, align
310 // CHECK-NEXT: [[Y:%.*]] = alloca i8*, align
311 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast [[TEST10]]** [[X]] to i8*
312 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
313 // CHECK-NEXT: store [[TEST10]]* null, [[TEST10]]** [[X]]
314 // CHECK-NEXT: [[YPTR1:%.*]] = bitcast i8** [[Y]] to i8*
315 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[YPTR1]])
316 // CHECK-NEXT: load [[TEST10]]*, [[TEST10]]** [[X]], align
317 // CHECK-NEXT: bitcast
318 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_{{[0-9]*}}
319 // CHECK-NEXT: [[V:%.*]] = call [[TEST10]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend{{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
320 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(%3* [[V]])
321 // CHECK-NEXT: bitcast
322 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_{{[0-9]*}}
323 // CHECK-NEXT: [[T3:%.*]] = call [[TEST10]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend{{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
324 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(%3* [[T3]])
325 // CHECK-NEXT: [[T4:%.*]] = bitcast [[TEST10]]* [[T3]] to i8*
326 // CHECK-NEXT: store i8* [[T4]], i8** [[Y]]
327 // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST10]]* [[V]] to i8*
328 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
329 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[Y]]
330 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
331 // CHECK-NEXT: [[YPTR2:%.*]] = bitcast i8** [[Y]] to i8*
332 // CHECK-NEXT: void @llvm.lifetime.end.p0i8(i64 8, i8* [[YPTR2]])
333 // CHECK-NEXT: [[T0:%.*]] = load [[TEST10]]*, [[TEST10]]** [[X]]
334 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST10]]* [[T0]] to i8*
335 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
336 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast [[TEST10]]** [[X]] to i8*
337 // CHECK-NEXT: void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
338 // CHECK-NEXT: ret void
341 void test11(id (*f)(void) __attribute__((ns_returns_retained))) {
342 // CHECK-LABEL: define{{.*}} void @test11(
343 // CHECK: [[F:%.*]] = alloca i8* ()*, align
344 // CHECK-NEXT: [[X:%.*]] = alloca i8*, align
345 // CHECK-NEXT: store i8* ()* {{%.*}}, i8* ()** [[F]], align
346 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
347 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
348 // CHECK-NEXT: [[T0:%.*]] = load i8* ()*, i8* ()** [[F]], align
349 // CHECK-NEXT: [[T1:%.*]] = call i8* [[T0]]()
350 // CHECK-NEXT: store i8* [[T1]], i8** [[X]], align
351 // CHECK-NEXT: [[T3:%.*]] = load i8*, i8** [[X]]
352 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T3]]) [[NUW]], !clang.imprecise_release
353 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
354 // CHECK-NEXT: void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
355 // CHECK-NEXT: ret void
360 extern id test12_helper(void);
362 // CHECK-LABEL: define{{.*}} void @test12()
363 // CHECK: [[X:%.*]] = alloca i8*, align
364 // CHECK-NEXT: [[Y:%.*]] = alloca i8*, align
366 __weak id x = test12_helper();
367 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
368 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
369 // CHECK-NEXT: [[T1:%.*]] = call i8* @test12_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
370 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
371 // CHECK-NEXT: call i8* @llvm.objc.initWeak(i8** [[X]], i8* [[T1]])
372 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
375 // CHECK-NEXT: [[T1:%.*]] = call i8* @test12_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
376 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
377 // CHECK-NEXT: call i8* @llvm.objc.storeWeak(i8** [[X]], i8* [[T1]])
378 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
381 // CHECK-NEXT: [[YPTR1:%.*]] = bitcast i8** [[Y]] to i8*
382 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[YPTR1]])
383 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.loadWeakRetained(i8** [[X]])
384 // CHECK-NEXT: store i8* [[T2]], i8** [[Y]], align
386 // CHECK-NEXT: [[T4:%.*]] = load i8*, i8** [[Y]]
387 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T4]]) [[NUW]], !clang.imprecise_release
388 // CHECK-NEXT: [[YPTR2:%.*]] = bitcast i8** [[Y]] to i8*
389 // CHECK-NEXT: void @llvm.lifetime.end.p0i8(i64 8, i8* [[YPTR2]])
390 // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[X]])
391 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
392 // CHECK-NEXT: void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
396 // Indirect consuming calls.
398 // CHECK-LABEL: define{{.*}} void @test13()
399 // CHECK: [[X:%.*]] = alloca i8*, align
400 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
401 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
402 // CHECK-NEXT: store i8* null, i8** [[X]], align
405 typedef void fnty(id __attribute__((ns_consumed)));
406 extern fnty *test13_func;
407 // CHECK-NEXT: [[FN:%.*]] = load void (i8*)*, void (i8*)** @test13_func, align
408 // CHECK-NEXT: [[X_VAL:%.*]] = load i8*, i8** [[X]], align
409 // CHECK-NEXT: [[X_TMP:%.*]] = call i8* @llvm.objc.retain(i8* [[X_VAL]]) [[NUW]]
410 // CHECK-NEXT: call void [[FN]](i8* noundef [[X_TMP]])
413 extern fnty ^test13_block;
414 // CHECK-NEXT: [[TMP:%.*]] = load void (i8*)*, void (i8*)** @test13_block, align
415 // CHECK-NEXT: [[BLOCK:%.*]] = bitcast void (i8*)* [[TMP]] to [[BLOCKTY:%.*]]*
416 // CHECK-NEXT: [[BLOCK_FN_PTR:%.*]] = getelementptr inbounds [[BLOCKTY]], [[BLOCKTY]]* [[BLOCK]], i32 0, i32 3
417 // CHECK-NEXT: [[BLOCK_OPAQUE:%.*]] = bitcast [[BLOCKTY]]* [[BLOCK]] to i8*
418 // CHECK-NEXT: [[X_VAL:%.*]] = load i8*, i8** [[X]], align
419 // CHECK-NEXT: [[X_TMP:%.*]] = call i8* @llvm.objc.retain(i8* [[X_VAL]]) [[NUW]]
420 // CHECK-NEXT: [[BLOCK_FN_TMP:%.*]] = load i8*, i8** [[BLOCK_FN_PTR]]
421 // CHECK-NEXT: [[BLOCK_FN:%.*]] = bitcast i8* [[BLOCK_FN_TMP]] to void (i8*, i8*)*
422 // CHECK-NEXT: call void [[BLOCK_FN]](i8* noundef [[BLOCK_OPAQUE]], i8* noundef [[X_TMP]])
425 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[X]]
426 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]]
427 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
428 // CHECK-NEXT: void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
429 // CHECK-NEXT: ret void
432 @interface Test16_super @end
433 @interface Test16 : Test16_super {
436 @property (assign) int x;
437 @property (retain) id y;
440 @implementation Test16
444 // CHECK: define internal void @"\01-[Test16 dealloc]"(
445 // CHECK: [[SELF:%.*]] = alloca [[TEST16:%.*]]*, align
446 // CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align
447 // CHECK-NEXT: alloca
448 // CHECK-NEXT: store [[TEST16]]* {{%.*}}, [[TEST16]]** [[SELF]], align
449 // CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
450 // CHECK-NEXT: [[BASE:%.*]] = load [[TEST16]]*, [[TEST16]]** [[SELF]]
453 // CHECK-NEXT: [[BASE2:%.*]] = bitcast [[TEST16]]* [[BASE]] to i8*
454 // CHECK-NEXT: [[T0:%.*]] = getelementptr
455 // CHECK-NEXT: store i8* [[BASE2]], i8** [[T0]]
456 // CHECK-NEXT: load {{%.*}}*, {{%.*}}** @"OBJC_CLASSLIST_SUP_REFS_$_
457 // CHECK-NEXT: bitcast
458 // CHECK-NEXT: getelementptr
460 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
461 // CHECK-NEXT: call void bitcast (i8* ({{.*}})* @objc_msgSendSuper2 to void (
462 // CHECK-NEXT: ret void
466 // CHECK: define internal void @"\01-[Test16 .cxx_destruct]"(
467 // CHECK: [[SELF:%.*]] = alloca [[TEST16:%.*]]*, align
468 // CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align
469 // CHECK-NEXT: store [[TEST16]]* {{%.*}}, [[TEST16]]** [[SELF]], align
470 // CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
471 // CHECK-NEXT: [[BASE:%.*]] = load [[TEST16]]*, [[TEST16]]** [[SELF]]
474 // CHECK-NEXT: [[Y_OFF:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test16.y"
475 // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST16]]* [[BASE]] to i8*
476 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i64 [[Y_OFF]]
477 // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8**
478 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** [[T2]], i8* null) [[NUW]]
481 // CHECK-NEXT: [[Z_OFF:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test16.z"
482 // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST16]]* [[BASE]] to i8*
483 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i64 [[Z_OFF]]
484 // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8**
485 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** [[T2]], i8* null) [[NUW]]
487 // CHECK-NEXT: ret void
491 // This shouldn't crash.
493 @property (assign) int x;
495 @interface Test17B : Test17A
497 @implementation Test17B
498 - (int) x { return super.x + 1; }
502 // CHECK-LABEL: define{{.*}} void @test19()
503 // CHECK: [[X:%.*]] = alloca [5 x i8*], align 16
504 // CHECK: call void @llvm.lifetime.start
505 // CHECK-NEXT: [[T0:%.*]] = bitcast [5 x i8*]* [[X]] to i8*
506 // CHECK: call void @llvm.memset.p0i8.i64(i8* align 16 [[T0]], i8 0, i64 40, i1 false)
509 extern id test19_helper(void);
510 x[2] = test19_helper();
512 // CHECK-NEXT: [[T1:%.*]] = call i8* @test19_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
513 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
514 // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[X]], i64 0, i64 2
515 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[SLOT]]
516 // CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]]
517 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]]
519 // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[X]], i32 0, i32 0
520 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 5
521 // CHECK-NEXT: br label
523 // CHECK: [[AFTER:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
524 // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds i8*, i8** [[AFTER]], i64 -1
525 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[CUR]]
526 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]], !clang.imprecise_release
527 // CHECK-NEXT: [[EQ:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
528 // CHECK-NEXT: br i1 [[EQ]],
533 void test20(unsigned n) {
534 // CHECK-LABEL: define{{.*}} void @test20
535 // CHECK: [[N:%.*]] = alloca i32, align 4
536 // CHECK-NEXT: [[SAVED_STACK:%.*]] = alloca i8*
537 // CHECK-NEXT: [[VLA_EXPR:%.*]] = alloca i64, align 8
538 // CHECK-NEXT: store i32 {{%.*}}, i32* [[N]], align 4
542 // Capture the VLA size.
543 // CHECK-NEXT: [[T0:%.*]] = load i32, i32* [[N]], align 4
544 // CHECK-NEXT: [[DIM:%.*]] = zext i32 [[T0]] to i64
546 // Save the stack pointer.
547 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.stacksave()
548 // CHECK-NEXT: store i8* [[T0]], i8** [[SAVED_STACK]]
551 // CHECK-NEXT: [[VLA:%.*]] = alloca i8*, i64 [[DIM]], align 16
553 // Store the VLA #elements expression.
554 // CHECK-NEXT: store i64 [[DIM]], i64* [[VLA_EXPR]], align 8
557 // CHECK-NEXT: [[T0:%.*]] = bitcast i8** [[VLA]] to i8*
558 // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 [[DIM]], 8
559 // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 16 [[T0]], i8 0, i64 [[T1]], i1 false)
562 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8*, i8** [[VLA]], i64 [[DIM]]
563 // CHECK-NEXT: [[EMPTY:%.*]] = icmp eq i8** [[VLA]], [[END]]
564 // CHECK-NEXT: br i1 [[EMPTY]]
566 // CHECK: [[AFTER:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
567 // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds i8*, i8** [[AFTER]], i64 -1
568 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[CUR]]
569 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]], !clang.imprecise_release
570 // CHECK-NEXT: [[EQ:%.*]] = icmp eq i8** [[CUR]], [[VLA]]
571 // CHECK-NEXT: br i1 [[EQ]],
573 // CHECK: [[T0:%.*]] = load i8*, i8** [[SAVED_STACK]]
574 // CHECK-NEXT: call void @llvm.stackrestore(i8* [[T0]])
575 // CHECK-NEXT: ret void
578 void test21(unsigned n) {
579 // CHECK-LABEL: define{{.*}} void @test21
580 // CHECK: [[N:%.*]] = alloca i32, align 4
581 // CHECK-NEXT: [[SAVED_STACK:%.*]] = alloca i8*
582 // CHECK-NEXT: [[VLA_EXPR:%.*]] = alloca i64, align 8
583 // CHECK-NEXT: store i32 {{%.*}}, i32* [[N]], align 4
587 // Capture the VLA size.
588 // CHECK-NEXT: [[T0:%.*]] = load i32, i32* [[N]], align 4
589 // CHECK-NEXT: [[DIM:%.*]] = zext i32 [[T0]] to i64
591 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.stacksave()
592 // CHECK-NEXT: store i8* [[T0]], i8** [[SAVED_STACK]]
596 // CHECK-NEXT: [[T0:%.*]] = mul nuw i64 2, [[DIM]]
597 // CHECK-NEXT: [[VLA:%.*]] = alloca [3 x i8*], i64 [[T0]], align 16
599 // Store the VLA #elements expression.
600 // CHECK-NEXT: store i64 [[DIM]], i64* [[VLA_EXPR]], align 8
603 // CHECK-NEXT: [[T0:%.*]] = bitcast [3 x i8*]* [[VLA]] to i8*
604 // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 2, [[DIM]]
605 // CHECK-NEXT: [[T2:%.*]] = mul nuw i64 [[T1]], 24
606 // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 16 [[T0]], i8 0, i64 [[T2]], i1 false)
609 // CHECK-NEXT: [[T0:%.*]] = mul nuw i64 2, [[DIM]]
610 // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[VLA]], i32 0, i32 0
611 // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 [[T0]], 3
612 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 [[T1]]
613 // CHECK-NEXT: [[EMPTY:%.*]] = icmp eq i8** [[BEGIN]], [[END]]
614 // CHECK-NEXT: br i1 [[EMPTY]]
616 // CHECK: [[AFTER:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
617 // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds i8*, i8** [[AFTER]], i64 -1
618 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[CUR]]
619 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]], !clang.imprecise_release
620 // CHECK-NEXT: [[EQ:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
621 // CHECK-NEXT: br i1 [[EQ]],
623 // CHECK: [[T0:%.*]] = load i8*, i8** [[SAVED_STACK]]
624 // CHECK-NEXT: call void @llvm.stackrestore(i8* [[T0]])
625 // CHECK-NEXT: ret void
628 // rdar://problem/8922540
629 // Note that we no longer emit .release_ivars flags.
630 // rdar://problem/12492434
631 // Note that we set the flag saying that we need destruction *and*
632 // the flag saying that we don't also need construction.
633 // CHECK-GLOBALS: @"_OBJC_CLASS_RO_$_Test23" = internal global [[RO_T:%.*]] { i32 390,
634 @interface Test23 { id x; } @end
635 @implementation Test23 @end
637 // CHECK-GLOBALS: @"_OBJC_CLASS_RO_$_Test24" = internal global [[RO_T:%.*]] { i32 130,
638 @interface Test24 {} @end
639 @implementation Test24 @end
641 // rdar://problem/8941012
642 @interface Test26 { id x[4]; } @end
643 @implementation Test26 @end
644 // CHECK: define internal void @"\01-[Test26 .cxx_destruct]"(
645 // CHECK: [[SELF:%.*]] = load [[TEST26:%.*]]*, [[TEST26:%.*]]**
646 // CHECK-NEXT: [[OFFSET:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test26.x"
647 // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST26]]* [[SELF]] to i8*
648 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i64 [[OFFSET]]
649 // CHECK-NEXT: [[X:%.*]] = bitcast i8* [[T1]] to [4 x i8*]*
650 // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[X]], i32 0, i32 0
651 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 4
652 // CHECK-NEXT: br label
653 // CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
654 // CHECK-NEXT: [[CUR]] = getelementptr inbounds i8*, i8** [[PAST]], i64 -1
655 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** [[CUR]], i8* null)
656 // CHECK-NEXT: [[ISDONE:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
657 // CHECK-NEXT: br i1 [[ISDONE]],
660 // Check that 'init' retains self.
664 @implementation Test27
665 - (id) init { return self; }
666 // CHECK: define internal i8* @"\01-[Test27 init]"
667 // CHECK: [[SELF:%.*]] = alloca [[TEST27:%.*]]*,
668 // CHECK-NEXT: [[CMD:%.*]] = alloca i8*,
669 // CHECK-NEXT: store [[TEST27]]* {{%.*}}, [[TEST27]]** [[SELF]]
670 // CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
671 // CHECK-NEXT: [[T0:%.*]] = load [[TEST27]]*, [[TEST27]]** [[SELF]]
672 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST27]]* [[T0]] to i8*
673 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]])
674 // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST27]]*
675 // CHECK-NEXT: [[RET:%.*]] = bitcast [[TEST27]]* [[T3]] to i8*
676 // CHECK-NEXT: [[T0:%.*]] = load [[TEST27]]*, [[TEST27]]** [[SELF]]
677 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST27]]* [[T0]] to i8*
678 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
679 // CHECK-NEXT: ret i8* [[RET]]
683 // rdar://problem/8087194
685 @property (copy) id prop;
687 @implementation Test28
690 // CHECK: define internal void @"\01-[Test28 .cxx_destruct]"
691 // CHECK: [[SELF:%.*]] = load [[TEST28:%.*]]*, [[TEST28:%.*]]**
692 // CHECK-NEXT: [[OFFSET:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test28.prop"
693 // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST28]]* [[SELF]] to i8*
694 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i64 [[OFFSET]]
695 // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8**
696 // CHECK-NEXT: call void @llvm.objc.storeStrong(i8** [[T2]], i8* null)
697 // CHECK-NEXT: ret void
699 @interface Test29_super
700 - (id) initWithAllocator: (id) allocator;
702 @interface Test29 : Test29_super
704 - (id) initWithAllocator: (id) allocator;
706 @implementation Test29
707 static id _test29_allocator = 0;
709 // CHECK: define internal i8* @"\01-[Test29 init]"([[TEST29:%[^*]*]]* noundef {{%.*}},
710 // CHECK: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
711 // CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align 8
712 // CHECK-NEXT: store [[TEST29]]* {{%.*}}, [[TEST29]]** [[SELF]]
713 // CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
715 // Evaluate arguments. Note that the send argument is evaluated
716 // before the zeroing of self.
717 // CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]*, [[TEST29]]** [[SELF]], align 8
718 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** @_test29_allocator, align 8
720 // Implicit null of 'self', i.e. direct transfer of ownership.
721 // CHECK-NEXT: store [[TEST29]]* null, [[TEST29]]** [[SELF]]
723 // Actual message send.
724 // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
725 // CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
726 // CHECK-NEXT: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* noundef [[T2]], i8* noundef [[SEL]], i8* noundef [[T1]])
728 // Implicit write of result back into 'self'. This is not supposed to
729 // be detectable because we're supposed to ban accesses to the old
730 // self value past the delegate init call.
731 // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[CALL]] to [[TEST29]]*
732 // CHECK-NEXT: store [[TEST29]]* [[T0]], [[TEST29]]** [[SELF]]
735 // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[CALL]]
736 // CHECK-NEXT: [[CALL:%.*]] = bitcast
737 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* [[CALL]]) [[NUW]]
738 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[TEST29]]*
739 // CHECK-NEXT: [[RET:%.*]] = bitcast [[TEST29]]* [[T1]] to i8*
742 // CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]*, [[TEST29]]** [[SELF]]
743 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
744 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
747 // CHECK-NEXT: ret i8* [[RET]]
748 return [self initWithAllocator: _test29_allocator];
750 - (id) initWithAllocator: (id) allocator {
751 // CHECK: define internal i8* @"\01-[Test29 initWithAllocator:]"(
752 // CHECK: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
753 // CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align 8
754 // CHECK-NEXT: [[ALLOCATOR:%.*]] = alloca i8*, align 8
755 // CHECK-NEXT: alloca
756 // CHECK-NEXT: store [[TEST29]]* {{%.*}}, [[TEST29]]** [[SELF]]
757 // CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
758 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* {{%.*}})
759 // CHECK-NEXT: store i8* [[T0]], i8** [[ALLOCATOR]]
761 // Evaluate arguments. Note that the send argument is evaluated
762 // before the zeroing of self.
763 // CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]*, [[TEST29]]** [[SELF]]
764 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[ALLOCATOR]], align 8
766 // Implicit null of 'self', i.e. direct transfer of ownership.
767 // CHECK-NEXT: store [[TEST29]]* null, [[TEST29]]** [[SELF]]
769 // Actual message send.
770 // CHECK: [[CALL:%.*]] = call {{.*}} @objc_msgSendSuper2
772 // Implicit write of result back into 'self'. This is not supposed to
773 // be detectable because we're supposed to ban accesses to the old
774 // self value past the delegate init call.
775 // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[CALL]] to [[TEST29]]*
776 // CHECK-NEXT: store [[TEST29]]* [[T0]], [[TEST29]]** [[SELF]]
779 // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[CALL]] to [[TEST29]]*
780 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
781 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]]) [[NUW]]
782 // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST29]]*
783 // CHECK-NEXT: [[T4:%.*]] = load [[TEST29]]*, [[TEST29]]** [[SELF]], align
784 // CHECK-NEXT: store [[TEST29]]* [[T3]], [[TEST29]]** [[SELF]], align
785 // CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST29]]* [[T4]] to i8*
786 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T5]])
789 // CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]*, [[TEST29]]** [[SELF]]
790 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
791 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]]) [[NUW]]
792 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[TEST29]]*
793 // CHECK-NEXT: [[RET:%.*]] = bitcast [[TEST29]]* [[T1]] to i8*
796 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[ALLOCATOR]]
797 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]], !clang.imprecise_release
799 // CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]*, [[TEST29]]** [[SELF]]
800 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
801 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
804 // CHECK-NEXT: ret i8* [[RET]]
805 self = [super initWithAllocator: allocator];
810 typedef struct Test30_helper Test30_helper;
813 - (Test30_helper*) initHelper;
815 @implementation Test30 {
819 // CHECK: define internal i8* @"\01-[Test30 init]"([[TEST30:%[^*]*]]* noundef {{%.*}},
820 // CHECK: [[RET:%.*]] = alloca [[TEST30]]*
821 // CHECK-NEXT: alloca i8*
822 // CHECK-NEXT: store [[TEST30]]* {{%.*}}, [[TEST30]]** [[SELF]]
826 // CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]*, [[TEST30]]** [[SELF]]
827 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
828 // CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
829 // CHECK-NEXT: [[CALL:%.*]] = call [[TEST30_HELPER:%.*]]* bitcast {{.*}} @objc_msgSend {{.*}}(i8* noundef [[T1]], i8* noundef [[SEL]])
832 // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST30_HELPER]]* [[CALL]] to i8*
833 // CHECK-NEXT: [[T1:%.*]] = load [[TEST30]]*, [[TEST30]]** [[SELF]]
834 // CHECK-NEXT: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test30.helper"
835 // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST30]]* [[T1]] to i8*
836 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, i8* [[T2]], i64 [[IVAR]]
837 // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
838 // CHECK-NEXT#: [[T5:%.*]] = load i8*, i8** [[T4]]
839 // CHECK-NEXT#: [[T6:%.*]] = call i8* @llvm.objc.retain(i8* [[T0]])
840 // CHECK-NEXT#: call void @llvm.objc.release(i8* [[T5]])
841 // CHECK-NEXT: store i8* [[T0]], i8** [[T4]]
844 // CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]*, [[TEST30]]** [[SELF]]
845 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
846 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]])
847 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[TEST30]]*
848 // CHECK-NEXT: [[RET:%.*]] = bitcast [[TEST30]]* [[T1]] to i8*
851 // CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]*, [[TEST30]]** [[SELF]]
852 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
853 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
856 // CHECK-NEXT: ret i8* [[RET]]
857 self->helper = [self initHelper];
860 - (Test30_helper*) initHelper {
861 // CHECK: define internal [[TEST30_HELPER]]* @"\01-[Test30 initHelper]"(
863 // CHECK-NEXT: alloca
866 // CHECK-NEXT: ret [[TEST30_HELPER]]* null
872 __attribute__((ns_returns_retained)) id test32(void) {
873 // CHECK-LABEL: define{{.*}} i8* @test32()
874 // CHECK: [[T0:%.*]] = call i8* @test32_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
875 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T0]])
876 // CHECK-NEXT: ret i8* [[T0]]
877 extern id test32_helper(void);
878 return test32_helper();
883 - (void) give: (Test33_a **) x;
884 - (void) take: (Test33_a **) x;
885 - (void) giveStrong: (out __strong Test33_a **) x;
886 - (void) takeStrong: (inout __strong Test33_a **) x;
887 - (void) giveOut: (out Test33_a **) x;
889 void test33(Test33 *ptr) {
893 [ptr giveStrong: &a];
894 [ptr takeStrong: &a];
897 // CHECK: define{{.*}} void @test33([[TEST33:%.*]]*
898 // CHECK: [[PTR:%.*]] = alloca [[TEST33]]*
899 // CHECK-NEXT: [[A:%.*]] = alloca [[A_T:%.*]]*
900 // CHECK-NEXT: [[TEMP0:%.*]] = alloca [[A_T]]*
901 // CHECK-NEXT: [[TEMP1:%.*]] = alloca [[A_T]]*
902 // CHECK-NEXT: [[TEMP2:%.*]] = alloca [[A_T]]*
903 // CHECK-NEXT: bitcast
904 // CHECK-NEXT: llvm.objc.retain
905 // CHECK-NEXT: bitcast
907 // CHECK-NEXT: bitcast
908 // CHECK-NEXT: call void @llvm.lifetime.start
909 // CHECK-NEXT: store [[A_T]]* null, [[A_T]]** [[A]]
911 // CHECK-NEXT: load [[TEST33]]*, [[TEST33]]** [[PTR]]
912 // CHECK-NEXT: [[W0:%.*]] = load [[A_T]]*, [[A_T]]** [[A]]
913 // CHECK-NEXT: store [[A_T]]* [[W0]], [[A_T]]** [[TEMP0]]
914 // CHECK-NEXT: bitcast
915 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
916 // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** noundef [[TEMP0]])
917 // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]*, [[A_T]]** [[TEMP0]]
918 // CHECK-NEXT: [[T1:%.*]] = bitcast [[A_T]]* [[T0]] to i8*
919 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]])
920 // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A_T]]*
921 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.use([[A_T]]* [[W0]]) [[NUW]]
922 // CHECK-NEXT: [[T4:%.*]] = load [[A_T]]*, [[A_T]]** [[A]]
923 // CHECK-NEXT: store [[A_T]]* [[T3]], [[A_T]]** [[A]]
924 // CHECK-NEXT: [[T5:%.*]] = bitcast [[A_T]]* [[T4]] to i8*
925 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T5]])
927 // CHECK-NEXT: load [[TEST33]]*, [[TEST33]]** [[PTR]]
928 // CHECK-NEXT: [[W0:%.*]] = load [[A_T]]*, [[A_T]]** [[A]]
929 // CHECK-NEXT: store [[A_T]]* [[W0]], [[A_T]]** [[TEMP1]]
930 // CHECK-NEXT: bitcast
931 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
932 // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** noundef [[TEMP1]])
933 // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]*, [[A_T]]** [[TEMP1]]
934 // CHECK-NEXT: [[T1:%.*]] = bitcast [[A_T]]* [[T0]] to i8*
935 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]])
936 // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A_T]]*
937 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.use([[A_T]]* [[W0]]) [[NUW]]
938 // CHECK-NEXT: [[T4:%.*]] = load [[A_T]]*, [[A_T]]** [[A]]
939 // CHECK-NEXT: store [[A_T]]* [[T3]], [[A_T]]** [[A]]
940 // CHECK-NEXT: [[T5:%.*]] = bitcast [[A_T]]* [[T4]] to i8*
941 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T5]])
943 // CHECK-NEXT: load [[TEST33]]*, [[TEST33]]** [[PTR]]
944 // CHECK-NEXT: bitcast
945 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
946 // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** noundef [[A]])
948 // CHECK-NEXT: load [[TEST33]]*, [[TEST33]]** [[PTR]]
949 // CHECK-NEXT: bitcast
950 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
951 // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** noundef [[A]])
954 // CHECK-NEXT: load [[TEST33]]*, [[TEST33]]** [[PTR]]
955 // CHECK-NEXT: store [[A_T]]* null, [[A_T]]** [[TEMP2]]
956 // CHECK-NEXT: bitcast
957 // CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
958 // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** noundef [[TEMP2]])
959 // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]*, [[A_T]]** [[TEMP2]]
960 // CHECK-NEXT: [[T1:%.*]] = bitcast [[A_T]]* [[T0]] to i8*
961 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]])
962 // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A_T]]*
963 // CHECK-NEXT: [[T4:%.*]] = load [[A_T]]*, [[A_T]]** [[A]]
964 // CHECK-NEXT: store [[A_T]]* [[T3]], [[A_T]]** [[A]]
965 // CHECK-NEXT: [[T5:%.*]] = bitcast [[A_T]]* [[T4]] to i8*
966 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T5]])
969 // CHECK-NEXT: bitcast
970 // CHECK-NEXT: llvm.objc.release
971 // CHECK-NEXT: bitcast
972 // CHECK-NEXT: call void @llvm.lifetime.end
974 // CHECK-NEXT: bitcast
975 // CHECK-NEXT: llvm.objc.release
976 // CHECK-NEXT: ret void
980 // CHECK-LABEL: define{{.*}} void @test36
982 // CHECK: [[X:%.*]] = alloca i8*
984 // CHECK: call i8* @llvm.objc.retain
985 // CHECK: call i8* @llvm.objc.retain
986 // CHECK: call i8* @llvm.objc.retain
987 id array[3] = { @"A", x, @"y" };
989 // CHECK: [[T0:%.*]] = load i8*, i8** [[X]]
990 // CHECK-NEXT: store i8* null, i8** [[X]]
991 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
995 // CHECK: call void @llvm.objc.release
998 // CHECK: call void @llvm.objc.release
999 // CHECK-NEXT: ret void
1004 extern void test37_helper(id *);
1006 test37_helper(&var);
1008 // CHECK-LABEL: define{{.*}} void @test37()
1009 // CHECK: [[VAR:%.*]] = alloca [[TEST37:%.*]]*,
1010 // CHECK-NEXT: [[TEMP:%.*]] = alloca i8*
1011 // CHECK-NEXT: [[VARPTR1:%.*]] = bitcast [[TEST37]]** [[VAR]] to i8*
1012 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[VARPTR1]])
1013 // CHECK-NEXT: store [[TEST37]]* null, [[TEST37]]** [[VAR]]
1015 // CHECK-NEXT: [[W0:%.*]] = load [[TEST37]]*, [[TEST37]]** [[VAR]]
1016 // CHECK-NEXT: [[W1:%.*]] = bitcast [[TEST37]]* [[W0]] to i8*
1017 // CHECK-NEXT: store i8* [[W1]], i8** [[TEMP]]
1018 // CHECK-NEXT: call void @test37_helper(i8** noundef [[TEMP]])
1019 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[TEMP]]
1020 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[TEST37]]*
1021 // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST37]]* [[T1]] to i8*
1022 // CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.retain(i8* [[T2]])
1023 // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[TEST37]]*
1024 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.use(i8* [[W1]]) [[NUW]]
1025 // CHECK-NEXT: [[T5:%.*]] = load [[TEST37]]*, [[TEST37]]** [[VAR]]
1026 // CHECK-NEXT: store [[TEST37]]* [[T4]], [[TEST37]]** [[VAR]]
1027 // CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST37]]* [[T5]] to i8*
1028 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T6]])
1030 // CHECK-NEXT: [[T0:%.*]] = load [[TEST37]]*, [[TEST37]]** [[VAR]]
1031 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST37]]* [[T0]] to i8*
1032 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
1033 // CHECK-NEXT: [[VARPTR2:%.*]] = bitcast [[TEST37]]** [[VAR]] to i8*
1034 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[VARPTR2]])
1035 // CHECK-NEXT: ret void
1038 @interface Test43 @end
1039 @implementation Test43
1040 - (id) test __attribute__((ns_returns_retained)) {
1041 extern id test43_produce(void);
1042 return test43_produce();
1043 // CHECK: call i8* @test43_produce(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1044 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(
1050 @property (retain) id x;
1052 @implementation Test45
1055 // CHECK: define internal i8* @"\01-[Test45 x]"(
1056 // CHECK: [[CALL:%.*]] = tail call i8* @objc_getProperty(
1057 // CHECK-NEXT: ret i8* [[CALL]]
1059 // rdar://problem/9315552
1060 void test46(__weak id *wp, __weak volatile id *wvp) {
1061 extern id test46_helper(void);
1063 // TODO: this is sub-optimal, we should retain at the actual call site.
1065 // CHECK: [[T1:%.*]] = call i8* @test46_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1066 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1067 // CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** {{%.*}}, align 8
1068 // CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
1069 // CHECK-NEXT: [[T4:%.*]] = call i8* @llvm.objc.retain(i8* [[T3]])
1070 // CHECK-NEXT: store i8* [[T4]], i8**
1071 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
1072 id x = *wp = test46_helper();
1074 // CHECK: [[T1:%.*]] = call i8* @test46_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1075 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1076 // CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** {{%.*}}, align 8
1077 // CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
1078 // CHECK-NEXT: [[T4:%.*]] = call i8* @llvm.objc.retain(i8* [[T3]])
1079 // CHECK-NEXT: store i8* [[T4]], i8**
1080 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
1081 id y = *wvp = test46_helper();
1084 // rdar://problem/9378887
1086 extern id test47_helper(void);
1087 id x = x = test47_helper();
1089 // CHECK-LABEL: define{{.*}} void @test47()
1090 // CHECK: [[X:%.*]] = alloca i8*
1091 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
1092 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
1093 // CHECK-NEXT: store i8* null, i8** [[X]]
1094 // CHECK-NEXT: [[T0:%.*]] = call i8* @test47_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1095 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T0]])
1096 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
1097 // CHECK-NEXT: store i8* [[T0]], i8** [[X]]
1098 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
1099 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retain(i8* [[T0]])
1100 // CHECK-NEXT: [[T3:%.*]] = load i8*, i8** [[X]]
1101 // CHECK-NEXT: store i8* [[T2]], i8** [[X]]
1102 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T3]])
1103 // CHECK-NEXT: [[T4:%.*]] = load i8*, i8** [[X]]
1104 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T4]])
1105 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
1106 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
1107 // CHECK-NEXT: ret void
1111 extern id test48_helper(void);
1112 __weak id x = x = test48_helper();
1113 // CHECK-LABEL: define{{.*}} void @test48()
1114 // CHECK: [[X:%.*]] = alloca i8*
1115 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
1116 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
1117 // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.objc.initWeak(i8** [[X]], i8* null)
1118 // CHECK-NEXT: [[T2:%.*]] = call i8* @test48_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1119 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T2]])
1120 // CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[X]], i8* [[T2]])
1121 // CHECK-NEXT: [[T4:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[X]], i8* [[T3]])
1122 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T2]])
1123 // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[X]])
1124 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
1125 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
1126 // CHECK-NEXT: ret void
1130 extern id test49_helper(void);
1131 __autoreleasing id x = x = test49_helper();
1132 // CHECK-LABEL: define{{.*}} void @test49()
1133 // CHECK: [[X:%.*]] = alloca i8*
1134 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
1135 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
1136 // CHECK-NEXT: store i8* null, i8** [[X]]
1137 // CHECK-NEXT: [[T0:%.*]] = call i8* @test49_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1138 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T0]])
1139 // CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.autorelease(i8* [[T0]])
1140 // CHECK-NEXT: store i8* [[T1]], i8** [[X]]
1141 // CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.retainAutorelease(i8* [[T1]])
1142 // CHECK-NEXT: store i8* [[T3]], i8** [[X]]
1143 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
1144 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
1145 // CHECK-NEXT: ret void
1152 // CHECK: [[T0:%.*]] = call i8* @llvm.objc.retain
1153 // CHECK: call void @llvm.objc.release
1162 typedef struct CGPoint CGPoint;
1165 @property (assign) CGPoint point;
1172 // rdar://problem/9400398
1174 id test52_helper(int) __attribute__((ns_returns_retained));
1175 return ({ int x = 5; test52_helper(x); });
1177 // CHECK-LABEL: define{{.*}} i8* @test52()
1178 // CHECK: [[X:%.*]] = alloca i32
1179 // CHECK-NEXT: [[TMPALLOCA:%.*]] = alloca i8*
1180 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i32* [[X]] to i8*
1181 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 4, i8* [[XPTR1]])
1182 // CHECK-NEXT: store i32 5, i32* [[X]],
1183 // CHECK-NEXT: [[T0:%.*]] = load i32, i32* [[X]],
1184 // CHECK-NEXT: [[T1:%.*]] = call i8* @test52_helper(i32 noundef [[T0]])
1185 // CHECK-NEXT: store i8* [[T1]], i8** [[TMPALLOCA]]
1186 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i32* [[X]] to i8*
1187 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 4, i8* [[XPTR2]])
1188 // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[TMPALLOCA]]
1189 // CHECK-NEXT: [[T3:%.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* [[T2]])
1190 // CHECK-NEXT: ret i8* [[T3]]
1193 // rdar://problem/9400644
1195 id test53_helper(void);
1196 id x = ({ id y = test53_helper(); y; });
1198 // CHECK-LABEL: define{{.*}} void @test53()
1199 // CHECK: [[X:%.*]] = alloca i8*,
1200 // CHECK-NEXT: [[Y:%.*]] = alloca i8*,
1201 // CHECK-NEXT: [[TMPALLOCA:%.*]] = alloca i8*,
1202 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
1203 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
1204 // CHECK-NEXT: [[YPTR1:%.*]] = bitcast i8** [[Y]] to i8*
1205 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[YPTR1]])
1206 // CHECK-NEXT: [[T1:%.*]] = call i8* @test53_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1207 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1208 // CHECK-NEXT: store i8* [[T1]], i8** [[Y]],
1209 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[Y]],
1210 // CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retain(i8* [[T0]])
1211 // CHECK-NEXT: store i8* [[T1]], i8** [[TMPALLOCA]]
1212 // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[Y]]
1213 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T2]])
1214 // CHECK-NEXT: [[YPTR2:%.*]] = bitcast i8** [[Y]] to i8*
1215 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[YPTR2]])
1216 // CHECK-NEXT: [[T3:%.*]] = load i8*, i8** [[TMPALLOCA]]
1217 // CHECK-NEXT: store i8* [[T3]], i8** [[X]],
1218 // CHECK-NEXT: load i8*, i8** [[X]],
1219 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[X]]
1220 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
1221 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
1222 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
1223 // CHECK-NEXT: ret void
1226 // <rdar://problem/9758798>
1227 // CHECK-LABEL: define{{.*}} void @test54(i32 noundef %first, ...)
1228 void test54(int first, ...) {
1229 __builtin_va_list arglist;
1230 // CHECK: call void @llvm.va_start
1231 __builtin_va_start(arglist, first);
1232 // CHECK: call i8* @llvm.objc.retain
1233 id obj = __builtin_va_arg(arglist, id);
1234 // CHECK: call void @llvm.va_end
1235 __builtin_va_end(arglist);
1236 // CHECK: call void @llvm.objc.release
1241 @interface Test55Base @end
1242 @interface Test55 : Test55Base @end
1243 @implementation Test55 (Category)
1246 // CHECK: define internal void @"\01-[Test55(Category) dealloc]"(
1248 // CHECK: call void bitcast (i8* ({{%.*}}*, i8*, ...)* @objc_msgSendSuper2 to void ({{%.*}}*, i8*)*)(
1250 // rdar://problem/8024350
1251 @protocol Test56Protocol
1252 + (id) make __attribute__((ns_returns_retained));
1254 @interface Test56<Test56Protocol> @end
1255 @implementation Test56
1256 // CHECK: define internal i8* @"\01+[Test56 make]"(
1258 extern id test56_helper(void);
1259 // CHECK: [[T1:%.*]] = call i8* @test56_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1260 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1261 // CHECK-NEXT: ret i8* [[T1]]
1262 return test56_helper();
1265 void test56_test(void) {
1266 id x = [Test56 make];
1267 // CHECK-LABEL: define{{.*}} void @test56_test()
1268 // CHECK: [[X:%.*]] = alloca i8*, align 8
1269 // CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
1270 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
1271 // CHECK: [[T0:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(
1272 // CHECK-NEXT: store i8* [[T0]], i8** [[X]]
1273 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[X]]
1274 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
1275 // CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
1276 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
1277 // CHECK-NEXT: ret void
1280 // rdar://problem/9784964
1282 @property (nonatomic, strong) id strong;
1283 @property (nonatomic, weak) id weak;
1284 @property (nonatomic, unsafe_unretained) id unsafe;
1286 @implementation Test57
1287 @synthesize strong, weak, unsafe;
1289 // CHECK: define internal i8* @"\01-[Test57 strong]"(
1290 // CHECK: [[T0:%.*]] = load [[TEST57:%.*]]*, [[TEST57:%.*]]** {{%.*}}
1291 // CHECK-NEXT: [[T1:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test57.strong"
1292 // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST57]]* [[T0]] to i8*
1293 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, i8* [[T2]], i64 [[T1]]
1294 // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
1295 // CHECK-NEXT: [[T5:%.*]] = load i8*, i8** [[T4]]
1296 // CHECK-NEXT: ret i8* [[T5]]
1298 // CHECK: define internal i8* @"\01-[Test57 weak]"(
1299 // CHECK: [[T0:%.*]] = load [[TEST57]]*, [[TEST57]]** {{%.*}}
1300 // CHECK-NEXT: [[T1:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test57.weak"
1301 // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST57]]* [[T0]] to i8*
1302 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, i8* [[T2]], i64 [[T1]]
1303 // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
1304 // CHECK-NEXT: [[T5:%.*]] = call i8* @llvm.objc.loadWeakRetained(i8** [[T4]])
1305 // CHECK-NEXT: [[T6:%.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* [[T5]])
1306 // CHECK-NEXT: ret i8* [[T6]]
1308 // CHECK: define internal i8* @"\01-[Test57 unsafe]"(
1309 // CHECK: [[T0:%.*]] = load [[TEST57]]*, [[TEST57]]** {{%.*}}
1310 // CHECK-NEXT: [[T1:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test57.unsafe"
1311 // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST57]]* [[T0]] to i8*
1312 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8, i8* [[T2]], i64 [[T1]]
1313 // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
1314 // CHECK-NEXT: [[T5:%.*]] = load i8*, i8** [[T4]]
1315 // CHECK-NEXT: ret i8* [[T5]]
1317 // rdar://problem/9842343
1319 extern id test59_getlock(void);
1320 extern void test59_body(void);
1321 @synchronized (test59_getlock()) {
1325 // CHECK-LABEL: define{{.*}} void @test59()
1326 // CHECK: [[T1:%.*]] = call i8* @test59_getlock(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1327 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1328 // CHECK-NEXT: call i32 @objc_sync_enter(i8* [[T1]])
1329 // CHECK-NEXT: call void @test59_body()
1330 // CHECK-NEXT: call i32 @objc_sync_exit(i8* [[T1]])
1331 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
1332 // CHECK-NEXT: ret void
1335 // Verify that we don't try to reclaim the result of performSelector.
1336 // rdar://problem/9887545
1338 - (id) performSelector: (SEL) selector;
1339 - (void) test61_void;
1343 // CHECK-LABEL: define{{.*}} void @test61()
1344 // CHECK: [[Y:%.*]] = alloca i8*, align 8
1346 extern id test61_make(void);
1348 // CHECK-NEXT: [[T0:%.*]] = call i8* @test61_make(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1349 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T0]])
1350 // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
1351 // CHECK-NEXT: [[T3:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
1352 // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* noundef [[T1]], i8* noundef [[T3]], i8* noundef [[T2]])
1353 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
1354 [test61_make() performSelector: @selector(test61_void)];
1356 // CHECK-NEXT: [[YPTR1:%.*]] = bitcast i8** [[Y]] to i8*
1357 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[YPTR1]])
1358 // CHECK-NEXT: [[T1:%.*]] = call i8* @test61_make(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1359 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1360 // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
1361 // CHECK-NEXT: [[T3:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
1362 // CHECK-NEXT: [[T5:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* noundef [[T1]], i8* noundef [[T3]], i8* noundef [[T2]]){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1363 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T5]])
1364 // CHECK-NEXT: store i8* [[T5]], i8** [[Y]]
1365 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
1366 id y = [test61_make() performSelector: @selector(test61_id)];
1368 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[Y]]
1369 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
1370 // CHECK-NEXT: [[YPTR2:%.*]] = bitcast i8** [[Y]] to i8*
1371 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[YPTR2]])
1372 // CHECK-NEXT: ret void
1375 // rdar://problem/9891815
1377 // CHECK-LABEL: define{{.*}} void @test62()
1378 // CHECK: [[I:%.*]] = alloca i32, align 4
1379 // CHECK-NEXT: [[CLEANUP_VALUE:%.*]] = alloca i8*
1380 // CHECK-NEXT: [[CLEANUP_REQUIRED:%.*]] = alloca i1
1381 extern id test62_make(void);
1382 extern void test62_body(void);
1384 // CHECK-NEXT: [[IPTR:%.*]] = bitcast i32* [[I]] to i8*
1385 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 4, i8* [[IPTR]])
1386 // CHECK-NEXT: store i32 0, i32* [[I]], align 4
1387 // CHECK-NEXT: br label
1389 // CHECK: [[T0:%.*]] = load i32, i32* [[I]], align 4
1390 // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 20
1391 // CHECK-NEXT: br i1 [[T1]],
1393 for (unsigned i = 0; i != 20; ++i) {
1394 // CHECK: [[T0:%.*]] = load i32, i32* [[I]], align 4
1395 // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
1396 // CHECK-NEXT: store i1 false, i1* [[CLEANUP_REQUIRED]]
1397 // CHECK-NEXT: br i1 [[T1]],
1398 // CHECK: [[T1:%.*]] = call i8* @test62_make(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1399 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1400 // CHECK-NEXT: store i8* [[T1]], i8** [[CLEANUP_VALUE]]
1401 // CHECK-NEXT: store i1 true, i1* [[CLEANUP_REQUIRED]]
1402 // CHECK-NEXT: [[T2:%.*]] = icmp ne i8* [[T1]], null
1403 // CHECK-NEXT: br label
1404 // CHECK: [[COND:%.*]] = phi i1 [ false, {{%.*}} ], [ [[T2]], {{%.*}} ]
1405 // CHECK-NEXT: [[T0:%.*]] = load i1, i1* [[CLEANUP_REQUIRED]]
1406 // CHECK-NEXT: br i1 [[T0]],
1407 // CHECK: [[T0:%.*]] = load i8*, i8** [[CLEANUP_VALUE]]
1408 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
1409 // CHECK-NEXT: br label
1410 // CHECK: br i1 [[COND]]
1411 // CHECK: call void @test62_body()
1412 // CHECK-NEXT: br label
1414 if (i != 0 && test62_make() != 0)
1418 // CHECK: [[T0:%.*]] = load i32, i32* [[I]], align 4
1419 // CHECK-NEXT: [[T1:%.*]] = add i32 [[T0]], 1
1420 // CHECK-NEXT: store i32 [[T1]], i32* [[I]]
1421 // CHECK-NEXT: br label
1432 @property NSString *address;
1435 @implementation Person
1436 @synthesize address;
1438 // CHECK: tail call i8* @objc_getProperty
1439 // CHECK: call void @objc_setProperty
1441 // Verify that we successfully parse and preserve this attribute in
1444 - (void) consume: (id __attribute__((ns_consumed))) ptr;
1447 extern Test66 *test66_receiver(void);
1448 extern id test66_arg(void);
1449 [test66_receiver() consume: test66_arg()];
1451 // CHECK-LABEL: define{{.*}} void @test66()
1452 // CHECK: [[T3:%.*]] = call [[TEST66:%.*]]* @test66_receiver(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1453 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST66]]* [[T3]])
1454 // CHECK-NEXT: [[T4:%.*]] = call i8* @test66_arg(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1455 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T4]])
1456 // CHECK-NEXT: [[T7:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
1457 // CHECK-NEXT: [[SIX:%.*]] = icmp eq i8* [[T7]], null
1458 // CHECK-NEXT: br i1 [[SIX]], label [[NULINIT:%.*]], label %[[CALL:.*]]
1460 // CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES
1461 // CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* noundef [[T7]], i8* noundef [[SEL]], i8* noundef [[T4]])
1462 // CHECK-NEXT: br label [[CONT:%.*]]
1463 // CHECK: call void @llvm.objc.release(i8* [[T4]]) [[NUW]]
1464 // CHECK-NEXT: br label [[CONT:%.*]]
1465 // CHECK: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
1466 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T8]])
1467 // CHECK-NEXT: ret void
1469 // rdar://problem/9953540
1470 Class test67_helper(void);
1472 Class cl = test67_helper();
1474 // CHECK-LABEL: define{{.*}} void @test67()
1475 // CHECK: [[CL:%.*]] = alloca i8*, align 8
1476 // CHECK-NEXT: [[CLPTR1:%.*]] = bitcast i8** [[CL]] to i8*
1477 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[CLPTR1]])
1478 // CHECK-NEXT: [[T0:%.*]] = call i8* @test67_helper()
1479 // CHECK-NEXT: store i8* [[T0]], i8** [[CL]], align 8
1480 // CHECK-NEXT: [[CLPTR2:%.*]] = bitcast i8** [[CL]] to i8*
1481 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[CLPTR2]])
1482 // CHECK-NEXT: ret void
1484 Class test68_helper(void);
1486 __strong Class cl = test67_helper();
1488 // CHECK-LABEL: define{{.*}} void @test68()
1489 // CHECK: [[CL:%.*]] = alloca i8*, align 8
1490 // CHECK-NEXT: [[CLPTR1:%.*]] = bitcast i8** [[CL]] to i8*
1491 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[CLPTR1]])
1492 // CHECK-NEXT: [[T1:%.*]] = call i8* @test67_helper(){{.*}} [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
1493 // CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use(i8* [[T1]])
1494 // CHECK-NEXT: store i8* [[T1]], i8** [[CL]], align 8
1495 // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[CL]]
1496 // CHECK-NEXT: call void @llvm.objc.release(i8* [[T2]])
1497 // CHECK-NEXT: [[CLPTR2:%.*]] = bitcast i8** [[CL]] to i8*
1498 // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[CLPTR2]])
1499 // CHECK-NEXT: ret void
1501 // rdar://problem/10564852
1502 @interface Test69 @end
1503 @implementation Test69
1504 - (id) foo { return self; }
1506 // CHECK: define internal i8* @"\01-[Test69 foo]"(
1507 // CHECK: [[SELF:%.*]] = alloca [[TEST69:%.*]]*, align 8
1508 // CHECK: [[T0:%.*]] = load [[TEST69]]*, [[TEST69]]** [[SELF]], align 8
1509 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST69]]* [[T0]] to i8*
1510 // CHECK-NEXT: ret i8* [[T1]]
1512 // rdar://problem/10907547
1514 // CHECK-LABEL: define{{.*}} void @test70
1515 // CHECK: store i8* null, i8**
1516 // CHECK: store i8* null, i8**
1517 // CHECK: [[ID:%.*]] = call i8* @llvm.objc.retain(i8*
1518 // CHECK: store i8* [[ID]], i8**
1524 // Be sure that we emit lifetime intrinsics only after dtors
1530 struct AggDtor getAggDtor(void);
1532 // CHECK-LABEL: define{{.*}} void @test71
1534 // CHECK: %[[T:[^ ]+]] = bitcast %struct.AggDtor* %[[TMP1:[^ ]+]] to i8*
1535 // CHECK: call void @llvm.lifetime.start.p0i8({{[^,]+}}, i8* %[[T]])
1536 // CHECK: call void @getAggDtor(%struct.AggDtor* sret(%struct.AggDtor) align 8 %[[TMP1]])
1537 // CHECK: %[[T:[^ ]+]] = bitcast %struct.AggDtor* %[[TMP1]] to i8**
1538 // CHECK: call void @__destructor_8_s40(i8** %[[T]])
1539 // CHECK: %[[T:[^ ]+]] = bitcast %struct.AggDtor* %[[TMP1:[^ ]+]] to i8*
1540 // CHECK: call void @llvm.lifetime.end.p0i8({{[^,]+}}, i8* %[[T]])
1541 // CHECK: %[[T:[^ ]+]] = bitcast %struct.AggDtor* %[[TMP2:[^ ]+]] to i8*
1542 // CHECK: call void @llvm.lifetime.start.p0i8({{[^,]+}}, i8* %[[T]])
1543 // CHECK: call void @getAggDtor(%struct.AggDtor* sret(%struct.AggDtor) align 8 %[[TMP2]])
1544 // CHECK: %[[T:[^ ]+]] = bitcast %struct.AggDtor* %[[TMP2]] to i8**
1545 // CHECK: call void @__destructor_8_s40(i8** %[[T]])
1546 // CHECK: %[[T:[^ ]+]] = bitcast %struct.AggDtor* %[[TMP2:[^ ]+]] to i8*
1547 // CHECK: call void @llvm.lifetime.end.p0i8({{[^,]+}}, i8* %[[T]])
1552 // Check that no extra release calls are emitted to detruct the compond literal.
1554 // CHECK: define{{.*}} void @test72(i8* noundef %[[A:.*]], i8* noundef %[[B:.*]])
1555 // CHECK: %[[A_ADDR:.*]] = alloca i8*, align 8
1556 // CHECK: %[[B_ADDR:.*]] = alloca i8*, align 8
1557 // CHECK: %[[T:.*]] = alloca [2 x i8*], align 16
1558 // CHECK: %[[V0:.*]] = call i8* @llvm.objc.retain(i8* %[[A]])
1559 // CHECK: %[[V1:.*]] = call i8* @llvm.objc.retain(i8* %[[B]]) #2
1560 // CHECK: %[[ARRAYINIT_BEGIN:.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %[[T]], i64 0, i64 0
1561 // CHECK: %[[V3:.*]] = load i8*, i8** %[[A_ADDR]], align 8, !tbaa !7
1562 // CHECK: %[[V4:.*]] = call i8* @llvm.objc.retain(i8* %[[V3]]) #2
1563 // CHECK: store i8* %[[V4]], i8** %[[ARRAYINIT_BEGIN]], align 8, !tbaa !7
1564 // CHECK: %[[ARRAYINIT_ELEMENT:.*]] = getelementptr inbounds i8*, i8** %[[ARRAYINIT_BEGIN]], i64 1
1565 // CHECK: %[[V5:.*]] = load i8*, i8** %[[B_ADDR]], align 8, !tbaa !7
1566 // CHECK: %[[V6:.*]] = call i8* @llvm.objc.retain(i8* %[[V5]]) #2
1567 // CHECK: store i8* %[[V6]], i8** %[[ARRAYINIT_ELEMENT]], align 8, !tbaa !7
1568 // CHECK: %[[ARRAY_BEGIN:.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %[[T]], i32 0, i32 0
1569 // CHECK: %[[V7:.*]] = getelementptr inbounds i8*, i8** %[[ARRAY_BEGIN]], i64 2
1571 // CHECK-NOT: call void @llvm.objc.release
1573 // CHECK: %[[ARRAYDESTROY_ELEMENTPAST:.*]] = phi i8** [ %[[V7]], %{{.*}} ], [ %[[ARRAYDESTROY_ELEMENT:.*]], %{{.*}} ]
1574 // CHECK: %[[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds i8*, i8** %[[ARRAYDESTROY_ELEMENTPAST]], i64 -1
1575 // CHECK: %[[V8:.*]] = load i8*, i8** %[[ARRAYDESTROY_ELEMENT]], align 8
1576 // CHECK: call void @llvm.objc.release(i8* %[[V8]]) #2, !clang.imprecise_release !10
1578 // CHECK-NOT: call void @llvm.objc.release
1580 // CHECK: %[[V10:.*]] = load i8*, i8** %[[B_ADDR]], align 8
1581 // CHECK: call void @llvm.objc.release(i8* %[[V10]]) #2, !clang.imprecise_release !10
1582 // CHECK: %[[V11:.*]] = load i8*, i8** %[[A_ADDR]], align 8
1583 // CHECK: call void @llvm.objc.release(i8* %[[V11]]) #2, !clang.imprecise_release !10
1585 void test72(id a, id b) {
1586 __strong id t[] = (__strong id[]){a, b};
1589 // ARC-ALIEN: attributes [[NLB]] = { nonlazybind }
1590 // ARC-NATIVE: attributes [[NLB]] = { nonlazybind }
1591 // CHECK: attributes [[NUW]] = { nounwind }