1 ; RUN: opt -passes=objc-arc-contract -S < %s | FileCheck %s
3 ; CHECK-LABEL: define void @test0() {
4 ; CHECK: %[[CALL:.*]] = notail call ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
5 ; CHECK-NOT: call ptr @llvm.objc.retainAutoreleasedReturnValue(
8 %call1 = call ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
12 ; CHECK-LABEL: define void @test1() {
13 ; CHECK: %[[CALL:.*]] = notail call ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue) ]
14 ; CHECK-NOT: call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(
16 define void @test1() {
17 %call1 = call ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue) ]
21 ; CHECK-LABEL:define ptr @test2(
22 ; CHECK: %[[V0:.*]] = invoke ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
24 ; CHECK-NOT: = call ptr @llvm.objc.retainAutoreleasedReturnValue(
27 ; CHECK: %[[V2:.*]] = invoke ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
29 ; CHECK-NOT: = call ptr @llvm.objc.retainAutoreleasedReturnValue(
32 ; CHECK: %[[RETVAL:.*]] = phi ptr [ %[[V0]], {{.*}} ], [ %[[V2]], {{.*}} ]
33 ; CHECK: ret ptr %[[RETVAL]]
35 define ptr @test2(i1 zeroext %b) personality ptr @__gxx_personality_v0 {
37 br i1 %b, label %if.then, label %if.end
40 %call1 = invoke ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
41 to label %cleanup unwind label %lpad
44 %0 = landingpad { ptr, i32 }
46 resume { ptr, i32 } undef
49 %call3 = invoke ptr @foo() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
50 to label %cleanup unwind label %lpad
53 %retval.0 = phi ptr [ %call1, %if.then ], [ %call3, %if.end ]
57 ; "clang.arc.attachedcall" is ignored if the return type of the called function is void.
58 ; CHECK-LABEL: define void @test3(
59 ; CHECK: call void @foo2() #[[ATTR1:.*]] [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
60 ; CHECK-NEXT: ret void
62 define void @test3() {
63 call void @foo2() #0 [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
69 declare i32 @__gxx_personality_v0(...)
70 declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr)
71 declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr)
73 !llvm.module.flags = !{!0}
75 ; CHECK: attributes #[[ATTR1]] = { noreturn }
76 attributes #0 = { noreturn }
78 !0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09fp, fp\09\09// marker for objc_retainAutoreleaseReturnValue"}