Skip to content

Commit 50a7e25

Browse files
author
Anxhelo Xhebraj
committed
Swift Optimizer: add projection path DefUse/UseDef walkers
Introduces a set of protocols useful to perform def-use and use-def traversals to find uses and definitions of values. This logic was originally baked into `EscapeInfo` directly. Here we extract it into general utilities, namely: - `ValueDefUseWalker`: visit uses of a value walking down value-value projections/constructions. - `AddressDefUseWalker`: visit uses of an address walking down addr-addr projections/constructions. - `ValueUseDefWalker`: visit definitions of a value walking up value-value projections/constructions. - `AddressUseDefWalker`: visit definitions of an address walking up addr-addr projections/constructions. These utilities can then be used in other passes or to create new utilities by composing them. For example to find a definition passing through both address projections and value extractions, it's enough to implement a visitor conforming to both `AddressUseDefWalker` and `ValueUseDefWalker`.
1 parent 36476e4 commit 50a7e25

File tree

2 files changed

+543
-1
lines changed

2 files changed

+543
-1
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88

99
swift_compiler_sources(Optimizer
1010
EscapeInfo.swift
11-
OptUtils.swift)
11+
OptUtils.swift
12+
WalkUtils.swift
13+
)

0 commit comments

Comments
 (0)