Skip to content

Commit ba9ad08

Browse files
committed
ForwardingUtils comments and cleanup.
1 parent d26a9f1 commit ba9ad08

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/ForwardingUtils.swift

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,32 +197,39 @@ enum ForwardingUseResult: CustomStringConvertible {
197197
}
198198
}
199199

200-
/// Visit all the uses in a forward-extended lifetime
200+
/// Visit all the non-forwarding uses in a forward-extended lifetime
201201
/// (LifetimeIntroducer -> Operand).
202202
///
203203
/// Minimal requirements:
204204
/// needWalk(for value: Value) -> Bool
205-
/// leafUse(_ operand: Operand) -> WalkResult
205+
/// nonForwardingUse(_ operand: Operand) -> WalkResult
206206
/// deadValue(_ value: Value, using operand: Operand?) -> WalkResult
207207
///
208208
/// Start walking:
209209
/// walkDown(root: Value)
210+
///
210211
protocol ForwardingDefUseWalker {
211-
// Minimally, check a ValueSet. This walker may traverse chains of
212-
// aggregation and destructuring by default. Implementations may
213-
// handle phis.
212+
/// Minimally, check a ValueSet. This walker may traverse chains of
213+
/// aggregation and destructuring by default. Implementations may
214+
/// handle phis.
214215
mutating func needWalk(for value: Value) -> Bool
215216

216-
mutating func leafUse(_ operand: Operand) -> WalkResult
217+
/// A nonForwarding use does not forward ownership, but may
218+
/// propagate the lifetime in other ways, such as an interior
219+
/// pointer.
220+
mutating func nonForwardingUse(_ operand: Operand) -> WalkResult
217221

218-
// Report any initial or forwarded value with no uses. Only relevant for
219-
// guaranteed values or incomplete OSSA. This could be a dead
220-
// instruction, a terminator in which the result is dead on one
221-
// path, or a dead phi.
222-
//
223-
// \p operand is nil if \p value is the root.
222+
/// Report any initial or forwarded value with no uses. Only relevant for
223+
/// guaranteed values or incomplete OSSA. This could be a dead
224+
/// instruction, a terminator in which the result is dead on one
225+
/// path, or a dead phi.
226+
///
227+
/// \p operand is nil if \p value is the root.
224228
mutating func deadValue(_ value: Value, using operand: Operand?) -> WalkResult
225229

230+
/// This is called for every forwarded value. If the root was an
231+
/// owned value, then this identifies all OSSA lifetimes in the
232+
/// forward-extendd lifetime.
226233
mutating func walkDownUses(of: Value, using: Operand?) -> WalkResult
227234

228235
mutating func walkDown(operand: Operand) -> WalkResult
@@ -235,7 +242,7 @@ extension ForwardingDefUseWalker {
235242
}
236243

237244
mutating func walkDownUses(of value: Value, using operand: Operand?)
238-
-> WalkResult {
245+
-> WalkResult {
239246
return walkDownUsesDefault(forwarding: value, using: operand)
240247
}
241248

@@ -268,7 +275,7 @@ extension ForwardingDefUseWalker {
268275
if let phi = Phi(using: operand) {
269276
return walkDownUses(of: phi.value, using: operand)
270277
}
271-
return leafUse(operand)
278+
return nonForwardingUse(operand)
272279
}
273280
}
274281

@@ -301,7 +308,7 @@ private struct VisitForwardedUses : ForwardingDefUseWalker {
301308
visitedValues.insert(value)
302309
}
303310

304-
mutating func leafUse(_ operand: Operand) -> WalkResult {
311+
mutating func nonForwardingUse(_ operand: Operand) -> WalkResult {
305312
return visitor(.operand(operand))
306313
}
307314

0 commit comments

Comments
 (0)