@@ -199,13 +199,13 @@ struct InteriorLivenessResult: CustomDebugStringConvertible {
199
199
///
200
200
/// The top-level entry points are:
201
201
/// - `classify(operand:)`
202
- /// - `visitUsesOfOuter(value :)`
202
+ /// - `visitAllUses(of :)`
203
203
///
204
204
/// The implementation may recursively call back to the top-level
205
205
/// entry points. Additionally, the implementation may recurse into inner
206
206
/// borrow scopes, skipping over the uses within inner scopes using:
207
- /// - `visitInnerBorrowUses(of:)`
208
- /// - `visitUsesOfInner(value: )`
207
+ /// - `visitInnerBorrowUses(of: BorrowingInstruction )`
208
+ /// - `visitInnerScopeUses(of: Value )`
209
209
///
210
210
/// Visitors implement:
211
211
///
@@ -225,7 +225,7 @@ struct InteriorLivenessResult: CustomDebugStringConvertible {
225
225
/// `isInnerlifetime` indicates whether the value being used is
226
226
/// defined by the "outer" OSSA lifetime or an inner borrow scope.
227
227
/// When the OwnershipUseVisitor is invoked on an outer value
228
- /// (visitUsesOfOuter(value :)), it visits all the uses of that value
228
+ /// (visitAllUses(of :)), it visits all the uses of that value
229
229
/// and also visits the lifetime-ending uses of any inner borrow
230
230
/// scopes. This provides a complete set of liveness "use points":
231
231
///
@@ -285,14 +285,14 @@ protocol OwnershipUseVisitor {
285
285
286
286
/// A use that is scoped to an inner borrow scope.
287
287
///
288
- /// Call `visitInnerBorrowUses (of:)` to recursively classify any
288
+ /// Call `visitInnerScopeUses (of:)` to recursively classify any
289
289
/// scope-ending uses and forwarded dependent values.
290
290
mutating func borrowingUse( of operand: Operand ,
291
291
by borrowInst: BorrowingInstruction ) -> WalkResult
292
292
293
293
/// A reborrow operand.
294
294
///
295
- /// Call `visitUsesOfInner ()` to recursively classify scope-ending
295
+ /// Call `visitInnerScopeUses ()` to recursively classify scope-ending
296
296
/// uses (reborrow and end_borrow).
297
297
mutating func reborrowingUse( of operand: Operand , isInnerLifetime: Bool )
298
298
-> WalkResult
@@ -320,7 +320,7 @@ extension OwnershipUseVisitor {
320
320
/// adjacent phis and treat them like inner borrows.
321
321
///
322
322
/// This is only called for uses in the outer lifetime.
323
- mutating func visitUsesOfOuter ( value : Value ) -> WalkResult {
323
+ mutating func visitAllUses ( of : Value ) -> WalkResult {
324
324
switch value. ownership {
325
325
case . owned:
326
326
return value. uses. ignoreTypeDependence. walk { classifyOwned ( operand: $0) }
@@ -338,7 +338,7 @@ extension OwnershipUseVisitor {
338
338
/// lifetime, including: begin_borrow, reborrow, partial_apply,
339
339
/// mark_dependence, or an inner adjacent phi (where original SSA
340
340
/// def is a phi in the same block).
341
- mutating func visitUsesOfInner ( value : Value ) -> WalkResult {
341
+ mutating func visitInnerScopeUses ( of : Value ) -> WalkResult {
342
342
if let beginBorrow = BeginBorrowValue ( value) {
343
343
return beginBorrow. scopeEndingOperands. walk {
344
344
switch $0. ownership {
@@ -370,11 +370,11 @@ extension OwnershipUseVisitor {
370
370
371
371
// Visit uses of borrowing instruction (operandOwnerhip == .borrow),
372
372
// skipping uses within the borrow scope.
373
- mutating func visitInnerBorrowUses ( of borrowInst: BorrowingInstruction )
373
+ mutating func visitInnerScopeUses ( of borrowInst: BorrowingInstruction )
374
374
-> WalkResult {
375
375
// If a borrowed value is introduced, then handle the inner scope.
376
376
if let beginBorrow = BeginBorrowValue ( resultOf: borrowInst) {
377
- return visitUsesOfInner ( value : beginBorrow. value)
377
+ return visitInnerScopeUses ( of : beginBorrow. value)
378
378
}
379
379
// Otherwise, directly visit the scope ending uses.
380
380
//
@@ -578,17 +578,17 @@ struct InteriorUseWalker {
578
578
if handleInner ( borrowed: innerPhi. value) == . abortWalk {
579
579
return . abortWalk
580
580
}
581
- return visitUsesOfInner ( value : innerPhi. value)
581
+ return visitInnerScopeUses ( of : innerPhi. value)
582
582
} else {
583
583
// Inner adjacent guaranteed phis are uses of the outer borrow.
584
- return visitUsesOfOuter ( value : innerPhi. value)
584
+ return visitAllUses ( of : innerPhi. value)
585
585
}
586
586
}
587
587
if result == . abortWalk {
588
588
return . abortWalk
589
589
}
590
590
}
591
- return visitUsesOfOuter ( value : definingValue)
591
+ return visitAllUses ( of : definingValue)
592
592
}
593
593
}
594
594
@@ -636,15 +636,15 @@ extension InteriorUseWalker: OwnershipUseVisitor {
636
636
// Handle partial_apply [on_stack] and mark_dependence [nonescaping].
637
637
//
638
638
// TODO: Rather than walking down the owned uses, this could call
639
- // visitInnerBorrowUses , but we need to ensure all dependent values
639
+ // visitInnerScopeUses , but we need to ensure all dependent values
640
640
// are complete first:
641
641
//
642
642
// if let svi = borrowInst as! SingleValueInstruction,
643
643
// svi.ownership == .owned {
644
644
// if handleInner(borrowed: beginBorrow.value) == .abortWalk {
645
645
// return .abortWalk
646
646
// }
647
- // return visitInnerBorrowUses (of: borrowInst)
647
+ // return visitInnerScopeUses (of: borrowInst)
648
648
// }
649
649
mutating func dependentUse( of operand: Operand , into value: Value )
650
650
-> WalkResult {
@@ -667,18 +667,16 @@ extension InteriorUseWalker: OwnershipUseVisitor {
667
667
}
668
668
669
669
// Call the innerScopeHandler before visiting the scope-ending uses.
670
- mutating func borrowingUse( of operand: Operand ,
671
- by borrowInst: BorrowingInstruction )
672
- -> WalkResult {
670
+ mutating func borrowingUse( of operand: Operand , by borrowInst: BorrowingInstruction ) -> WalkResult {
673
671
if let beginBorrow = BeginBorrowValue ( resultOf: borrowInst) {
674
672
if handleInner ( borrowed: beginBorrow. value) == . abortWalk {
675
673
return . abortWalk
676
674
}
677
675
if visitInnerUses {
678
- return visitUsesOfOuter ( value : beginBorrow. value)
676
+ return visitAllUses ( of : beginBorrow. value)
679
677
}
680
678
}
681
- return visitInnerBorrowUses ( of: borrowInst)
679
+ return visitInnerScopeUses ( of: borrowInst)
682
680
}
683
681
684
682
// Visit a reborrow operand. This ends an outer lifetime and extends
@@ -824,9 +822,9 @@ extension InteriorUseWalker {
824
822
}
825
823
switch value. ownership {
826
824
case . owned:
827
- return visitUsesOfInner ( value : value)
825
+ return visitInnerScopeUses ( of : value)
828
826
case . guaranteed:
829
- return visitUsesOfOuter ( value : value)
827
+ return visitAllUses ( of : value)
830
828
default :
831
829
fatalError ( " ownership requires a lifetime " )
832
830
}
@@ -899,9 +897,9 @@ extension InteriorUseWalker {
899
897
// Since definingValue dominates guaranteedPhi, this is a well-formed linear
900
898
// lifetime, and liveness can proceed.
901
899
if guaranteedPhi. isReborrow {
902
- return visitUsesOfInner ( value : guaranteedPhi. value)
900
+ return visitInnerScopeUses ( of : guaranteedPhi. value)
903
901
} else {
904
- return visitUsesOfOuter ( value : guaranteedPhi. value)
902
+ return visitAllUses ( of : guaranteedPhi. value)
905
903
}
906
904
}
907
905
}
0 commit comments