MLIR  19.0.0git
Public Types | Public Member Functions | Friends | List of all members
mlir::DataFlowSolver Class Reference

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 PointT >
const StateT * lookupState (PointT point) const
 Lookup an analysis state for the given program point. More...
 
template<typename PointT >
void eraseState (PointT point)
 Erase any analysis state associated with the given program point. More...
 
template<typename PointT , typename... Args>
PointT * getProgramPoint (Args &&...args)
 Get a uniqued program point instance. More...
 
void enqueue (WorkItem item)
 Push a work item onto the worklist. More...
 
template<typename StateT , typename PointT >
StateT * getOrCreateState (PointT point)
 Get the state associated with the given program point. 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 DataFlowConfiggetConfig () 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...
 

Detailed Description

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 program point memory, and tracking dependencies between analyses, program points, and analysis states.

Steps to run a data-flow analysis:

  1. Load and initialize children analyses. Children analyses are instantiated in the solver and initialized, building their dependency relations.
  2. Configure and run the analysis. The solver invokes the children analyses according to their dependency relations until a fixed point is reached.
  3. Query analysis state results from the solver.

TODO: Optimize the internal implementation of the solver.

Definition at line 222 of file DataFlowFramework.h.

Member Typedef Documentation

◆ WorkItem

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 266 of file DataFlowFramework.h.

Constructor & Destructor Documentation

◆ DataFlowSolver()

mlir::DataFlowSolver::DataFlowSolver ( const DataFlowConfig config = DataFlowConfig())
inlineexplicit

Definition at line 224 of file DataFlowFramework.h.

Member Function Documentation

◆ enqueue()

void mlir::DataFlowSolver::enqueue ( WorkItem  item)
inline

◆ eraseState()

template<typename PointT >
void mlir::DataFlowSolver::eraseState ( PointT  point)
inline

Erase any analysis state associated with the given program point.

Definition at line 247 of file DataFlowFramework.h.

◆ getConfig()

const DataFlowConfig& mlir::DataFlowSolver::getConfig ( ) const
inline

Get the configuration of the solver.

Definition at line 280 of file DataFlowFramework.h.

Referenced by mlir::DataFlowAnalysis::getSolverConfig().

◆ getOrCreateState()

template<typename StateT , typename PointT >
StateT * mlir::DataFlowSolver::getOrCreateState ( PointT  point)

Get the state associated with the given program point.

If it does not exist, create an uninitialized state.

Definition at line 498 of file DataFlowFramework.h.

Referenced by mlir::DataFlowAnalysis::getOrCreate(), and mlir::dataflow::IntegerValueRangeLattice::onUpdate().

◆ getProgramPoint()

template<typename PointT , typename... Args>
PointT* mlir::DataFlowSolver::getProgramPoint ( Args &&...  args)
inline

Get a uniqued program point instance.

If one is not present, it is created with the provided arguments.

Definition at line 259 of file DataFlowFramework.h.

References mlir::get().

Referenced by mlir::DataFlowAnalysis::getProgramPoint().

◆ initializeAndRun()

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 88 of file DataFlowFramework.cpp.

References DATAFLOW_DEBUG, mlir::failed(), mlir::failure(), and mlir::success().

◆ load()

template<typename AnalysisT , typename... Args>
AnalysisT * mlir::DataFlowSolver::load ( Args &&...  args)

Load an analysis into the solver. Return the analysis instance.

Definition at line 489 of file DataFlowFramework.h.

◆ lookupState()

template<typename StateT , typename PointT >
const StateT* mlir::DataFlowSolver::lookupState ( PointT  point) const
inline

Lookup an analysis state for the given program point.

Returns null if one does not exist.

Definition at line 238 of file DataFlowFramework.h.

Referenced by mlir::dataflow::RunLivenessAnalysis::getLiveness(), replaceWithConstant(), and staticallyNonNegative().

◆ propagateIfChanged()

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.

Definition at line 117 of file DataFlowFramework.cpp.

Referenced by mlir::dataflow::IntegerValueRangeLattice::onUpdate().

Friends And Related Function Documentation

◆ DataFlowAnalysis

friend class DataFlowAnalysis
friend

Allow the base child analysis class to access the internals of the solver.

Definition at line 304 of file DataFlowFramework.h.


The documentation for this class was generated from the following files: