xref: /llvm-project/llvm/test/Transforms/ObjCARC/contract-marker.ll (revision 01e4f41b43b57dee751146fde9992c660bd7c714)
1; RUN: opt -S -passes=objc-arc-contract < %s | FileCheck %s
2
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]+]]
7; CHECK: }
8
9define void @foo() {
10entry:
11  %call = tail call ptr @qux()
12  %0 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call) nounwind
13  tail call void @bar(ptr %0)
14  ret void
15}
16
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]+]]
21; CHECK: }
22
23define void @foo2() {
24entry:
25  %call = tail call ptr @qux()
26  %0 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %call) nounwind
27  tail call void @bar(ptr %0)
28  ret void
29}
30
31; CHECK-LABEL: define ptr @foo3(
32; CHECK: call ptr @returnsArg(
33; CHECK-NEXT: call void asm sideeffect
34
35define ptr @foo3(ptr %a) {
36  %call = call ptr @returnsArg(ptr %a)
37  call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %call)
38  ret ptr %call
39}
40
41; CHECK-LABEL: define ptr @foo4(
42; CHECK: call ptr @returnsArg(
43; CHECK-NEXT: call void asm sideeffect
44
45define ptr @foo4(ptr %a) {
46  %call = call ptr @returnsArg(ptr %a)
47  call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %a)
48  ret ptr %call
49}
50
51declare ptr @qux()
52declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr)
53declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr)
54declare void @bar(ptr)
55declare ptr @returnsArg(ptr returned)
56
57!llvm.module.flags = !{!0}
58
59!0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09r7, r7\09\09@ marker for return value optimization"}
60
61; CHECK: attributes [[NUW]] = { nounwind }
62