15 #ifndef MLIR_ANALYSIS_DATAFLOW_DEADCODEANALYSIS_H
16 #define MLIR_ANALYSIS_DATAFLOW_DEADCODEANALYSIS_H
20 #include "llvm/ADT/SmallPtrSet.h"
25 class CallOpInterface;
26 class CallableOpInterface;
27 class BranchOpInterface;
28 class RegionBranchOpInterface;
29 class RegionBranchTerminatorOpInterface;
50 void print(raw_ostream &os)
const override;
59 subscribers.insert(analysis);
98 void print(raw_ostream &os)
const override;
111 return knownPredecessors.getArrayRef();
116 return successorInputs.lookup(predecessor);
128 bool allKnown =
true;
156 void print(raw_ostream &os)
const override;
191 void initializeSymbolCallables(
Operation *top);
194 LogicalResult initializeRecursively(
Operation *op);
197 void visitCallOperation(CallOpInterface call);
201 void visitBranchOperation(BranchOpInterface branch);
206 void visitRegionBranchOperation(RegionBranchOpInterface branch);
211 void visitRegionTerminator(
Operation *op, RegionBranchOpInterface branch);
215 void visitCallableTerminator(
Operation *op, CallableOpInterface callable);
225 std::optional<SmallVector<Attribute>> getOperandValues(
Operation *op);
Base class for generic analysis states.
AnalysisState(LatticeAnchor anchor)
Create the analysis state at the given lattice anchor.
Block represents an ordered list of Operations.
Base class for all data-flow analyses.
The general data-flow analysis solver.
Base class for generic lattice anchor based on a concrete lattice anchor type and a content key.
GenericLatticeAnchorBase< CFGEdge, std::pair< Block *, Block * > > Base
Alias for the base class.
const std::pair< Block *, Block * > & getValue() const
Get the contents of the lattice anchor.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation is the basic unit of execution within MLIR.
This class represents a collection of SymbolTables.
This class provides an abstraction over the different types of ranges over Values.
This lattice anchor represents a control-flow edge between a block and one of its successors.
Block * getTo() const
Get the target block.
Block * getFrom() const
Get the block from which the edge originates.
Location getLoc() const override
Get a fused location of both blocks.
void print(raw_ostream &os) const override
Print the blocks between the control-flow edge.
Dead code analysis analyzes control-flow, as understood by RegionBranchOpInterface and BranchOpInterf...
DeadCodeAnalysis(DataFlowSolver &solver)
LogicalResult visit(ProgramPoint point) override
Visit an operation with control-flow semantics and deduce which of its successors are live.
LogicalResult initialize(Operation *top) override
Initialize the analysis by visiting every operation with potential control-flow semantics.
This is a simple analysis state that represents whether the associated lattice anchor (either a block...
bool isLive() const
Get whether the lattice anchor is live.
void onUpdate(DataFlowSolver *solver) const override
When the state of the lattice anchor is changed to live, re-invoke subscribed analyses on the operati...
ChangeResult setToLive()
Set the state of the lattice anchor to live.
void print(raw_ostream &os) const override
Print the liveness.
void blockContentSubscribe(DataFlowAnalysis *analysis)
Subscribe an analysis to changes to the liveness.
This analysis state represents a set of live control-flow "predecessors" of a program point (either a...
ChangeResult setHasUnknownPredecessors()
Indicate that there are potentially unknown predecessors.
ValueRange getSuccessorInputs(Operation *predecessor) const
Get the successor inputs from a predecessor.
bool allPredecessorsKnown() const
Returns true if all predecessors are known.
void print(raw_ostream &os) const override
Print the known predecessors.
ChangeResult join(Operation *predecessor)
Add a known predecessor.
ArrayRef< Operation * > getKnownPredecessors() const
Get the known predecessors.
Include the generated interface declarations.
ChangeResult
A result type used to indicate if a change happened.
Program point represents a specific location in the execution of a program.