forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautorelease.sil
95 lines (80 loc) · 4.34 KB
/
autorelease.sil
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | %FileCheck -check-prefix CHECK -check-prefix CHECK-%target-ptrsize -check-prefix %target-cpu -DINT=i%target-ptrsize %s
// rdar://16565958
import Builtin
import Swift
class C {}
sil_vtable C {}
sil [ossa] @_TFC11autorelease1Cd : $@convention(method) (@owned C) -> @owned Builtin.NativeObject {
bb0(%0 : @owned $C):
%1 = unchecked_ref_cast %0 : $C to $Builtin.NativeObject // user: %2
return %1 : $Builtin.NativeObject // id: %2
}
sil [ossa] @foo : $@convention(thin) (@owned C?) -> @autoreleased C? {
bb0(%0 : @owned $C?):
return %0 : $C?
}
// CHECK: define{{( dllexport| protected)?}} swiftcc [[INT]] @foo([[INT]] %0) {{.*}} {
// CHECK: [[T0:%.*]] = inttoptr [[INT]] %0 to i8*
// CHECK-NEXT: [[T1:%.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* [[T0]])
// CHECK-NEXT: [[T2:%.*]] = ptrtoint i8* [[T1]] to [[INT]]
// CHECK-NEXT: ret [[INT]] [[T2]]
sil [ossa] @bar : $@convention(thin) (@owned C?) -> @owned C? {
bb0(%0 : @owned $C?):
%1 = function_ref @foo : $@convention(thin) (@owned C?) -> @autoreleased C?
%2 = apply %1(%0) : $@convention(thin) (@owned C?) -> @autoreleased C?
return %2 : $C?
}
// x86_64: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64 %0)
// x86_64: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
// x86_64-NEXT: [[T1:%.*]] = inttoptr i64 [[T0]] to i8*
// x86_64-NEXT: [[T2:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// x86_64-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
// x86_64-NEXT: ret i64 [[T3]]
// arm64: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64 %0)
// arm64: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
// arm64-NEXT: call void asm sideeffect "mov
// arm64-NEXT: [[T1:%.*]] = inttoptr i64 [[T0]] to i8*
// arm64-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// arm64-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
// arm64-NEXT: ret i64 [[T3]]
// arm64e: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64 %0)
// arm64e: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
// arm64e-NEXT: call void asm sideeffect "mov
// arm64e-NEXT: [[T1:%.*]] = inttoptr i64 [[T0]] to i8*
// arm64e-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// arm64e-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
// arm64e-NEXT: ret i64 [[T3]]
// aarch64: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64 %0)
// aarch64: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
// aarch64-NEXT: call void asm sideeffect "mov
// aarch64-NEXT: [[T1:%.*]] = inttoptr i64 [[T0]] to i8*
// aarch64-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// aarch64-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
// aarch64-NEXT: ret i64 [[T3]]
// i386: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32 %0)
// i386: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
// i386-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
// i386-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// i386-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
// i386-NEXT: ret i32 [[T3]]
// armv7: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32 %0)
// armv7: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
// armv7-NEXT: call void asm sideeffect "mov
// armv7-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
// armv7-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// armv7-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
// armv7-NEXT: ret i32 [[T3]]
// armv7s: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32 %0)
// armv7s: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
// armv7s-NEXT: call void asm sideeffect "mov
// armv7s-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
// armv7s-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// armv7s-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
// armv7s-NEXT: ret i32 [[T3]]
// armv7k: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32 %0)
// armv7k: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
// armv7k-NEXT: call void asm sideeffect "mov
// armv7k-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
// armv7k-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
// armv7k-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
// armv7k-NEXT: ret i32 [[T3]]