Skip to content

Commit cbf5c19

Browse files
committed
SIL: rename protocol BorrowIntroducingInstruction -> BeginBorrowInstruction
to match with `BeginBorrowValue`
1 parent 0dee865 commit cbf5c19

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ struct AliasAnalysis {
358358
return defaultEffects(of: endBorrow, on: memLoc)
359359
case .box, .class, .tail:
360360
// Check if the memLoc is "derived" from the begin_borrow, i.e. is an interior pointer.
361-
var walker = FindBeginBorrowWalker(beginBorrow: endBorrow.borrow as! BorrowIntroducingInstruction)
361+
var walker = FindBeginBorrowWalker(beginBorrow: endBorrow.borrow as! BeginBorrowInstruction)
362362
return walker.visitAccessStorageRoots(of: accessPath) ? .noEffects : .worstEffects
363363
}
364364
}
@@ -704,7 +704,7 @@ private enum ImmutableScope {
704704
}
705705

706706
private struct FindBeginBorrowWalker : ValueUseDefWalker {
707-
let beginBorrow: BorrowIntroducingInstruction
707+
let beginBorrow: BeginBorrowInstruction
708708
var walkUpCache = WalkerCache<Path>()
709709

710710
mutating func walkUp(value: Value, path: SmallProjectionPath) -> WalkResult {

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LetPropertyLowering.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private func constructLetInitRegion(
136136
// root-class initializer).
137137
initRegion.insert(markUninitialized)
138138

139-
var borrows = Stack<BorrowIntroducingInstruction>(context)
139+
var borrows = Stack<BeginBorrowInstruction>(context)
140140
defer { borrows.deinitialize() }
141141

142142
for inst in markUninitialized.parentFunction.instructions {

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ extension GlobalVariable {
826826

827827
extension InstructionRange {
828828
/// Adds the instruction range of a borrow-scope by transitively visiting all (potential) re-borrows.
829-
mutating func insert(borrowScopeOf borrow: BorrowIntroducingInstruction, _ context: some Context) {
829+
mutating func insert(borrowScopeOf borrow: BeginBorrowInstruction, _ context: some Context) {
830830
var worklist = ValueWorklist(context)
831831
defer { worklist.deinitialize() }
832832

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ final public class BridgeObjectToRefInst : SingleValueInstruction, UnaryInstruct
11691169

11701170
final public class BridgeObjectToWordInst : SingleValueInstruction, UnaryInstruction {}
11711171

1172-
final public class BorrowedFromInst : SingleValueInstruction, BorrowIntroducingInstruction {
1172+
final public class BorrowedFromInst : SingleValueInstruction, BeginBorrowInstruction {
11731173
public var borrowedValue: Value { operands[0].value }
11741174
public var borrowedPhi: Phi { Phi(borrowedValue)! }
11751175
public var enclosingOperands: OperandArray {
@@ -1431,21 +1431,22 @@ extension Instruction {
14311431
}
14321432
}
14331433

1434-
/// Instructions beginning a borrow-scope which must be ended by `end_borrow`.
1435-
public protocol BorrowIntroducingInstruction : SingleValueInstruction, ScopedInstruction {
1434+
/// Single-value instructions beginning a borrow-scope which end with an `end_borrow` or a branch to a re-borrow phi.
1435+
/// See also `BeginBorrowValue` which represents all kind of `Value`s which begin a borrow scope.
1436+
public protocol BeginBorrowInstruction : SingleValueInstruction, ScopedInstruction {
14361437
}
14371438

14381439
final public class EndBorrowInst : Instruction, UnaryInstruction {
14391440
public var borrow: Value { operand.value }
14401441
}
14411442

1442-
extension BorrowIntroducingInstruction {
1443+
extension BeginBorrowInstruction {
14431444
public var endOperands: LazyFilterSequence<UseList> {
14441445
return self.uses.lazy.filter { $0.instruction is EndBorrowInst }
14451446
}
14461447
}
14471448

1448-
final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction, BorrowIntroducingInstruction {
1449+
final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction, BeginBorrowInstruction {
14491450
public var borrowedValue: Value { operand.value }
14501451

14511452
public override var isLexical: Bool { bridged.BeginBorrow_isLexical() }
@@ -1457,7 +1458,7 @@ final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction, B
14571458
}
14581459
}
14591460

1460-
final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, BorrowIntroducingInstruction {
1461+
final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, BeginBorrowInstruction {
14611462

14621463
// True if the invariants on `load_borrow` have not been checked and should not be strictly enforced.
14631464
//
@@ -1467,7 +1468,7 @@ final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, Bor
14671468
public var isUnchecked: Bool { bridged.LoadBorrowInst_isUnchecked() }
14681469
}
14691470

1470-
final public class StoreBorrowInst : SingleValueInstruction, StoringInstruction, BorrowIntroducingInstruction {
1471+
final public class StoreBorrowInst : SingleValueInstruction, StoringInstruction, BeginBorrowInstruction {
14711472
public var allocStack: AllocStackInst {
14721473
var dest = destination
14731474
if let mark = dest as? MarkUnresolvedNonCopyableValueInst {

0 commit comments

Comments
 (0)