Skip to content

Commit 8720139

Browse files
committed
Swift AccessUtils: remove AccessStoragePathWalker
Instead, place it's one and only API `visitAccessStorageRoots` into an extension of `ValueUseDefWalker`.
1 parent 0a59e02 commit 8720139

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

SwiftCompilerSources/Sources/Optimizer/TestPasses/AccessDumper.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ let accessDumper = FunctionPass(name: "dump-access", {
4848
print("End accesses for \(function.name)")
4949
})
5050

51-
private struct AccessStoragePathVisitor : AccessStoragePathWalker {
51+
private struct AccessStoragePathVisitor : ValueUseDefWalker {
5252
var walkUpCache = WalkerCache<Path>()
53-
mutating func visit(accessStoragePath: ProjectedValue) {
54-
print(" Storage: \(accessStoragePath.value)")
55-
print(" Path: \"\(accessStoragePath.path)\"")
53+
mutating func rootDef(value: Value, path: SmallProjectionPath) -> WalkResult {
54+
print(" Storage: \(value)")
55+
print(" Path: \"\(path)\"")
56+
return .continueWalk
5657
}
5758
}
5859

SwiftCompilerSources/Sources/Optimizer/Utilities/AccessUtils.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,7 @@ extension Value {
462462
/// %addr = struct_element_addr %base : $X, #X.e
463463
/// store %v to [trivial] %addr : $*Int
464464
/// ```
465-
protocol AccessStoragePathWalker : ValueUseDefWalker where Path == SmallProjectionPath {
466-
mutating func visit(accessStoragePath: ProjectedValue)
467-
}
468-
469-
extension AccessStoragePathWalker {
465+
extension ValueUseDefWalker where Path == SmallProjectionPath {
470466
/// The main entry point.
471467
/// Given an `accessPath` where the access base is a reference (class, tail, box), call
472468
/// the `visit` function for all storage roots with a the corresponding path.
@@ -486,9 +482,4 @@ extension AccessStoragePathWalker {
486482
return false
487483
}
488484
}
489-
490-
mutating func rootDef(value: Value, path: SmallProjectionPath) -> WalkResult {
491-
visit(accessStoragePath: value.at(path))
492-
return .continueWalk
493-
}
494485
}

0 commit comments

Comments
 (0)