Skip to content

Commit cf99536

Browse files
committed
Optimizer Utilities: add InstructionWorklist.pushPredecessors(of: Instruction, ignoring:)
1 parent 3fb7032 commit cf99536

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/DataStructures/Worklist.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,21 @@ typealias BasicBlockWorklist = Worklist<BasicBlockSet>
7676
typealias InstructionWorklist = Worklist<InstructionSet>
7777
typealias ValueWorklist = Worklist<ValueSet>
7878
typealias OperandWorklist = Worklist<OperandSet>
79+
80+
extension InstructionWorklist {
81+
mutating func pushPredecessors(of inst: Instruction, ignoring ignoreInst: SingleValueInstruction) {
82+
if let prev = inst.previous {
83+
if prev != ignoreInst {
84+
pushIfNotVisited(prev)
85+
}
86+
} else {
87+
for predBlock in inst.parentBlock.predecessors {
88+
let termInst = predBlock.terminator
89+
if termInst != ignoreInst {
90+
pushIfNotVisited(termInst)
91+
}
92+
}
93+
}
94+
}
95+
}
96+

0 commit comments

Comments
 (0)