1 ; RUN: opt -passes=objc-arc -S < %s | FileCheck %s
3 ; Generated by compiling:
5 ; id baz(ptr X) { return (__bridge_transfer id)X; }
10 ; Y = (__bridge_retained ptr)X;
14 ; clang -x objective-c -mllvm -enable-objc-arc-opts=0 -fobjc-arc -S -emit-llvm test.m
16 ; And then hand-reduced further.
18 declare ptr @llvm.objc.autoreleaseReturnValue(ptr)
19 declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr)
20 declare ptr @llvm.objc.retain(ptr)
21 declare void @llvm.objc.release(ptr)
23 define void @foo(ptr %X) {
25 %0 = tail call ptr @llvm.objc.retain(ptr %X)
26 %tobool = icmp eq ptr %0, null
27 br i1 %tobool, label %if.end, label %if.then
29 if.then: ; preds = %entry
30 %1 = tail call ptr @llvm.objc.retain(ptr nonnull %0)
33 if.end: ; preds = %if.then, %entry
34 %Y.0 = phi ptr [ %1, %if.then ], [ null, %entry ]
35 %2 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %Y.0)
36 %3 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %2)
37 tail call void @llvm.objc.release(ptr %0)
42 ; CHECK: tail call ptr @llvm.objc.retain
44 ; CHECK-NEXT: tail call void @llvm.objc.release
45 ; CHECK-NEXT: tail call void @llvm.objc.release