File: sil_combine_apply_unit.sil

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (178 lines) | stat: -rw-r--r-- 9,048 bytes parent folder | download
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// RUN: %target-sil-opt \
// RUN:     -test-runner %s \
// RUN:     -module-name Swift \
// RUN:     -enable-sil-verify-all \
// RUN: | %FileCheck %s

import Builtin

enum Optional<T> {
  case some(T)
  case none
}

protocol Error {}

class C {}

struct Input {}
struct Output {}
enum Nunca {}

sil @borrowMaybeC : $@convention(thin) (@guaranteed Optional<C>) -> ()
sil @borrowMaybeC2 : $@convention(thin) (@guaranteed Optional<C>, @guaranteed Optional<C>) -> ()
sil @borrowMaybeCThrowing : $@convention(thin) (@guaranteed Optional<C>) -> (@error Error)
sil @borrowMaybeC2Throwing : $@convention(thin) (@guaranteed Optional<C>, @guaranteed Optional<C>) -> (@error Error)
sil @rdar127452206_callee : $@convention(thin) @Sendable @substituted <τ_0_0, τ_0_1, τ_0_2> (@in_guaranteed τ_0_0) -> (@out τ_0_2, @error_indirect τ_0_1) for <Input, Nunca, Output>

// CHECK-LABEL: sil @rdar127452206 : {{.*}} {
// CHECK:       bb0([[INPUT:%[^,]+]] :
// CHECK:         [[OUTPUT:%[^,]+]] = alloc_stack $Output
// CHECK:         [[NUNCA:%[^,]+]] = alloc_stack $Nunca
// CHECK:         [[OUTPUT_AS_OUTPUT:%[^,]+]] = unchecked_addr_cast [[OUTPUT]]
// CHECK:         [[NUNCA_AS_NUNCA:%[^,]+]] = unchecked_addr_cast [[NUNCA]]
// CHECK:         [[INPUT_AS_INPUT:%[^,]+]] = unchecked_addr_cast [[INPUT]]
// CHECK:         apply [nothrow] {{%[^,]+}}([[OUTPUT_AS_OUTPUT]], [[NUNCA_AS_NUNCA]], [[INPUT_AS_INPUT]])
// CHECK-LABEL: } // end sil function 'rdar127452206'
sil @rdar127452206 : $@convention(thin) (@in Input) -> () {
entry(%input : $*Input):
  %output = alloc_stack $Output
  %nunca = alloc_stack $Nunca
  %callee = function_ref @rdar127452206_callee : $@convention(thin) @Sendable @substituted <τ_0_0, τ_0_1, τ_0_2> (@in_guaranteed τ_0_0) -> (@out τ_0_2, @error_indirect τ_0_1) for <Input, Nunca, Output>
  %convert = convert_function %callee : $@convention(thin) @Sendable @substituted <τ_0_0, τ_0_1, τ_0_2> (@in_guaranteed τ_0_0) -> (@out τ_0_2, @error_indirect τ_0_1) for <Input, Nunca, Output> to $@convention(thin) @substituted <τ_0_0, τ_0_1, τ_0_2> (@in_guaranteed τ_0_0) -> (@out τ_0_2, @error_indirect τ_0_1) for <Input, Nunca, Output> // user: %216
  specify_test "sil_combine_visit_instruction @instruction[4]"
  apply [nothrow] %convert(%output, %nunca, %input) : $@convention(thin) @substituted <τ_0_0, τ_0_1, τ_0_2> (@in_guaranteed τ_0_0) -> (@out τ_0_2, @error_indirect τ_0_1) for <Input, Nunca, Output>
  dealloc_stack %nunca : $*Nunca
  dealloc_stack %output : $*Output
  %retval = tuple ()
  return %retval : $()
}

