Skip to content

Commit 0dee865

Browse files
committed
SIL: make protocol ScopeInstruction an Instruction protocol
This allows to remove the `var instruction` property. NFC
1 parent 1bff8cd commit 0dee865

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ private struct ExtendableScope {
287287
var firstInstruction: Instruction {
288288
switch introducer {
289289
case let .scoped(scopedInst):
290-
return scopedInst.instruction
290+
return scopedInst
291291
case let .owned(value):
292292
if let definingInst = value.definingInstructionOrTerminator {
293293
return definingInst

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,9 +1415,7 @@ final public class AllocExistentialBoxInst : SingleValueInstruction, Allocation
14151415
/// An instruction whose side effects extend across a scope including other instructions. These are always paired with a
14161416
/// scope ending instruction such as `begin_access` (ending with `end_access`) and `begin_borrow` (ending with
14171417
/// `end_borrow`).
1418-
public protocol ScopedInstruction {
1419-
var instruction: Instruction { get }
1420-
1418+
public protocol ScopedInstruction: Instruction {
14211419
var endOperands: LazyFilterSequence<UseList> { get }
14221420

14231421
var endInstructions: EndInstructions { get }
@@ -1437,17 +1435,13 @@ extension Instruction {
14371435
public protocol BorrowIntroducingInstruction : SingleValueInstruction, ScopedInstruction {
14381436
}
14391437

1440-
extension BorrowIntroducingInstruction {
1441-
public var instruction: Instruction { get { self } }
1442-
}
1443-
14441438
final public class EndBorrowInst : Instruction, UnaryInstruction {
14451439
public var borrow: Value { operand.value }
14461440
}
14471441

14481442
extension BorrowIntroducingInstruction {
14491443
public var endOperands: LazyFilterSequence<UseList> {
1450-
return uses.lazy.filter { $0.instruction is EndBorrowInst }
1444+
return self.uses.lazy.filter { $0.instruction is EndBorrowInst }
14511445
}
14521446
}
14531447

@@ -1518,8 +1512,6 @@ final public class EndAccessInst : Instruction, UnaryInstruction {
15181512
}
15191513

15201514
extension BeginAccessInst : ScopedInstruction {
1521-
public var instruction: Instruction { get { self } }
1522-
15231515
public var endOperands: LazyFilterSequence<UseList> {
15241516
return uses.lazy.filter { $0.instruction is EndAccessInst }
15251517
}
@@ -1556,8 +1548,6 @@ final public class AbortApplyInst : Instruction, UnaryInstruction {
15561548
}
15571549

15581550
extension BeginApplyInst : ScopedInstruction {
1559-
public var instruction: Instruction { get { self } }
1560-
15611551
public var endOperands: LazyFilterSequence<UseList> {
15621552
return token.uses.lazy.filter { $0.isScopeEndingUse }
15631553
}

0 commit comments

Comments
 (0)