File tree Expand file tree Collapse file tree 2 files changed +31
-7
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -1022,12 +1022,14 @@ extension LifetimeDependenceDefUseWalker {
10221022 assert ( !mdi. isUnresolved && !mdi. isNonEscaping,
10231023 " should be handled as a dependence by AddressUseVisitor " )
10241024 }
1025- if operand. instruction is ReturnInst , !operand. value. isEscapable {
1026- return returnedDependence ( result: operand)
1027- }
1028- if operand. instruction is YieldInst , !operand. value. isEscapable {
1029- return yieldedDependence ( result: operand)
1025+ if operand. instruction is YieldInst {
1026+ if operand. value. isEscapable {
1027+ return leafUse ( of: operand)
1028+ } else {
1029+ return yieldedDependence ( result: operand)
1030+ }
10301031 }
1032+ // Escaping an address
10311033 return escapingDependence ( on: operand)
10321034 }
10331035
Original file line number Diff line number Diff line change @@ -23,7 +23,29 @@ func bv_copy(_ bv: borrowing BV) -> dependsOn(bv) BV {
2323}
2424
2525struct NCInt : ~ Copyable {
26- var value : Int
26+ var i : Int
27+ }
28+
29+ public struct NEInt : ~ Escapable {
30+ var i : Int
31+
32+ // Test yielding an address.
33+ // CHECK-LABEL: sil hidden @$s4test5NEIntV5ipropSivM : $@yield_once @convention(method) (@inout NEInt) -> @yields @inout Int {
34+ // CHECK: bb0(%0 : $*NEInt):
35+ // CHECK: [[A:%.*]] = begin_access [modify] [static] %0 : $*NEInt
36+ // CHECK: [[E:%.*]] = struct_element_addr [[A]] : $*NEInt, #NEInt.i
37+ // CHECK: yield [[E]] : $*Int, resume bb1, unwind bb2
38+ // CHECK: end_access [[A]] : $*NEInt
39+ // CHECK: end_access [[A]] : $*NEInt
40+ // CHECK-LABEL: } // end sil function '$s4test5NEIntV5ipropSivM'
41+ var iprop : Int {
42+ _read { yield i }
43+ _modify { yield & i }
44+ }
45+
46+ init ( owner: borrowing NCInt ) -> dependsOn( owner) Self {
47+ self . i = owner. i
48+ }
2749}
2850
2951func takeClosure( _: ( ) -> ( ) ) { }
@@ -56,5 +78,5 @@ func bv_borrow_borrow(bv: borrowing BV) -> dependsOn(scoped bv) BV {
5678// because lifetime dependence does not expect a dependence directly on an 'inout' address without any 'begin_access'
5779// marker.
5880func ncint_capture( ncInt: inout NCInt ) {
59- takeClosure { _ = ncInt. value }
81+ takeClosure { _ = ncInt. i }
6082}
You can’t perform that action at this time.
0 commit comments