// CHECK-LABEL: sil [ossa] @convert_function__to_optional__owned_as_guaranteed__1 : {{.*}} {
// CHECK:       bb0([[C:%[^,]+]] :
// CHECK:         [[BORROW_MAYBE_C:%[^,]+]] = function_ref @borrowMaybeC
// CHECK:         [[B:%[^,]+]] = begin_borrow [[C]]
// CHECK:         [[MAYBE_B:%[^,]+]] = unchecked_ref_cast [[B]] : $C to $Optional<C>
// CHECK:         apply [[BORROW_MAYBE_C]]([[MAYBE_B]])
// CHECK:         end_borrow [[B]]
// CHECK:         destroy_value [[C]]
// CHECK-LABEL: } // end sil function 'convert_function__to_optional__owned_as_guaranteed__1'
sil [ossa] @convert_function__to_optional__owned_as_guaranteed__1 : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  %borrowMaybeC = function_ref @borrowMaybeC : $@convention(thin) (@guaranteed Optional<C>) -> ()
  %borrowC = convert_function %borrowMaybeC : $@convention(thin) (@guaranteed Optional<C>) -> () to $@convention(thin) (@guaranteed C) -> ()
  %void = apply %borrowC(%c) : $@convention(thin) (@guaranteed C) -> ()
  specify_test "sil_combine_visit_instruction %void"
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}

// CHECK-LABEL: sil [ossa] @convert_function__to_optional__owned_as_guaranteed__2 : {{.*}} {
// CHECK:       bb0(
// CHECK-SAME:      [[C:%[^,]+]] :
// CHECK-SAME:      [[C2:%[^,]+]] :
// CHECK-SAME:  ):
// CHECK:       [[BORROW_MAYBE_C2:%[^,]+]] = function_ref @borrowMaybeC2
// CHECK:       [[B:%[^,]+]] = begin_borrow [[C]]
// CHECK:       [[MAYBE_B:%[^,]+]] = unchecked_ref_cast [[B]] : $C to $Optional<C>
// CHECK:       [[B2:%[^,]+]] = begin_borrow [[C2]]
// CHECK:       [[MAYBE_B2:%[^,]+]] = unchecked_ref_cast [[B2]] : $C to $Optional<C>
// CHECK:       apply [[BORROW_MAYBE_C2]]([[MAYBE_B]], [[MAYBE_B2]])
// CHECK:       end_borrow [[B]]
// CHECK:       end_borrow [[B2]]
// CHECK:       destroy_value [[C]]
// CHECK:       destroy_value [[C2]]
// CHECK-LABEL: } // end sil function 'convert_function__to_optional__owned_as_guaranteed__2'
sil [ossa] @convert_function__to_optional__owned_as_guaranteed__2 : $@convention(thin) (@owned C, @owned C) -> () {
entry(%c : @owned $C, %c2 : @owned $C):
  %borrowMaybeC2 = function_ref @borrowMaybeC2 : $@convention(thin) (@guaranteed Optional<C>, @guaranteed Optional<C>) -> ()
  %borrowC2 = convert_function %borrowMaybeC2 : $@convention(thin) (@guaranteed Optional<C>, @guaranteed Optional<C>) -> () to $@convention(thin) (@guaranteed C, @guaranteed C) -> ()
  %void = apply %borrowC2(%c, %c2) : $@convention(thin) (@guaranteed C, @guaranteed C) -> ()
  specify_test "sil_combine_visit_instruction %void"
  destroy_value %c : $C
  destroy_value %c2 : $C
  %retval = tuple ()
  return %retval : $()
}

