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;
100 assert((isa<RegionBranchOpInterface>(op) || isa<BranchOpInterface>(op) ||
101 isa<RegionBranchTerminatorOpInterface>(op)) &&
102 "expected the op to be `RegionBranchOpInterface`, "
103 "`BranchOpInterface` or `RegionBranchTerminatorOpInterface`");
114 if (isa<RegionBranchOpInterface>(op)) {
119 for (
Block &block : region)
120 blocks.push_back(&block);
122 }
else if (isa<BranchOpInterface>(op)) {
133 assert(isa<RegionBranchOpInterface>(parentOp) &&
134 "expected parent op to implement `RegionBranchOpInterface`");
136 for (
Block &block : region)
137 blocks.push_back(&block);
140 bool foundMemoryEffectingOp =
false;
141 for (
Block *block : blocks) {
142 if (foundMemoryEffectingOp)
148 foundMemoryEffectingOp =
true;
168 if (!isa<RegionBranchTerminatorOpInterface>(op))
174 (void)
visitOperation(parentOp, operandLiveness, parentResultsLiveness);
180 assert(isa<CallOpInterface>(operand.
getOwner()) &&
181 "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.
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 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)