forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray_specialize.sil
111 lines (85 loc) · 3.07 KB
/
array_specialize.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -array-specialize
sil_stage canonical
import Builtin
import Swift
struct ArrayIntBuffer {
var storage : Builtin.NativeObject
}
struct MyArray<T> {
var buffer : ArrayIntBuffer
}
enum MyBool{
case True
case False
}
class MyClass {
}
/// We need to split the loop exit edge from bb1 to bb3 before updating ssa form
/// after cloning.
sil @clone_switch_enum_exit : $@convention(thin) (@inout MyArray<MyClass>, @inout MyBool) -> MyBool {
bb0(%0 : $*MyArray<MyClass>, %1 : $*MyBool):
%3 = load %0 : $*MyArray<MyClass>
br bb1
bb1:
%2 = function_ref @arrayPropertyIsNative : $@convention(method) (@owned MyArray<MyClass>) -> Bool
%4 = load %1 : $*MyBool
retain_value %3 : $MyArray<MyClass>
%5 = apply %2(%3) : $@convention(method) (@owned MyArray<MyClass>) -> Bool
switch_enum %4 : $MyBool, case #MyBool.False!enumelt: bb3, case #MyBool.True!enumelt: bb2
bb2:
%6 = integer_literal $Builtin.Int1, -1
cond_br %6, bb1, bb4
bb3:
br bb4
bb4:
return %4 : $MyBool
}
protocol AProtocol : class {
}
sil @cant_handle_open_existential_use_outside_loop : $@convention(thin) (@inout MyArray<MyClass>, @inout MyBool, @owned AProtocol) -> MyBool {
bb0(%0 : $*MyArray<MyClass>, %1 : $*MyBool, %10 : $AProtocol):
%3 = load %0 : $*MyArray<MyClass>
br bb1
bb1:
%2 = function_ref @arrayPropertyIsNative : $@convention(method) (@owned MyArray<MyClass>) -> Bool
%4 = load %1 : $*MyBool
retain_value %3 : $MyArray<MyClass>
%5 = apply %2(%3) : $@convention(method) (@owned MyArray<MyClass>) -> Bool
%11 = open_existential_ref %10 : $AProtocol to $@opened("B538073C-2428-11E5-AC93-C82A1428F987") AProtocol
switch_enum %4 : $MyBool, case #MyBool.False!enumelt: bb3, case #MyBool.True!enumelt: bb2
bb2:
%6 = integer_literal $Builtin.Int1, -1
cond_br %6, bb1, bb4
bb3:
br bb4
bb4:
release_value %11 : $@opened("B538073C-2428-11E5-AC93-C82A1428F987") AProtocol
return %4 : $MyBool
}
sil public_external [_semantics "array.props.isNativeTypeChecked"] @arrayPropertyIsNative : $@convention(method) (@owned MyArray<MyClass>) -> Bool {
bb0(%0: $MyArray<MyClass>):
unreachable
}
// Make sure we can handle try_apply when splitting edges. This test used to crash.
sil @throwing_fun : $@convention(thin) () -> (MyBool, @error Error)
sil @clone_try_apply_exit : $@convention(thin) (@inout MyArray<MyClass>, @inout MyBool) -> (MyBool, @error Error) {
bb0(%0 : $*MyArray<MyClass>, %1 : $*MyBool):
%3 = load %0 : $*MyArray<MyClass>
br bb1
bb1:
%2 = function_ref @arrayPropertyIsNative : $@convention(method) (@owned MyArray<MyClass>) -> Bool
%4 = load %1 : $*MyBool
retain_value %3 : $MyArray<MyClass>
%5 = apply %2(%3) : $@convention(method) (@owned MyArray<MyClass>) -> Bool
%7 = function_ref @throwing_fun : $@convention(thin) () -> (MyBool, @error Error)
try_apply %7() : $@convention(thin) () -> (MyBool, @error Error), normal bb2, error bb5
bb2(%8 : $MyBool):
%6 = integer_literal $Builtin.Int1, -1
cond_br %6, bb1, bb4
bb3:
br bb4
bb4:
return %4 : $MyBool
bb5(%9 : $Error):
throw %9 : $Error
}