@@ -104,6 +104,7 @@ extension ProjectedValue {
104
104
_ context: some Context ) -> V . Result ? {
105
105
var walker = EscapeWalker ( visitor: visitor, complexityBudget: complexityBudget, context)
106
106
if walker. walkUp ( addressOrValue: value, path: path. escapePath) == . abortWalk {
107
+ walker. visitor. cleanupOnAbort ( )
107
108
return nil
108
109
}
109
110
return walker. visitor. result
@@ -119,6 +120,7 @@ extension ProjectedValue {
119
120
_ context: some Context ) -> V . Result ? {
120
121
var walker = EscapeWalker ( visitor: visitor, context)
121
122
if walker. walkDown ( addressOrValue: value, path: path. escapePath) == . abortWalk {
123
+ walker. visitor. cleanupOnAbort ( )
122
124
return nil
123
125
}
124
126
return walker. visitor. result
@@ -182,6 +184,12 @@ extension EscapeVisitor {
182
184
protocol EscapeVisitorWithResult : EscapeVisitor {
183
185
associatedtype Result
184
186
var result : Result { get }
187
+
188
+ mutating func cleanupOnAbort( )
189
+ }
190
+
191
+ extension EscapeVisitorWithResult {
192
+ mutating func cleanupOnAbort( ) { }
185
193
}
186
194
187
195
// FIXME: This ought to be marked private, but that triggers a compiler bug
@@ -482,7 +490,7 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
482
490
// 1. the closure (with the captured values) itself can escape
483
491
// 2. something can escape in a destructor when the context is destroyed
484
492
return walkDownUses ( ofValue: pai, path: path. with ( knownType: nil ) )
485
- case is LoadInst , is LoadWeakInst , is LoadUnownedInst :
493
+ case is LoadInst , is LoadWeakInst , is LoadUnownedInst , is LoadBorrowInst :
486
494
if !followLoads( at: path. projectionPath) {
487
495
return . continueWalk
488
496
}
@@ -693,7 +701,7 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
693
701
}
694
702
case let ap as ApplyInst :
695
703
return walkUpApplyResult ( apply: ap, path: path. with ( knownType: nil ) )
696
- case is LoadInst , is LoadWeakInst , is LoadUnownedInst :
704
+ case is LoadInst , is LoadWeakInst , is LoadUnownedInst , is LoadBorrowInst :
697
705
if !followLoads( at: path. projectionPath) {
698
706
// When walking up we shouldn't end up at a load where followLoads is false,
699
707
// because going from a (non-followLoads) address to a load always involves a class indirection.
0 commit comments