MLIR
21.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. More... | |
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. More... | |
LogicalResult | initializeAndRun (Operation *top) |
Initialize the children analyses starting from the provided top-level operation and run the analysis until fixpoint. More... | |
template<typename StateT , typename AnchorT > | |
const StateT * | lookupState (AnchorT anchor) const |
Lookup an analysis state for the given lattice anchor. More... | |
template<typename AnchorT > | |
void | eraseState (AnchorT anchor) |
Erase any analysis state associated with the given lattice anchor. More... | |
void | eraseAllStates () |
template<typename AnchorT , typename... Args> | |
AnchorT * | getLatticeAnchor (Args &&...args) |
Get a uniqued lattice anchor instance. More... | |
ProgramPoint * | getProgramPointBefore (Operation *op) |
Get a uniqued program point instance. More... | |
ProgramPoint * | getProgramPointBefore (Block *block) |
ProgramPoint * | getProgramPointAfter (Operation *op) |
ProgramPoint * | getProgramPointAfter (Block *block) |
void | enqueue (WorkItem item) |
Push a work item onto the worklist. More... | |
template<typename StateT , typename AnchorT > | |
StateT * | getOrCreateState (AnchorT anchor) |
Get the state associated with the given lattice anchor. More... | |
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. More... | |
const DataFlowConfig & | getConfig () const |
Get the configuration of the solver. More... | |
Friends | |
class | DataFlowAnalysis |
Allow the base child analysis class to access the internals of the solver. More... | |
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:
initializeAndRun
.TODO: Optimize the internal implementation of the solver.
Definition at line 316 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 393 of file DataFlowFramework.h.
|
inlineexplicit |
Definition at line 318 of file DataFlowFramework.h.
References mlir::StorageUniquer::registerParametricStorageType().
|
inline |
Push a work item onto the worklist.
Definition at line 395 of file DataFlowFramework.h.
Referenced by mlir::AnalysisState::onUpdate(), mlir::dataflow::Executable::onUpdate(), and mlir::dataflow::AbstractSparseLattice::onUpdate().
|
inline |
Definition at line 352 of file DataFlowFramework.h.
|
inline |
Erase any analysis state associated with the given lattice anchor.
Definition at line 346 of file DataFlowFramework.h.
|
inline |
Get the configuration of the solver.
Definition at line 409 of file DataFlowFramework.h.
Referenced by mlir::DataFlowAnalysis::getSolverConfig().
|
inline |
Get a uniqued lattice anchor instance.
If one is not present, it is created with the provided arguments.
Definition at line 357 of file DataFlowFramework.h.
References mlir::get().
Referenced by mlir::DataFlowAnalysis::getLatticeAnchor().
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 648 of file DataFlowFramework.h.
Referenced by copyIntegerRange(), mlir::DataFlowAnalysis::getOrCreate(), and mlir::dataflow::IntegerValueRangeLattice::onUpdate().
|
inline |
Definition at line 385 of file DataFlowFramework.h.
References mlir::Block::end(), and mlir::StorageUniquer::get().
|
inline |
Definition at line 376 of file DataFlowFramework.h.
References mlir::StorageUniquer::get(), and mlir::Operation::getBlock().
Referenced by mlir::DataFlowAnalysis::getProgramPointAfter(), mlir::dataflow::Executable::onUpdate(), and mlir::dataflow::AbstractSparseLattice::onUpdate().
|
inline |
Definition at line 371 of file DataFlowFramework.h.
References mlir::Block::begin(), and mlir::StorageUniquer::get().
|
inline |
Get a uniqued program point instance.
Definition at line 362 of file DataFlowFramework.h.
References mlir::StorageUniquer::get(), and mlir::Operation::getBlock().
Referenced by mlir::DataFlowAnalysis::getProgramPointBefore(), and mlir::dataflow::Executable::onUpdate().
LogicalResult DataFlowSolver::initializeAndRun | ( | Operation * | top | ) |
Initialize the children analyses starting from the provided top-level operation and run the analysis until fixpoint.
Definition at line 107 of file DataFlowFramework.cpp.
References DATAFLOW_DEBUG.
Referenced by mlir::dataflow::RunLivenessAnalysis::RunLivenessAnalysis().
AnalysisT * mlir::DataFlowSolver::load | ( | Args &&... | args | ) |
Load an analysis into the solver. Return the analysis instance.
Definition at line 639 of file DataFlowFramework.h.
Referenced by mlir::dataflow::RunLivenessAnalysis::RunLivenessAnalysis().
|
inline |
Lookup an analysis state for the given lattice anchor.
Returns null if one does not exist.
Definition at line 334 of file DataFlowFramework.h.
Referenced by copyIntegerRange(), mlir::dataflow::RunLivenessAnalysis::getLiveness(), getMaybeConstantValue(), 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 136 of file DataFlowFramework.cpp.
Referenced by mlir::dataflow::IntegerValueRangeLattice::onUpdate().
|
friend |
Allow the base child analysis class to access the internals of the solver.
Definition at line 437 of file DataFlowFramework.h.