@@ -1179,6 +1179,8 @@ final public class BorrowedFromInst : SingleValueInstruction, BeginBorrowInstruc
11791179 public var enclosingValues : LazyMapSequence < LazySequence < OperandArray > . Elements , Value > {
11801180 enclosingOperands. values
11811181 }
1182+
1183+ public var scopeEndingOperands : LazyFilterSequence < UseList > { uses. endingLifetime }
11821184}
11831185
11841186final public class ProjectBoxInst : SingleValueInstruction , UnaryInstruction {
@@ -1416,7 +1418,7 @@ final public class AllocExistentialBoxInst : SingleValueInstruction, Allocation
14161418/// scope ending instruction such as `begin_access` (ending with `end_access`) and `begin_borrow` (ending with
14171419/// `end_borrow`).
14181420public protocol ScopedInstruction : Instruction {
1419- var endOperands : LazyFilterSequence < UseList > { get }
1421+ var scopeEndingOperands : LazyFilterSequence < UseList > { get }
14201422
14211423 var endInstructions : EndInstructions { get }
14221424}
@@ -1425,7 +1427,7 @@ extension Instruction {
14251427 /// Return the sequence of use points of any instruction.
14261428 public var endInstructions : EndInstructions {
14271429 if let scopedInst = self as? ScopedInstruction {
1428- return . scoped( scopedInst. endOperands . users)
1430+ return . scoped( scopedInst. scopeEndingOperands . users)
14291431 }
14301432 return . single( self )
14311433 }
@@ -1440,22 +1442,14 @@ final public class EndBorrowInst : Instruction, UnaryInstruction {
14401442 public var borrow : Value { operand. value }
14411443}
14421444
1443- extension BeginBorrowInstruction {
1444- public var endOperands : LazyFilterSequence < UseList > {
1445- return self . uses. lazy. filter { $0. instruction is EndBorrowInst }
1446- }
1447- }
1448-
14491445final public class BeginBorrowInst : SingleValueInstruction , UnaryInstruction , BeginBorrowInstruction {
14501446 public var borrowedValue : Value { operand. value }
14511447
14521448 public override var isLexical : Bool { bridged. BeginBorrow_isLexical ( ) }
14531449 public var hasPointerEscape : Bool { bridged. BeginBorrow_hasPointerEscape ( ) }
14541450 public var isFromVarDecl : Bool { bridged. BeginBorrow_isFromVarDecl ( ) }
14551451
1456- public var endOperands : LazyFilterSequence < UseList > {
1457- return uses. endingLifetime
1458- }
1452+ public var scopeEndingOperands : LazyFilterSequence < UseList > { uses. endingLifetime }
14591453}
14601454
14611455final public class LoadBorrowInst : SingleValueInstruction , LoadInstruction , BeginBorrowInstruction {
@@ -1466,6 +1460,8 @@ final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, Beg
14661460 // code using noncopyable types that consumes or mutates a memory location while that location is borrowed,
14671461 // but the move-only checker must diagnose those problems before canonical SIL is formed.
14681462 public var isUnchecked : Bool { bridged. LoadBorrowInst_isUnchecked ( ) }
1463+
1464+ public var scopeEndingOperands : LazyFilterSequence < UseList > { uses. endingLifetime }
14691465}
14701466
14711467final public class StoreBorrowInst : SingleValueInstruction , StoringInstruction , BeginBorrowInstruction {
@@ -1477,7 +1473,13 @@ final public class StoreBorrowInst : SingleValueInstruction, StoringInstruction,
14771473 return dest as! AllocStackInst
14781474 }
14791475
1476+ public var scopeEndingOperands : LazyFilterSequence < UseList > {
1477+ return self . uses. lazy. filter { $0. instruction is EndBorrowInst }
1478+ }
1479+
14801480 public var endBorrows : LazyMapSequence < LazyFilterSequence < UseList > , Instruction > {
1481+ // A `store_borrow` is an address value.
1482+ // Only `end_borrow`s (with this address operand) can end such a borrow scope.
14811483 uses. users ( ofType: EndBorrowInst . self)
14821484 }
14831485}
@@ -1502,7 +1504,7 @@ final public class BeginAccessInst : SingleValueInstruction, UnaryInstruction {
15021504 public typealias EndAccessInstructions = LazyMapSequence < LazyFilterSequence < UseList > , EndAccessInst >
15031505
15041506 public var endAccessInstructions : EndAccessInstructions {
1505- endOperands . map { $0. instruction as! EndAccessInst }
1507+ scopeEndingOperands . map { $0. instruction as! EndAccessInst }
15061508 }
15071509}
15081510
@@ -1513,7 +1515,7 @@ final public class EndAccessInst : Instruction, UnaryInstruction {
15131515}
15141516
15151517extension BeginAccessInst : ScopedInstruction {
1516- public var endOperands : LazyFilterSequence < UseList > {
1518+ public var scopeEndingOperands : LazyFilterSequence < UseList > {
15171519 return uses. lazy. filter { $0. instruction is EndAccessInst }
15181520 }
15191521}
@@ -1549,7 +1551,7 @@ final public class AbortApplyInst : Instruction, UnaryInstruction {
15491551}
15501552
15511553extension BeginApplyInst : ScopedInstruction {
1552- public var endOperands : LazyFilterSequence < UseList > {
1554+ public var scopeEndingOperands : LazyFilterSequence < UseList > {
15531555 return token. uses. lazy. filter { $0. isScopeEndingUse }
15541556 }
15551557}
0 commit comments