@@ -80,6 +80,9 @@ sil @useRawSpan : $@convention(thin) (@guaranteed RawSpan) -> ()
8080sil @initHolder : $@convention(method) (@thin Holder.Type) -> @owned Holder
8181sil @readAccess : $@yield_once @convention(method) (@guaranteed Holder) -> @lifetime(borrow 0) @yields @guaranteed NE
8282
83+ sil @yieldInoutHolder : $@yield_once @convention(method) (@inout Holder) -> @yields @inout Holder
84+ sil @yieldInoutNE : $@yield_once @convention(method) (@inout Holder) -> @lifetime(borrow 0) @owned NE
85+
8386// NCContainer.wrapper._read:
8487// var wrapper: Wrapper {
8588// _read {
@@ -442,6 +445,53 @@ bb0(%0 : @owned $B):
442445 return %24
443446}
444447
448+ // =============================================================================
449+ // Coroutine extension
450+ // =============================================================================
451+
452+ // Sink the inner end_apply and the outer end_access.
453+ //
454+ // CHECK-LABEL: sil hidden [ossa] @testCoroutineInsideAccess : $@convention(thin) (@inout Holder) -> () {
455+ // CHECK: bb0(%0 : $*Holder):
456+ // CHECK: [[BORROW:%[0-9]+]] = begin_borrow [lexical] [var_decl]
457+ // CHECK: [[ACCESS:%[0-9]+]] = begin_access [modify] [unknown] %0
458+ // CHECK: ({{.*}}, [[TOKEN:%[0-9]+]]) = begin_apply %{{.*}}([[ACCESS]]) : $@yield_once @convention(method) (@inout Holder) -> @yields @inout Holder
459+ // CHECK: apply
460+ // CHECK: [[MD:%[0-9]+]] = mark_dependence [unresolved] %10 on %7
461+ // CHECK: apply
462+ // CHECK: end_borrow
463+ // CHECK: end_access
464+ // CHECK: end_apply [[TOKEN]] as $()
465+ // CHECK: end_access [[ACCESS]]
466+ // CHECK: end_borrow [[BORROW]]
467+ // CHECK-LABEL: } // end sil function 'testCoroutineInsideAccess'
468+ sil hidden [ossa] @testCoroutineInsideAccess : $@convention(thin) (@inout Holder) -> () {// %0 "w"
469+ bb0(%0 : $*Holder):
470+ debug_value %0, var, name "w", argno 1, expr op_deref
471+ %2 = alloc_box ${ var NE }, var, name "span"
472+ %3 = begin_borrow [lexical] [var_decl] %2
473+ %4 = project_box %3, 0
474+ %5 = begin_access [modify] [unknown] %0
475+ %6 = function_ref @yieldInoutHolder : $@yield_once @convention(method) (@inout Holder) -> @yields @inout Holder
476+ (%7, %8) = begin_apply %6(%5) : $@yield_once @convention(method) (@inout Holder) -> @yields @inout Holder
477+ %9 = function_ref @getOwnedNEFromInout : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
478+ %10 = apply %9(%7) : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
479+ %11 = mark_dependence [unresolved] %10 on %7
480+ %12 = end_apply %8 as $()
481+ end_access %5
482+ store %11 to [init] %4
483+ %15 = begin_access [read] [unknown] %4
484+ %16 = load_borrow [unchecked] %15
485+ %17 = function_ref @useNE : $@convention(thin) (@guaranteed NE) -> ()
486+ %18 = apply %17(%16) : $@convention(thin) (@guaranteed NE) -> ()
487+ end_borrow %16
488+ end_access %15
489+ end_borrow %3
490+ destroy_value %2
491+ %99 = tuple ()
492+ return %99
493+ }
494+
445495// =============================================================================
446496// Return value extension
447497// =============================================================================
0 commit comments