1 ; RUN: opt -S -passes=objc-arc-contract < %s | FileCheck %s
3 ; CHECK-LABEL: define void @foo() {
4 ; CHECK: %call = tail call ptr @qux()
5 ; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for return value optimization", ""()
6 ; CHECK-NEXT: %0 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call) [[NUW:#[0-9]+]]
11 %call = tail call ptr @qux()
12 %0 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call) nounwind
13 tail call void @bar(ptr %0)
17 ; CHECK-LABEL: define void @foo2() {
18 ; CHECK: %call = tail call ptr @qux()
19 ; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for return value optimization", ""()
20 ; CHECK-NEXT: %0 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %call) [[NUW:#[0-9]+]]
25 %call = tail call ptr @qux()
26 %0 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %call) nounwind
27 tail call void @bar(ptr %0)
31 ; CHECK-LABEL: define ptr @foo3(
32 ; CHECK: call ptr @returnsArg(
33 ; CHECK-NEXT: call void asm sideeffect
35 define ptr @foo3(ptr %a) {
36 %call = call ptr @returnsArg(ptr %a)
37 call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call)
41 ; CHECK-LABEL: define ptr @foo4(
42 ; CHECK: call ptr @returnsArg(
43 ; CHECK-NEXT: call void asm sideeffect
45 define ptr @foo4(ptr %a) {
46 %call = call ptr @returnsArg(ptr %a)
47 call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %a)
52 declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr)
53 declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr)
54 declare void @bar(ptr)
55 declare ptr @returnsArg(ptr returned)
57 !llvm.module.flags = !{!0}
59 !0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09r7, r7\09\09@ marker for return value optimization"}
61 ; CHECK: attributes [[NUW]] = { nounwind }