@@ -41,12 +41,17 @@ struct Holder {
41
41
@_addressableForDependencies
42
42
struct AddressableForDeps {}
43
43
44
+ protocol PAny : ~Copyable, ~Escapable {}
45
+
44
46
sil @getPtr : $@convention(thin) () -> @out UnsafeRawPointer
45
47
sil @getSpan : $@convention(thin) (@in_guaranteed AnyObject) -> @lifetime(borrow 0) @out NE
46
48
sil @getInoutSpan : $@convention(thin) (@inout AnyObject) -> @lifetime(borrow 0) @out NCE
47
49
48
50
sil @useNE : $@convention(thin) (@guaranteed NE) -> ()
49
51
52
+ sil @getExistential : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @out any PAny & ~Copyable & ~Escapable
53
+ sil @useExistential : $@convention(thin) (@in_guaranteed any PAny & ~Copyable & ~Escapable) -> ()
54
+
50
55
// Check that the inserted dependence is on the 'self' argument, not the temporary borrow.
51
56
//
52
57
// CHECK-LABEL: sil [available 9999] [ossa] @testSpanProp : $@convention(method) (@guaranteed AnyObject) -> @lifetime(borrow 0) @owned NE {
@@ -172,3 +177,31 @@ bb0(%0 : @guaranteed $Holder):
172
177
%99 = tuple ()
173
178
return %99 : $()
174
179
}
180
+
181
+ // Test that source of a dependency may be a project_box and the mark_dependence will be inserted.
182
+ //
183
+ // CHECK-LABEL: sil hidden [ossa] @testBoxDependenceSource : $@convention(thin) (@inout Holder) -> () {
184
+ // CHECK: [[BOX:%[0-9]+]] = project_box %2, 0
185
+ // CHECK: [[ARG:%[0-9]+]] = begin_access [modify] [unknown] %0
186
+ // CHECK: apply %{{.*}}([[BOX]], [[ARG]]) : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @out any PAny & ~Copyable & ~Escapable
187
+ // CHECK: mark_dependence_addr [unresolved] [[BOX]] on [[ARG]]
188
+ // CHECK-LABEL: } // end sil function 'testBoxDependenceSource'
189
+ sil hidden [ossa] @testBoxDependenceSource : $@convention(thin) (@inout Holder) -> () {
190
+ bb0(%0 : $*Holder):
191
+ %1 = alloc_box ${ let any PAny & ~Copyable & ~Escapable }, let, name "span"
192
+ %2 = begin_borrow [lexical] [var_decl] %1
193
+ %3 = project_box %2, 0
194
+ %4 = begin_access [modify] [unknown] %0
195
+
196
+ %5 = function_ref @getExistential : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @out any PAny & ~Copyable & ~Escapable
197
+ %6 = apply %5(%3, %4) : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @out any PAny & ~Copyable & ~Escapable
198
+ end_access %4
199
+ %8 = mark_unresolved_non_copyable_value [no_consume_or_assign] %3
200
+
201
+ %9 = function_ref @useExistential : $@convention(thin) (@in_guaranteed any PAny & ~Copyable & ~Escapable) -> ()
202
+ %10 = apply %9(%8) : $@convention(thin) (@in_guaranteed any PAny & ~Copyable & ~Escapable) -> ()
203
+ end_borrow %2
204
+ destroy_value %1
205
+ %13 = tuple ()
206
+ return %13
207
+ }
0 commit comments