File tree 2 files changed +31
-7
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities
2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -1022,12 +1022,14 @@ extension LifetimeDependenceDefUseWalker {
1022
1022
assert ( !mdi. isUnresolved && !mdi. isNonEscaping,
1023
1023
" should be handled as a dependence by AddressUseVisitor " )
1024
1024
}
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
+ }
1030
1031
}
1032
+ // Escaping an address
1031
1033
return escapingDependence ( on: operand)
1032
1034
}
1033
1035
Original file line number Diff line number Diff line change @@ -23,7 +23,29 @@ func bv_copy(_ bv: borrowing BV) -> dependsOn(bv) BV {
23
23
}
24
24
25
25
struct 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
+ }
27
49
}
28
50
29
51
func takeClosure( _: ( ) -> ( ) ) { }
@@ -56,5 +78,5 @@ func bv_borrow_borrow(bv: borrowing BV) -> dependsOn(scoped bv) BV {
56
78
// because lifetime dependence does not expect a dependence directly on an 'inout' address without any 'begin_access'
57
79
// marker.
58
80
func ncint_capture( ncInt: inout NCInt ) {
59
- takeClosure { _ = ncInt. value }
81
+ takeClosure { _ = ncInt. i }
60
82
}
You can’t perform that action at this time.
0 commit comments