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