1 ; RUN: opt -passes=objc-arc-contract -S < %s | FileCheck %s
3 declare ptr @llvm.objc.autoreleaseReturnValue(ptr)
6 ; Check that ARC contraction replaces the function return with the value
7 ; returned by @llvm.objc.autoreleaseReturnValue.
9 ; CHECK-LABEL: define ptr @autoreleaseRVTailCall(
10 ; CHECK: %[[V0:[0-9]+]] = tail call ptr @llvm.objc.autoreleaseReturnValue(
11 ; CHECK: ret ptr %[[V0]]
13 define ptr @autoreleaseRVTailCall() {
15 %2 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %1)
19 declare ptr @foo2(i32);
21 ; CHECK-LABEL: define ptr @autoreleaseRVTailCallPhi(
22 ; CHECK: %[[PHIVAL:.*]] = phi ptr [ %{{.*}}, %bb1 ], [ %{{.*}}, %bb2 ]
23 ; CHECK: %[[RETVAL:.*]] = phi ptr [ %{{.*}}, %bb1 ], [ %{{.*}}, %bb2 ]
24 ; CHECK: %[[V4:.*]] = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %[[PHIVAL]])
25 ; CHECK: ret ptr %[[V4]]
27 define ptr @autoreleaseRVTailCallPhi(i1 %cond) {
29 br i1 %cond, label %bb1, label %bb2
31 %v0 = call ptr @foo2(i32 1)
34 %v2 = call ptr @foo2(i32 2)
37 %phival = phi ptr [ %v0, %bb1 ], [ %v2, %bb2 ]
38 %retval = phi ptr [ %v0, %bb1 ], [ %v2, %bb2 ]
39 %v4 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %phival)