31 os << (
isLive ?
"live" :
"not live");
41 const auto *otherLiveness =
reinterpret_cast<const Liveness *
>(&other);
78 for (
auto *operand : operands)
83 bool foundLiveResult =
false;
85 if (r->isLive && !foundLiveResult) {
90 foundLiveResult =
true;
102 assert((isa<RegionBranchOpInterface>(op) || isa<BranchOpInterface>(op) ||
103 isa<RegionBranchTerminatorOpInterface>(op)) &&
104 "expected the op to be `RegionBranchOpInterface`, "
105 "`BranchOpInterface` or `RegionBranchTerminatorOpInterface`");
115 bool mayLive =
false;
117 if (isa<RegionBranchOpInterface>(op)) {
137 for (
Block &block : region)
138 blocks.push_back(&block);
141 }
else if (isa<BranchOpInterface>(op)) {
150 assert(isa<RegionBranchOpInterface>(parentOp) &&
151 "expected parent op to implement `RegionBranchOpInterface`");
172 for (
Block &block : region)
173 blocks.push_back(&block);
177 for (
Block *block : blocks) {
207 if (!isa<RegionBranchTerminatorOpInterface>(op))
213 (void)
visitOperation(parentOp, operandLiveness, parentResultsLiveness);
219 assert(isa<CallOpInterface>(operand.
getOwner()) &&
220 "expected the op to implement `CallOpInterface`");
Block represents an ordered list of Operations.
void addDependency(AnalysisState *state, ProgramPoint *point)
Create a dependency between the given analysis state and lattice anchor on this analysis.
void propagateIfChanged(AnalysisState *state, ChangeResult changed)
Propagate an update to a state if it changed.
ProgramPoint * getProgramPointAfter(Operation *op)
const StateT * lookupState(AnchorT anchor) const
Lookup an analysis state for the given lattice anchor.
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.
result_range getResults()
unsigned getNumResults()
Return the number of results held by this operation.
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 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
LogicalResult visitOperation(Operation *op, ArrayRef< Liveness * > operands, ArrayRef< const Liveness * > results) override
For every value, liveness analysis determines whether or not it is "live".
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)