1; RUN: opt -objc-arc-contract -S < %s | FileCheck %s 2 3declare i8* @llvm.objc.autoreleaseReturnValue(i8*) 4declare i8* @foo1() 5 6; Check that ARC contraction replaces the function return with the value 7; returned by @llvm.objc.autoreleaseReturnValue. 8 9; CHECK-LABEL: define i32* @autoreleaseRVTailCall( 10; CHECK: %[[V0:[0-9]+]] = tail call i8* @llvm.objc.autoreleaseReturnValue( 11; CHECK: %[[V1:[0-9]+]] = bitcast i8* %[[V0]] to i32* 12; CHECK: ret i32* %[[V1]] 13 14define i32* @autoreleaseRVTailCall() { 15 %1 = call i8* @foo1() 16 %2 = bitcast i8* %1 to i32* 17 %3 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %1) 18 ret i32* %2 19} 20 21declare i32* @foo2(i32); 22 23; CHECK-LABEL: define i32* @autoreleaseRVTailCallPhi( 24; CHECK: %[[PHIVAL:.*]] = phi i8* [ %{{.*}}, %bb1 ], [ %{{.*}}, %bb2 ] 25; CHECK: %[[RETVAL:.*]] = phi i32* [ %{{.*}}, %bb1 ], [ %{{.*}}, %bb2 ] 26; CHECK: %[[V4:.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %[[PHIVAL]]) 27; CHECK: %[[V0:.*]] = bitcast i8* %[[V4]] to i32* 28; CHECK: ret i32* %[[V0]] 29 30define i32* @autoreleaseRVTailCallPhi(i1 %cond) { 31entry: 32 br i1 %cond, label %bb1, label %bb2 33bb1: 34 %v0 = call i32* @foo2(i32 1) 35 %v1 = bitcast i32* %v0 to i8* 36 br label %bb3 37bb2: 38 %v2 = call i32* @foo2(i32 2) 39 %v3 = bitcast i32* %v2 to i8* 40 br label %bb3 41bb3: 42 %phival = phi i8* [ %v1, %bb1 ], [ %v3, %bb2 ] 43 %retval = phi i32* [ %v0, %bb1 ], [ %v2, %bb2 ] 44 %v4 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %phival) 45 ret i32* %retval 46} 47