// CHECK-LABEL: sil [ossa] @convert_function__to_optional__owned_as_guaranteed__3 : {{.*}} {
// CHECK:       bb0([[C:%[^,]+]] :
// CHECK:         [[BORROW_MAYBE_C:%[^,]+]] = function_ref @borrowMaybeCThrowing
// CHECK:         [[B:%[^,]+]] = begin_borrow [[C]]
// CHECK:         [[MAYBE_B:%[^,]+]] = unchecked_ref_cast [[B]] : $C to $Optional<C>
// CHECK:         try_apply [[BORROW_MAYBE_C]]([[MAYBE_B]])
// CHECK:             normal [[SUCCESS:bb[0-9]+]]
// CHECK:             error [[FAILURE:bb[0-9]+]]
// CHECK:       [[SUCCESS]]
// CHECK:         end_borrow [[B]]
// CHECK:         destroy_value [[C]]
// CHECK:       [[FAILURE]]([[ERROR:%[^,]+]] :
// CHECK:         end_borrow [[B]]
// CHECK:         destroy_value [[C]]
// CHECK:         throw [[ERROR]]
// CHECK-LABEL: } // end sil function 'convert_function__to_optional__owned_as_guaranteed__3'
sil [ossa] @convert_function__to_optional__owned_as_guaranteed__3 : $@convention(thin) (@owned C) -> (@error Error) {
entry(%c : @owned $C):
  %borrowMaybeC = function_ref @borrowMaybeCThrowing : $@convention(thin) (@guaranteed Optional<C>) -> (@error Error)
  %borrowC = convert_function %borrowMaybeC : $@convention(thin) (@guaranteed Optional<C>) -> (@error Error) to $@convention(thin) (@guaranteed C) -> (@error Error)
  specify_test "sil_combine_visit_instruction @instruction"
  try_apply %borrowC(%c) : $@convention(thin) (@guaranteed C) -> (@error Error),
    normal success,
    error failure

success(%void : $()):
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()

failure(%error : @owned $Error):
  destroy_value %c : $C
  throw %error : $Error
}

// CHECK-LABEL: sil [ossa] @convert_function__to_optional__owned_as_guaranteed__4 : {{.*}} {
// CHECK:       bb0(
// CHECK-SAME:      [[C:%[^,]+]] :
// CHECK-SAME:      [[C2:%[^,]+]] :
// CHECK-SAME:  ):
// CHECK:         [[BORROW_MAYBE_C2:%[^,]+]] = function_ref @borrowMaybeC2Throwing
// CHECK:         [[B:%[^,]+]] = begin_borrow [[C]]
// CHECK:         [[MAYBE_B:%[^,]+]] = unchecked_ref_cast [[B]] : $C to $Optional<C>
// CHECK:         [[B2:%[^,]+]] = begin_borrow [[C2]]
// CHECK:         [[MAYBE_B2:%[^,]+]] = unchecked_ref_cast [[B2]] : $C to $Optional<C>
// CHECK:         try_apply [[BORROW_MAYBE_C2]]([[MAYBE_B]], [[MAYBE_B2]])
// CHECK:             normal [[SUCCESS:bb[0-9]+]]
// CHECK:             error [[FAILURE:bb[0-9]+]]
// CHECK:       [[SUCCESS]]
// CHECK:         end_borrow [[B]]
// CHECK:         end_borrow [[B2]]
// CHECK:         destroy_value [[C]]
// CHECK:         destroy_value [[C2]]
// CHECK:       [[FAILURE]]([[ERROR:%[^,]+]] :
// CHECK:         end_borrow [[B]]
// CHECK:         end_borrow [[B2]]
// CHECK:         destroy_value [[C]]
// CHECK:         destroy_value [[C2]]
// CHECK:         throw [[ERROR]]
// CHECK-LABEL: } // end sil function 'convert_function__to_optional__owned_as_guaranteed__4'
sil [ossa] @convert_function__to_optional__owned_as_guaranteed__4 : $@convention(thin) (@owned C, @owned C) -> (@error Error) {
entry(%c : @owned $C, %c2 : @owned $C):
  %borrowMaybeC2 = function_ref @borrowMaybeC2Throwing : $@convention(thin) (@guaranteed Optional<C>, @guaranteed Optional<C>) -> (@error Error)
  %borrowC2 = convert_function %borrowMaybeC2 : $@convention(thin) (@guaranteed Optional<C>, @guaranteed Optional<C>) -> (@error Error) to $@convention(thin) (@guaranteed C, @guaranteed C) -> (@error Error)
  specify_test "sil_combine_visit_instruction @instruction"
  try_apply %borrowC2(%c, %c2) : $@convention(thin) (@guaranteed C, @guaranteed C) -> (@error Error),
    normal success,
    error failure

success(%void : $()):
  destroy_value %c : $C
  destroy_value %c2 : $C
  %retval = tuple ()
  return %retval : $()

failure(%error : @owned $Error):
  destroy_value %c : $C
  destroy_value %c2 : $C
  throw %error : $Error
}