1 ; RUN: opt -S -objc-arc < %s | FileCheck %s
3 declare void @use_pointer(i8*)
4 declare i8* @returner()
5 declare i8* @llvm.objc.retain(i8*)
6 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
7 declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
9 ; Clean up residue left behind after inlining.
11 ; CHECK-LABEL: define void @test0(
13 ; CHECK-NEXT: ret void
15 define void @test0(i8* %call.i) {
17 %0 = tail call i8* @llvm.objc.retain(i8* %call.i) nounwind
18 %1 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %0) nounwind
22 ; Same as test0, but with slightly different use arrangements.
24 ; CHECK-LABEL: define void @test1(
26 ; CHECK-NEXT: ret void
28 define void @test1(i8* %call.i) {
30 %0 = tail call i8* @llvm.objc.retain(i8* %call.i) nounwind
31 %1 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call.i) nounwind
35 ; Delete a retainRV+autoreleaseRV even if the pointer is used.
37 ; CHECK-LABEL: define void @test24(
39 ; CHECK-NEXT: call void @use_pointer(i8* %p)
40 ; CHECK-NEXT: ret void
42 define void @test24(i8* %p) {
44 call i8* @llvm.objc.autoreleaseReturnValue(i8* %p) nounwind
45 call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %p) nounwind
46 call void @use_pointer(i8* %p)