@@ -34,13 +34,19 @@ protocol AddressUseVisitor {
34
34
/// An access scope: begin_access, begin_apply, load_borrow.
35
35
mutating func scopedAddressUse( of operand: Operand ) -> WalkResult
36
36
37
+ /// end_access, end_apply, abort_apply, end_borrow.
38
+ mutating func scopeEndingAddressUse( of operand: Operand ) -> WalkResult
39
+
37
40
/// A address leaf use cannot propagate the address bits beyond the
38
41
/// instruction.
39
42
///
40
- /// An apply or builtin propagates an address into the callee, but
41
- /// it is considered a leaf use as long as the argument does not escape.
43
+ /// StoringInstructions are leaf uses.
42
44
mutating func leafAddressUse( of operand: Operand ) -> WalkResult
43
45
46
+ /// An address used by an apply.
47
+ mutating func appliedAddressUse( of operand: Operand , by apply: FullApplySite )
48
+ -> WalkResult
49
+
44
50
/// A loaded address use propagates the value at the address.
45
51
mutating func loadedAddressUse( of operand: Operand , into value: Value )
46
52
-> WalkResult
@@ -67,10 +73,12 @@ extension AddressUseVisitor {
67
73
/// protocol methods above.
68
74
mutating func classifyAddress( operand: Operand ) -> WalkResult {
69
75
switch operand. instruction {
70
- case is BeginAccessInst , is BeginApplyInst , is LoadBorrowInst ,
71
- is StoreBorrowInst :
76
+ case is BeginAccessInst , is LoadBorrowInst , is StoreBorrowInst :
72
77
return scopedAddressUse ( of: operand)
73
78
79
+ case is EndAccessInst , is EndApplyInst , is AbortApplyInst , is EndBorrowInst :
80
+ return scopeEndingAddressUse ( of: operand)
81
+
74
82
case let markDep as MarkDependenceInst :
75
83
if markDep. valueOperand == operand {
76
84
return projectedAddressUse ( of: operand, into: markDep)
@@ -81,7 +89,7 @@ extension AddressUseVisitor {
81
89
if markDep. type. isAddress {
82
90
return projectedAddressUse ( of: operand, into: markDep)
83
91
}
84
- if LifetimeDependence ( markDependence : markDep, context) != nil {
92
+ if LifetimeDependence ( markDep, context) != nil {
85
93
// This is unreachable from InteriorUseVisitor because the
86
94
// base address of a `mark_dependence [nonescaping]` must be a
87
95
// `begin_access`, and interior liveness does not check uses of
@@ -97,7 +105,7 @@ extension AddressUseVisitor {
97
105
case let pai as PartialApplyInst where !pai. isOnStack:
98
106
return escapingAddressUse ( of: operand)
99
107
100
- case is AddressToPointerInst :
108
+ case is ReturnInst , is ThrowInst , is YieldInst , is AddressToPointerInst :
101
109
return escapingAddressUse ( of: operand)
102
110
103
111
case is StructElementAddrInst , is TupleElementAddrInst ,
@@ -113,16 +121,18 @@ extension AddressUseVisitor {
113
121
let svi = operand. instruction as! SingleValueInstruction
114
122
return projectedAddressUse ( of: operand, into: svi)
115
123
116
- case is ReturnInst , is ThrowInst , is YieldInst , is TryApplyInst ,
117
- is SwitchEnumAddrInst , is CheckedCastAddrBranchInst ,
124
+ case let apply as FullApplySite :
125
+ return appliedAddressUse ( of: operand, by: apply)
126
+
127
+ case is SwitchEnumAddrInst , is CheckedCastAddrBranchInst ,
118
128
is SelectEnumAddrInst , is InjectEnumAddrInst ,
119
129
is StoreInst , is StoreUnownedInst , is StoreWeakInst ,
120
130
is AssignInst , is AssignByWrapperInst , is AssignOrInitInst ,
121
131
is TupleAddrConstructorInst , is InitBlockStorageHeaderInst ,
122
132
is RetainValueAddrInst , is ReleaseValueAddrInst ,
123
133
is DestroyAddrInst , is DeallocStackInst ,
124
134
is DeinitExistentialAddrInst ,
125
- is EndApplyInst , is IsUniqueInst , is MarkFunctionEscapeInst ,
135
+ is IsUniqueInst , is MarkFunctionEscapeInst ,
126
136
is PackElementSetInst :
127
137
return leafAddressUse ( of: operand)
128
138
0 commit comments