31 os << (
isLive ?
"live" :
"not live");
41 const auto *otherLiveness =
reinterpret_cast<const Liveness *
>(&other);
76 for (
auto *operand : operands)
81 bool foundLiveResult =
false;
83 if (r->isLive && !foundLiveResult) {
88 foundLiveResult =
true;
99 assert((isa<RegionBranchOpInterface>(op) || isa<BranchOpInterface>(op) ||
100 isa<RegionBranchTerminatorOpInterface>(op)) &&
101 "expected the op to be `RegionBranchOpInterface`, "
102 "`BranchOpInterface` or `RegionBranchTerminatorOpInterface`");
113 if (isa<RegionBranchOpInterface>(op)) {
118 for (
Block &block : region)
119 blocks.push_back(&block);
121 }
else if (isa<BranchOpInterface>(op)) {
132 assert(isa<RegionBranchOpInterface>(parentOp) &&
133 "expected parent op to implement `RegionBranchOpInterface`");
135 for (
Block &block : region)
136 blocks.push_back(&block);
139 bool foundMemoryEffectingOp =
false;
140 for (
Block *block : blocks) {
141 if (foundMemoryEffectingOp)
147 foundMemoryEffectingOp =
true;
167 if (!isa<RegionBranchTerminatorOpInterface>(op))
179 assert(isa<CallOpInterface>(operand.
getOwner()) &&
180 "expected the op to implement `CallOpInterface`");
Block represents an ordered list of Operations.
void propagateIfChanged(AnalysisState *state, ChangeResult changed)
Propagate an update to a state if it changed.
void addDependency(AnalysisState *state, ProgramPoint point)
Create a dependency between the given analysis state and program point on this analysis.
const StateT * lookupState(PointT point) const
Lookup an analysis state for the given program point.
AnalysisT * load(Args &&...args)
Load an analysis into the solver. Return the analysis instance.
LogicalResult initializeAndRun(Operation *top)
Initialize the children analyses starting from the provided top-level operation and run the analysis ...
IRValueT get() const
Return the current value being used by this operand.
This class represents an operand of an operation.
Operation is the basic unit of execution within MLIR.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
MutableArrayRef< Region > getRegions()
Returns the regions held by this operation.
SuccessorRange getSuccessors()
result_range getResults()
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class represents a collection of SymbolTables.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
void meet(AbstractSparseLattice *lhs, const AbstractSparseLattice &rhs)
Join the lattice element and propagate and update if it changed.
This class represents an abstract lattice.
Dead code analysis analyzes control-flow, as understood by RegionBranchOpInterface and BranchOpInterf...
An analysis that, by going backwards along the dataflow graph, annotates each value with a boolean st...
void visitOperation(Operation *op, ArrayRef< Liveness * > operands, ArrayRef< const Liveness * > results) override
For every value, liveness analysis determines whether or not it is "live".
void setToExitState(Liveness *lattice) override
Set the given lattice element(s) at control flow exit point(s).
void visitBranchOperand(OpOperand &operand) override
void visitCallOperand(OpOperand &operand) override
Liveness * getLatticeElement(Value value) override
Get the lattice element for a value.
This analysis implements sparse constant propagation, which attempts to determine constant-valued res...
Operation * getOwner() const
Return the owner of this operand.
Include the generated interface declarations.
ChangeResult
A result type used to indicate if a change happened.
bool isMemoryEffectFree(Operation *op)
Returns true if the given operation is free of memory effects.
This lattice represents, for a given value, whether or not it is "live".
void print(raw_ostream &os) const override
Print the contents of the analysis state.
ChangeResult meet(const AbstractSparseLattice &other) override
Meet (intersect) the information in this lattice with 'rhs'.
RunLivenessAnalysis(Operation *op)
const Liveness * getLiveness(Value val)