|
MLIR 24.0.0git
|
The general data-flow analysis solver. More...
#include "mlir/Analysis/DataFlowFramework.h"
Public Types | |
| using | WorkItem = std::pair<ProgramPoint *, DataFlowAnalysis *> |
| A work item on the solver queue is a program point, child analysis pair. | |
Public Member Functions | |
| DataFlowSolver (const DataFlowConfig &config=DataFlowConfig()) | |
| template<typename AnalysisT, typename... Args> | |
| AnalysisT * | load (Args &&...args) |
| Load an analysis into the solver. Return the analysis instance. | |
| LogicalResult | initializeAndRun (Operation *top, llvm::function_ref< bool(DataFlowAnalysis &)> analysisFilter=nullptr) |
| Initialize analyses starting from the provided top-level operation and run the analysis until fixpoint. | |
| template<typename StateT, typename AnchorT> | |
| const StateT * | lookupState (AnchorT anchor) const |
| Lookup an analysis state for the given lattice anchor. | |
| template<typename AnchorT> | |
| void | eraseState (AnchorT anchor) |
| Erase any analysis state associated with the given lattice anchor. | |
| void | eraseAllStates () |
| Erase all analysis states. | |
| template<typename AnchorT, typename... Args> | |
| AnchorT * | getLatticeAnchor (Args &&...args) |
| Get a uniqued lattice anchor instance. | |
| ProgramPoint * | getProgramPointBefore (Operation *op) |
| Get a uniqued program point instance. | |
| ProgramPoint * | getProgramPointBefore (Block *block) |
| ProgramPoint * | getProgramPointAfter (Operation *op) |
| ProgramPoint * | getProgramPointAfter (Block *block) |
| void | enqueue (WorkItem item) |
| Push a work item onto the worklist, if it is not already there. | |
| template<typename StateT, typename AnchorT> | |
| StateT * | getOrCreateState (AnchorT anchor) |
| Get the state associated with the given lattice anchor. | |
| template<typename StateT> | |
| LatticeAnchor | getLeaderAnchorOrSelf (LatticeAnchor latticeAnchor) const |
| Get leader lattice anchor in equivalence lattice anchor group, return input lattice anchor if input not found in equivalece lattice anchor group. | |
| template<typename StateT, typename AnchorT> | |
| void | unionLatticeAnchors (AnchorT anchor, AnchorT other) |
| Union input anchors under the given state. | |
| template<typename StateT> | |
| bool | isEquivalent (LatticeAnchor lhs, LatticeAnchor rhs) const |
| Return given lattice is equivalent on given state. | |
| void | propagateIfChanged (AnalysisState *state, ChangeResult changed) |
| Propagate an update to an analysis state if it changed by pushing dependent work items to the back of the queue. | |
| const DataFlowConfig & | getConfig () const |
| Get the configuration of the solver. | |
Friends | |
| class | DataFlowAnalysis |
| Allow the base child analysis class to access the internals of the solver. | |
The general data-flow analysis solver.
This class is responsible for orchestrating child data-flow analyses, running the fixed-point iteration algorithm, managing analysis state and lattice anchor memory, and tracking dependencies between analyses, lattice anchor, and analysis states.
Steps to run a data-flow analysis:
Steps to re-run a data-flow analysis when IR changes:
TODO: Optimize the internal implementation of the solver.
Definition at line 325 of file DataFlowFramework.h.
| using mlir::DataFlowSolver::WorkItem = std::pair<ProgramPoint *, DataFlowAnalysis *> |
A work item on the solver queue is a program point, child analysis pair.
Each item is processed by invoking the child analysis at the program point.
Definition at line 411 of file DataFlowFramework.h.
|
inlineexplicit |
Definition at line 327 of file DataFlowFramework.h.
Push a work item onto the worklist, if it is not already there.
Definition at line 413 of file DataFlowFramework.h.
Referenced by mlir::AnalysisState::onUpdate(), mlir::dataflow::AbstractSparseLattice::onUpdate(), and mlir::dataflow::Executable::onUpdate().
|
inline |
Erase all analysis states.
Definition at line 367 of file DataFlowFramework.h.
| void mlir::DataFlowSolver::eraseState | ( | AnchorT | anchor | ) |
Erase any analysis state associated with the given lattice anchor.
Definition at line 571 of file DataFlowFramework.h.
Referenced by mlir::dataflow::maybeReplaceWithConstant().
|
inline |
Get the configuration of the solver.
Definition at line 455 of file DataFlowFramework.h.
|
inline |
Get a uniqued lattice anchor instance.
If one is not present, it is created with the provided arguments.
Definition at line 375 of file DataFlowFramework.h.
| LatticeAnchor mlir::DataFlowSolver::getLeaderAnchorOrSelf | ( | LatticeAnchor | latticeAnchor | ) | const |
Get leader lattice anchor in equivalence lattice anchor group, return input lattice anchor if input not found in equivalece lattice anchor group.
Definition at line 767 of file DataFlowFramework.h.
References mlir::TypeID::get().
Referenced by getOrCreateState(), and lookupState().
| StateT * mlir::DataFlowSolver::getOrCreateState | ( | AnchorT | anchor | ) |
Get the state associated with the given lattice anchor.
If it does not exist, create an uninitialized state.
Definition at line 782 of file DataFlowFramework.h.
References mlir::TypeID::get(), and getLeaderAnchorOrSelf().
Referenced by copyIntegerRange().
|
inline |
Definition at line 403 of file DataFlowFramework.h.
References mlir::Block::end().
|
inline |
Definition at line 394 of file DataFlowFramework.h.
References mlir::Operation::getBlock().
Referenced by mlir::dataflow::AbstractSparseLattice::onUpdate(), and mlir::dataflow::Executable::onUpdate().
|
inline |
Definition at line 389 of file DataFlowFramework.h.
References mlir::Block::begin().
|
inline |
Get a uniqued program point instance.
Definition at line 380 of file DataFlowFramework.h.
References mlir::Operation::getBlock().
Referenced by mlir::dataflow::Executable::onUpdate().
| LogicalResult DataFlowSolver::initializeAndRun | ( | Operation * | top, |
| llvm::function_ref< bool(DataFlowAnalysis &)> | analysisFilter = nullptr ) |
Initialize analyses starting from the provided top-level operation and run the analysis until fixpoint.
An optional analysisFilter predicate restricts which analyses are initialized. When no filter is given every loaded analysis is (re-)initialized. The fixpoint loop always processes all enqueued work items regardless of the filter.
Definition at line 112 of file DataFlowFramework.cpp.
References DATAFLOW_DEBUG, DataFlowAnalysis, mlir::Operation::hasTrait(), and success().
Referenced by mlir::xegpu::runContiguityAnalysis().
| bool mlir::DataFlowSolver::isEquivalent | ( | LatticeAnchor | lhs, |
| LatticeAnchor | rhs ) const |
Return given lattice is equivalent on given state.
Definition at line 798 of file DataFlowFramework.h.
References mlir::TypeID::get().
| AnalysisT * mlir::DataFlowSolver::load | ( | Args &&... | args | ) |
Load an analysis into the solver. Return the analysis instance.
Definition at line 756 of file DataFlowFramework.h.
References mlir::get(), and mlir::TypeID::get().
Referenced by mlir::dataflow::loadBaselineAnalyses(), and mlir::xegpu::runContiguityAnalysis().
|
inline |
Lookup an analysis state for the given lattice anchor.
Returns null if one does not exist.
Definition at line 350 of file DataFlowFramework.h.
References mlir::TypeID::get(), and getLeaderAnchorOrSelf().
Referenced by copyIntegerRange(), getMaybeConstantValue(), mlir::dataflow::maybeReplaceWithConstant(), replaceWithConstant(), and mlir::dataflow::staticallyNonNegative().
| void DataFlowSolver::propagateIfChanged | ( | AnalysisState * | state, |
| ChangeResult | changed ) |
Propagate an update to an analysis state if it changed by pushing dependent work items to the back of the queue.
This should only be used when DataFlowSolver is running. Otherwise, the solver won't process the work items.
Definition at line 160 of file DataFlowFramework.cpp.
References mlir::AnalysisState::anchor, mlir::Change, DATAFLOW_DEBUG, and mlir::AnalysisState::onUpdate().
| void mlir::DataFlowSolver::unionLatticeAnchors | ( | AnchorT | anchor, |
| AnchorT | other ) |
Union input anchors under the given state.
Definition at line 810 of file DataFlowFramework.h.
References mlir::TypeID::get().
|
friend |
Allow the base child analysis class to access the internals of the solver.
Definition at line 491 of file DataFlowFramework.h.
References DataFlowAnalysis.
Referenced by DataFlowAnalysis, and initializeAndRun().