Skip to content

Commit 800fa16

Browse files
committed
ForwardingUtils; minor cleanup
1 parent 1c8a150 commit 800fa16

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/ForwardingUtils.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ enum ForwardingUseResult: CustomStringConvertible {
202202
///
203203
/// Minimal requirements:
204204
/// needWalk(for value: Value) -> Bool
205-
/// nonForwardingUse(_ operand: Operand) -> WalkResult
205+
/// nonForwardingUse(of operand: Operand) -> WalkResult
206206
/// deadValue(_ value: Value, using operand: Operand?) -> WalkResult
207207
///
208208
/// Start walking:
@@ -217,7 +217,7 @@ protocol ForwardingDefUseWalker {
217217
/// A nonForwarding use does not forward ownership, but may
218218
/// propagate the lifetime in other ways, such as an interior
219219
/// pointer.
220-
mutating func nonForwardingUse(_ operand: Operand) -> WalkResult
220+
mutating func nonForwardingUse(of operand: Operand) -> WalkResult
221221

222222
/// Report any initial or forwarded value with no uses. Only relevant for
223223
/// guaranteed values or incomplete OSSA. This could be a dead
@@ -249,8 +249,9 @@ extension ForwardingDefUseWalker {
249249
mutating func walkDownUsesDefault(forwarding value: Value,
250250
using operand: Operand?)
251251
-> WalkResult {
252-
if !needWalk(for: value) { return .continueWalk }
253-
252+
if !needWalk(for: value) {
253+
return .continueWalk
254+
}
254255
var hasUse = false
255256
for use in value.uses where !use.isTypeDependent {
256257
if walkDown(operand: use) == .abortWalk {
@@ -280,7 +281,7 @@ extension ForwardingDefUseWalker {
280281
if let phi = Phi(using: operand) {
281282
return walkDownUses(of: phi.value, using: operand)
282283
}
283-
return nonForwardingUse(operand)
284+
return nonForwardingUse(of: operand)
284285
}
285286
}
286287

@@ -313,7 +314,7 @@ private struct VisitForwardedUses : ForwardingDefUseWalker {
313314
visitedValues.insert(value)
314315
}
315316

316-
mutating func nonForwardingUse(_ operand: Operand) -> WalkResult {
317+
mutating func nonForwardingUse(of operand: Operand) -> WalkResult {
317318
return visitor(.operand(operand))
318319
}
319320

SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
import SILBridging
1414

1515
/// An instruction that forwards ownership from operands to results.
16+
///
17+
/// Forwarding instructions are not allowed to store the value or
18+
/// propagate its bits in any way that isn't tracked by its
19+
/// results. Passes assume that a forwarding value is nonescaping as
20+
/// long as its results are nonescaping.
1621
public protocol ForwardingInstruction : Instruction {
1722
var singleForwardedOperand: Operand? { get }
1823

0 commit comments

Comments
 (0)