1 ; RUN: opt -objc-arc -S < %s | FileCheck %s 2 3 ; Generated by compiling: 4 ; 5 ; id baz(void *X) { return (__bridge_transfer id)X; } 6 ; 7 ; void foo(id X) { 8 ; void *Y = 0; 9 ; if (X) 10 ; Y = (__bridge_retained void *)X; 11 ; baz(Y); 12 ; } 13 ; 14 ; clang -x objective-c -mllvm -enable-objc-arc-opts=0 -fobjc-arc -S -emit-llvm test.m 15 ; 16 ; And then hand-reduced further. 17 18 declare i8* @objc_autoreleaseReturnValue(i8*) 19 declare i8* @objc_unsafeClaimAutoreleasedReturnValue(i8*) 20 declare i8* @objc_retain(i8*) 21 declare void @objc_release(i8*) 22 23 define void @foo(i8* %X) { 24 entry: 25 %0 = tail call i8* @objc_retain(i8* %X) 26 %tobool = icmp eq i8* %0, null 27 br i1 %tobool, label %if.end, label %if.then 28 29 if.then: ; preds = %entry 30 %1 = tail call i8* @objc_retain(i8* nonnull %0) 31 br label %if.end 32 33 if.end: ; preds = %if.then, %entry 34 %Y.0 = phi i8* [ %1, %if.then ], [ null, %entry ] 35 %2 = tail call i8* @objc_autoreleaseReturnValue(i8* %Y.0) 36 %3 = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %2) 37 tail call void @objc_release(i8* %0) 38 ret void 39 } 40 41 ; CHECK: if.then 42 ; CHECK: tail call i8* @objc_retain 43 ; CHECK-NEXT: call i8* @objc_autorelease 44 ; CHECK: %Y.0 = phi 45 ; CHECK-NEXT: tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %Y.0) 46 ; CHECK-NEXT: tail call void @objc_release 47 48