@@ -41,12 +41,17 @@ struct Holder {
4141@_addressableForDependencies
4242struct AddressableForDeps {}
4343
44+ protocol PAny : ~Copyable, ~Escapable {}
45+
4446sil @getPtr : $@convention(thin) () -> @out UnsafeRawPointer
4547sil @getSpan : $@convention(thin) (@in_guaranteed AnyObject) -> @lifetime(borrow 0) @out NE
4648sil @getInoutSpan : $@convention(thin) (@inout AnyObject) -> @lifetime(borrow 0) @out NCE
4749
4850sil @useNE : $@convention(thin) (@guaranteed NE) -> ()
4951
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+
5055// Check that the inserted dependence is on the 'self' argument, not the temporary borrow.
5156//
5257// CHECK-LABEL: sil [available 9999] [ossa] @testSpanProp : $@convention(method) (@guaranteed AnyObject) -> @lifetime(borrow 0) @owned NE {
@@ -172,3 +177,31 @@ bb0(%0 : @guaranteed $Holder):
172177 %99 = tuple ()
173178 return %99 : $()
174179}
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