@@ -1179,6 +1179,8 @@ final public class BorrowedFromInst : SingleValueInstruction, BeginBorrowInstruc
1179
1179
public var enclosingValues : LazyMapSequence < LazySequence < OperandArray > . Elements , Value > {
1180
1180
enclosingOperands. values
1181
1181
}
1182
+
1183
+ public var scopeEndingOperands : LazyFilterSequence < UseList > { uses. endingLifetime }
1182
1184
}
1183
1185
1184
1186
final public class ProjectBoxInst : SingleValueInstruction , UnaryInstruction {
@@ -1416,7 +1418,7 @@ final public class AllocExistentialBoxInst : SingleValueInstruction, Allocation
1416
1418
/// scope ending instruction such as `begin_access` (ending with `end_access`) and `begin_borrow` (ending with
1417
1419
/// `end_borrow`).
1418
1420
public protocol ScopedInstruction : Instruction {
1419
- var endOperands : LazyFilterSequence < UseList > { get }
1421
+ var scopeEndingOperands : LazyFilterSequence < UseList > { get }
1420
1422
1421
1423
var endInstructions : EndInstructions { get }
1422
1424
}
@@ -1425,7 +1427,7 @@ extension Instruction {
1425
1427
/// Return the sequence of use points of any instruction.
1426
1428
public var endInstructions : EndInstructions {
1427
1429
if let scopedInst = self as? ScopedInstruction {
1428
- return . scoped( scopedInst. endOperands . users)
1430
+ return . scoped( scopedInst. scopeEndingOperands . users)
1429
1431
}
1430
1432
return . single( self )
1431
1433
}
@@ -1440,22 +1442,14 @@ final public class EndBorrowInst : Instruction, UnaryInstruction {
1440
1442
public var borrow : Value { operand. value }
1441
1443
}
1442
1444
1443
- extension BeginBorrowInstruction {
1444
- public var endOperands : LazyFilterSequence < UseList > {
1445
- return self . uses. lazy. filter { $0. instruction is EndBorrowInst }
1446
- }
1447
- }
1448
-
1449
1445
final public class BeginBorrowInst : SingleValueInstruction , UnaryInstruction , BeginBorrowInstruction {
1450
1446
public var borrowedValue : Value { operand. value }
1451
1447
1452
1448
public override var isLexical : Bool { bridged. BeginBorrow_isLexical ( ) }
1453
1449
public var hasPointerEscape : Bool { bridged. BeginBorrow_hasPointerEscape ( ) }
1454
1450
public var isFromVarDecl : Bool { bridged. BeginBorrow_isFromVarDecl ( ) }
1455
1451
1456
- public var endOperands : LazyFilterSequence < UseList > {
1457
- return uses. endingLifetime
1458
- }
1452
+ public var scopeEndingOperands : LazyFilterSequence < UseList > { uses. endingLifetime }
1459
1453
}
1460
1454
1461
1455
final public class LoadBorrowInst : SingleValueInstruction , LoadInstruction , BeginBorrowInstruction {
@@ -1466,6 +1460,8 @@ final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, Beg
1466
1460
// code using noncopyable types that consumes or mutates a memory location while that location is borrowed,
1467
1461
// but the move-only checker must diagnose those problems before canonical SIL is formed.
1468
1462
public var isUnchecked : Bool { bridged. LoadBorrowInst_isUnchecked ( ) }
1463
+
1464
+ public var scopeEndingOperands : LazyFilterSequence < UseList > { uses. endingLifetime }
1469
1465
}
1470
1466
1471
1467
final public class StoreBorrowInst : SingleValueInstruction , StoringInstruction , BeginBorrowInstruction {
@@ -1477,7 +1473,13 @@ final public class StoreBorrowInst : SingleValueInstruction, StoringInstruction,
1477
1473
return dest as! AllocStackInst
1478
1474
}
1479
1475
1476
+ public var scopeEndingOperands : LazyFilterSequence < UseList > {
1477
+ return self . uses. lazy. filter { $0. instruction is EndBorrowInst }
1478
+ }
1479
+
1480
1480
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.
1481
1483
uses. users ( ofType: EndBorrowInst . self)
1482
1484
}
1483
1485
}
@@ -1502,7 +1504,7 @@ final public class BeginAccessInst : SingleValueInstruction, UnaryInstruction {
1502
1504
public typealias EndAccessInstructions = LazyMapSequence < LazyFilterSequence < UseList > , EndAccessInst >
1503
1505
1504
1506
public var endAccessInstructions : EndAccessInstructions {
1505
- endOperands . map { $0. instruction as! EndAccessInst }
1507
+ scopeEndingOperands . map { $0. instruction as! EndAccessInst }
1506
1508
}
1507
1509
}
1508
1510
@@ -1513,7 +1515,7 @@ final public class EndAccessInst : Instruction, UnaryInstruction {
1513
1515
}
1514
1516
1515
1517
extension BeginAccessInst : ScopedInstruction {
1516
- public var endOperands : LazyFilterSequence < UseList > {
1518
+ public var scopeEndingOperands : LazyFilterSequence < UseList > {
1517
1519
return uses. lazy. filter { $0. instruction is EndAccessInst }
1518
1520
}
1519
1521
}
@@ -1549,7 +1551,7 @@ final public class AbortApplyInst : Instruction, UnaryInstruction {
1549
1551
}
1550
1552
1551
1553
extension BeginApplyInst : ScopedInstruction {
1552
- public var endOperands : LazyFilterSequence < UseList > {
1554
+ public var scopeEndingOperands : LazyFilterSequence < UseList > {
1553
1555
return token. uses. lazy. filter { $0. isScopeEndingUse }
1554
1556
}
1555
1557
}
0 commit comments