Skip to content

Commit c3612ba

Browse files
committed
SIL: make var OperandArray.values available for all kind of operand sequences
1 parent 876fd51 commit c3612ba

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ConstantCapturePropagation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private func constantPropagateCaptures(of partialApply: PartialApplyInst, _ cont
112112
// Escaping closures consume their arguments. Therefore we need to destroy the removed argument values.
113113
addCompensatingDestroys(for: constArgs, context)
114114
}
115-
let newArguments = nonConstArgs.map { $0.value }
115+
let newArguments = Array(nonConstArgs.values)
116116
rewritePartialApply(partialApply, withSpecialized: specializedCallee, arguments: newArguments, context)
117117
}
118118

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/InitializeStaticGlobals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ private extension Value {
404404
case is LoadInst:
405405
return true
406406
case is StructInst, is TupleInst:
407-
worklist.pushIfNotVisited(contentsOf: (v as! Instruction).operands.lazy.map { $0.value })
407+
worklist.pushIfNotVisited(contentsOf: (v as! Instruction).operands.values)
408408
case let ei as EnumInst:
409409
if let payload = ei.payload {
410410
worklist.pushIfNotVisited(payload)

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyCondBranch.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ private extension CondBranchInst {
2727
}
2828
let builder = Builder(before: self, context)
2929
if conditionValue == 0 {
30-
builder.createBranch(to: falseBlock, arguments: Array(falseOperands.map { $0.value }))
30+
builder.createBranch(to: falseBlock, arguments: Array(falseOperands.values))
3131
} else {
32-
builder.createBranch(to: trueBlock, arguments: Array(trueOperands.map { $0.value }))
32+
builder.createBranch(to: trueBlock, arguments: Array(trueOperands.values))
3333
}
3434
context.erase(instruction: self)
3535
}

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension Value {
7171
}
7272
switch v {
7373
case let fw as ForwardingInstruction:
74-
worklist.pushIfNotVisited(contentsOf: fw.definedOperands.lazy.map { $0.value })
74+
worklist.pushIfNotVisited(contentsOf: fw.definedOperands.values)
7575
case let bf as BorrowedFromInst:
7676
worklist.pushIfNotVisited(bf.borrowedValue)
7777
case let bb as BeginBorrowInst:
@@ -82,7 +82,7 @@ extension Value {
8282
} else if let termResult = TerminatorResult(arg),
8383
let fw = termResult.terminator as? ForwardingInstruction
8484
{
85-
worklist.pushIfNotVisited(contentsOf: fw.definedOperands.lazy.map { $0.value })
85+
worklist.pushIfNotVisited(contentsOf: fw.definedOperands.values)
8686
}
8787
default:
8888
continue

SwiftCompilerSources/Sources/SIL/Argument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public struct Phi {
170170
}
171171

172172
public var incomingValues: LazyMapSequence<LazyMapSequence<PredecessorList, Operand>, Value> {
173-
incomingOperands.lazy.map { $0.value }
173+
incomingOperands.values
174174
}
175175

176176
public var isReborrow: Bool { value.isReborrow }

SwiftCompilerSources/Sources/SIL/Operand.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ public struct OperandArray : RandomAccessCollection, CustomReflectable {
104104
base: OptionalBridgedOperand(op: base.advancedBy(bounds.lowerBound).op),
105105
count: bounds.upperBound - bounds.lowerBound)
106106
}
107-
108-
public var values: LazyMapSequence<LazySequence<OperandArray>.Elements, Value> {
109-
self.lazy.map { $0.value }
110-
}
111107
}
112108

113109
public struct UseList : CollectionLikeSequence {
@@ -143,6 +139,10 @@ public struct UseList : CollectionLikeSequence {
143139
}
144140

145141
extension Sequence where Element == Operand {
142+
public var values: LazyMapSequence<Self, Value> {
143+
self.lazy.map { $0.value }
144+
}
145+
146146
public var singleUse: Operand? {
147147
var result: Operand? = nil
148148
for op in self {

SwiftCompilerSources/Sources/SIL/Utilities/BorrowUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public final class EnclosingValueIterator : IteratorProtocol {
534534
} else if let forwardingInst = value.forwardingInstruction {
535535
// Recurse through guaranteed forwarding non-phi instructions.
536536
let ops = forwardingInst.forwardedOperands
537-
worklist.pushIfNotVisited(contentsOf: ops.lazy.map { $0.value })
537+
worklist.pushIfNotVisited(contentsOf: ops.values)
538538
} else if value.isGuaranteedApplyResult {
539539
let selfArgument = (value as! ApplyInst).arguments.last!
540540
worklist.pushIfNotVisited(selfArgument)

0 commit comments

Comments
 (0)