1 ; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
2 ; RUN: opt -passes=objc-arc-contract -S < %s | FileCheck %s
4 ; CHECK-LABEL: define void @test0() {
5 ; CHECK: %[[CALL:.*]] = notail call i8* @foo() [ "clang.arc.attachedcall"(i64 0) ]
6 ; CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL]])
9 %call1 = call i8* @foo() [ "clang.arc.attachedcall"(i64 0) ]
13 ; CHECK-LABEL: define void @test1() {
14 ; CHECK: %[[CALL:.*]] = notail call i8* @foo() [ "clang.arc.attachedcall"(i64 1) ]
15 ; CHECK: call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %[[CALL]])
17 define void @test1() {
18 %call1 = call i8* @foo() [ "clang.arc.attachedcall"(i64 1) ]
22 ; CHECK-LABEL:define i8* @test2(
23 ; CHECK: %[[CALL1:.*]] = invoke i8* @foo() [ "clang.arc.attachedcall"(i64 0) ]
25 ; CHECK: %[[V0:.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL1]])
28 ; CHECK: %[[CALL3:.*]] = invoke i8* @foo() [ "clang.arc.attachedcall"(i64 0) ]
30 ; CHECK: %[[V2:.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL3]])
33 ; CHECK: %[[RETVAL:.*]] = phi i8* [ %[[V0]], {{.*}} ], [ %[[V2]], {{.*}} ]
34 ; CHECK: ret i8* %[[RETVAL]]
36 define i8* @test2(i1 zeroext %b) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
38 br i1 %b, label %if.then, label %if.end
41 %call1 = invoke i8* @foo() [ "clang.arc.attachedcall"(i64 0) ]
42 to label %cleanup unwind label %lpad
45 %0 = landingpad { i8*, i32 }
47 resume { i8*, i32 } undef
50 %call3 = invoke i8* @foo() [ "clang.arc.attachedcall"(i64 0) ]
51 to label %cleanup unwind label %lpad
54 %retval.0 = phi i8* [ %call1, %if.then ], [ %call3, %if.end ]
58 ; CHECK-LABEL: define void @test3(
59 ; CHECK: call void @foo2() #[[ATTR1:.*]] [ "clang.arc.attachedcall"(i64 0) ]
60 ; CHECK-NEXT: ret void
62 define void @test3() {
63 call void @foo2() #0 [ "clang.arc.attachedcall"(i64 0) ]
69 declare i32 @__gxx_personality_v0(...)
71 !llvm.module.flags = !{!0}
73 ; CHECK: attributes #[[ATTR1]] = { noreturn }
74 attributes #0 = { noreturn }
76 !0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09fp, fp\09\09// marker for objc_retainAutoreleaseReturnValue"}