1 ; RUN: opt -S -objc-arc < %s | FileCheck %s
6 declare i8* @llvm.objc.retain(i8*)
8 declare void @llvm.objc.release(i8*)
10 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
12 ; Don't delete the autorelease.
14 ; CHECK-LABEL: define %0* @test0(
15 ; CHECK: @llvm.objc.retain
17 ; CHECK-NOT: @llvm.objc.r
18 ; CHECK: @llvm.objc.autoreleaseReturnValue
19 ; CHECK-NOT: @llvm.objc.
21 define %0* @test0(%0* %buffer) nounwind {
22 %1 = bitcast %0* %buffer to i8*
23 %2 = tail call i8* @llvm.objc.retain(i8* %1) nounwind
24 br i1 undef, label %.lr.ph, label %._crit_edge
26 .lr.ph: ; preds = %.lr.ph, %0
27 br i1 false, label %.lr.ph, label %._crit_edge
29 ._crit_edge: ; preds = %.lr.ph, %0
30 %3 = tail call i8* @llvm.objc.retain(i8* %1) nounwind
31 tail call void @llvm.objc.release(i8* %1) nounwind, !clang.imprecise_release !0
32 %4 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %1) nounwind
36 ; Do delete the autorelease, even with the retain in a different block.
38 ; CHECK-LABEL: define %0* @test1(
41 define %0* @test1() nounwind {
42 %buffer = call %0* @foo()
43 %1 = bitcast %0* %buffer to i8*
44 %2 = tail call i8* @llvm.objc.retain(i8* %1) nounwind
45 br i1 undef, label %.lr.ph, label %._crit_edge
47 .lr.ph: ; preds = %.lr.ph, %0
48 br i1 false, label %.lr.ph, label %._crit_edge
50 ._crit_edge: ; preds = %.lr.ph, %0
51 %3 = tail call i8* @llvm.objc.retain(i8* %1) nounwind
52 tail call void @llvm.objc.release(i8* %1) nounwind, !clang.imprecise_release !0
53 %4 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %1) nounwind