15#ifndef MLIR_ANALYSIS_DATAFLOW_DEADCODEANALYSIS_H
16#define MLIR_ANALYSIS_DATAFLOW_DEADCODEANALYSIS_H
21#include "llvm/ADT/SmallPtrSet.h"
27class CallableOpInterface;
28class BranchOpInterface;
29class RegionBranchOpInterface;
30class RegionBranchTerminatorOpInterface;
60 subscribers.insert(analysis);
112 return knownPredecessors.getArrayRef();
117 return successorInputs.lookup(predecessor);
129 bool allKnown =
true;
192 void initializeSymbolCallables(
Operation *top);
195 LogicalResult initializeRecursively(
Operation *op);
198 void visitCallOperation(CallOpInterface call);
202 void visitBranchOperation(BranchOpInterface branch);
207 void visitRegionBranchEdges(RegionBranchOpInterface regionBranchOp,
214 void visitRegionBranchOperation(RegionBranchOpInterface branch);
219 void visitRegionTerminator(
Operation *op, RegionBranchOpInterface branch);
223 void visitCallableTerminator(
Operation *op, CallableOpInterface callable);
233 std::optional<SmallVector<Attribute>> getOperandValues(
Operation *op);
245 bool hasSymbolTable =
false;
AnalysisState(LatticeAnchor anchor)
Create the analysis state on the given lattice anchor.
Block represents an ordered list of Operations.
Base class for all data-flow analyses.
DataFlowAnalysis(DataFlowSolver &solver)
Create an analysis with a reference to the parent solver.
friend class DataFlowSolver
Allow the data-flow solver to access the internals of this class.
The general data-flow analysis solver.
GenericLatticeAnchorBase< CFGEdge, std::pair< Block *, Block * > > Base
const std::pair< Block *, Block * > & getValue() const
GenericLatticeAnchorBase(ValueT &&value)
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.
Location getLoc() const override
Get a fused location of both blocks.
Block * getTo() const
Get the target block.
Block * getFrom() const
Get the block from which the edge originates.
void print(raw_ostream &os) const override
Print the blocks between the control-flow edge.
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.
AnalysisState(LatticeAnchor anchor)
Create the analysis state on the given lattice anchor.
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.
ArrayRef< Operation * > getKnownPredecessors() const
Get the known predecessors.
bool allPredecessorsKnown() const
Returns true if all predecessors are known.
AnalysisState(LatticeAnchor anchor)
Create the analysis state on the given lattice anchor.
void print(raw_ostream &os) const override
Print the known predecessors.
ChangeResult join(Operation *predecessor)
Add a known predecessor.
Include the generated interface declarations.
ChangeResult
A result type used to indicate if a change happened.
llvm::SetVector< T, Vector, Set, N > SetVector
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap
Program point represents a specific location in the execution of a program.