MLIR
20.0.0git
|
Dead code analysis analyzes control-flow, as understood by RegionBranchOpInterface
and BranchOpInterface
, and the callgraph, as understood by CallableOpInterface
and CallOpInterface
.
More...
#include "mlir/Analysis/DataFlow/DeadCodeAnalysis.h"
Public Member Functions | |
DeadCodeAnalysis (DataFlowSolver &solver) | |
LogicalResult | initialize (Operation *top) override |
Initialize the analysis by visiting every operation with potential control-flow semantics. More... | |
LogicalResult | visit (ProgramPoint *point) override |
Visit an operation with control-flow semantics and deduce which of its successors are live. More... | |
Public Member Functions inherited from mlir::DataFlowAnalysis | |
virtual | ~DataFlowAnalysis () |
DataFlowAnalysis (DataFlowSolver &solver) | |
Create an analysis with a reference to the parent solver. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from mlir::DataFlowAnalysis | |
void | addDependency (AnalysisState *state, ProgramPoint *point) |
Create a dependency between the given analysis state and lattice anchor on this analysis. More... | |
void | propagateIfChanged (AnalysisState *state, ChangeResult changed) |
Propagate an update to a state if it changed. More... | |
template<typename AnchorT > | |
void | registerAnchorKind () |
Register a custom lattice anchor class. More... | |
template<typename AnchorT , typename... Args> | |
AnchorT * | getLatticeAnchor (Args &&...args) |
Get or create a custom lattice anchor. More... | |
template<typename StateT , typename AnchorT > | |
StateT * | getOrCreate (AnchorT anchor) |
Get the analysis state associated with the lattice anchor. More... | |
template<typename StateT , typename AnchorT > | |
const StateT * | getOrCreateFor (ProgramPoint *dependent, AnchorT anchor) |
Get a read-only analysis state for the given point and create a dependency on dependent . More... | |
ProgramPoint * | getProgramPointBefore (Operation *op) |
Get a uniqued program point instance. More... | |
ProgramPoint * | getProgramPointBefore (Block *block) |
ProgramPoint * | getProgramPointAfter (Operation *op) |
ProgramPoint * | getProgramPointAfter (Block *block) |
const DataFlowConfig & | getSolverConfig () const |
Return the configuration of the solver used for this analysis. More... | |
Dead code analysis analyzes control-flow, as understood by RegionBranchOpInterface
and BranchOpInterface
, and the callgraph, as understood by CallableOpInterface
and CallOpInterface
.
This analysis uses known constant values of operands to determine the liveness of each block and each edge between a block and its predecessors. For region control-flow, this analysis determines the predecessor operations for region entry blocks and region control-flow operations. For the callgraph, this analysis determines the callsites and live returns of every function.
Definition at line 175 of file DeadCodeAnalysis.h.
|
explicit |
Definition at line 119 of file DeadCodeAnalysis.cpp.
|
overridevirtual |
Initialize the analysis by visiting every operation with potential control-flow semantics.
Implements mlir::DataFlowAnalysis.
Definition at line 124 of file DeadCodeAnalysis.cpp.
References mlir::Operation::getRegions().
|
overridevirtual |
Visit an operation with control-flow semantics and deduce which of its successors are live.
Implements mlir::DataFlowAnalysis.
Definition at line 246 of file DeadCodeAnalysis.cpp.
References mlir::Operation::getBlock(), mlir::Operation::getNumRegions(), mlir::Operation::getNumSuccessors(), mlir::Operation::getParentOp(), mlir::ProgramPoint::getPrevOp(), mlir::DataFlowAnalysis::getProgramPointAfter(), mlir::DataFlowAnalysis::getProgramPointBefore(), mlir::Operation::getSuccessors(), mlir::ProgramPoint::isBlockStart(), and isRegionOrCallableReturn().