Skip to content

Commit 54bc9f3

Browse files
committed
SIL: allow inserting specific instruction classes into an InstructionSet
Instead, remove `Operand.users(ofType:)` which returned a sequence of `Instruction` - which was a kind of replacement for the missing `InstructionSet` API
1 parent 011803a commit 54bc9f3

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

SwiftCompilerSources/Sources/Optimizer/DataStructures/Set.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ struct OperandSet : IntrusiveSet {
268268
}
269269
}
270270

271+
extension InstructionSet {
272+
mutating func insert<I: Instruction>(contentsOf source: some Sequence<I>) {
273+
for inst in source {
274+
_ = insert(inst)
275+
}
276+
}
277+
}
278+
271279
extension IntrusiveSet {
272280
mutating func insert(contentsOf source: some Sequence<Element>) {
273281
for element in source {

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ final public class AllocStackInst : SingleValueInstruction, Allocation, DebugVar
13661366
return bridged.AllocStack_hasVarInfo() ? bridged.AllocStack_getVarInfo() : nil
13671367
}
13681368

1369-
public var deallocations: LazyMapSequence<LazyFilterSequence<UseList>, Instruction> {
1369+
public var deallocations: LazyMapSequence<LazyFilterSequence<UseList>, DeallocStackInst> {
13701370
uses.users(ofType: DeallocStackInst.self)
13711371
}
13721372
}
@@ -1484,7 +1484,7 @@ final public class StoreBorrowInst : SingleValueInstruction, StoringInstruction,
14841484
return self.uses.lazy.filter { $0.instruction is EndBorrowInst }
14851485
}
14861486

1487-
public var endBorrows: LazyMapSequence<LazyFilterSequence<UseList>, Instruction> {
1487+
public var endBorrows: LazyMapSequence<LazyFilterSequence<UseList>, EndBorrowInst> {
14881488
// A `store_borrow` is an address value.
14891489
// Only `end_borrow`s (with this address operand) can end such a borrow scope.
14901490
uses.users(ofType: EndBorrowInst.self)

SwiftCompilerSources/Sources/SIL/Operand.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ extension Sequence where Element == Operand {
185185
public func users<I: Instruction>(ofType: I.Type) -> LazyMapSequence<LazyFilterSequence<Self>, I> {
186186
self.lazy.filter{ $0.instruction is I }.lazy.map { $0.instruction as! I }
187187
}
188-
189-
// This overload which returns a Sequence of `Instruction` and not a Sequence of `I` is used for APIs, like
190-
// `InstructionSet.insert(contentsOf:)`, which require a sequence of `Instruction`.
191-
public func users<I: Instruction>(ofType: I.Type) -> LazyMapSequence<LazyFilterSequence<Self>, Instruction> {
192-
self.lazy.filter{ $0.instruction is I }.users
193-
}
194188
}
195189

196190
extension Value {

0 commit comments

Comments
 (0)