MLIR
20.0.0git
|
Represents an analysis for computing liveness information from a given top-level operation. More...
#include "mlir/Analysis/Liveness.h"
Public Types | |
using | OperationListT = std::vector< Operation * > |
using | BlockMapT = DenseMap< Block *, LivenessBlockInfo > |
using | ValueSetT = SmallPtrSet< Value, 16 > |
Public Member Functions | |
Liveness (Operation *op) | |
Creates a new Liveness analysis that computes liveness information for all associated regions. More... | |
Operation * | getOperation () const |
Returns the operation this analysis was constructed from. More... | |
OperationListT | resolveLiveness (Value value) const |
Gets liveness info (if any) for the given value. More... | |
const LivenessBlockInfo * | getLiveness (Block *block) const |
Gets liveness info (if any) for the block. More... | |
const ValueSetT & | getLiveIn (Block *block) const |
Returns a reference to a set containing live-in values (unordered). More... | |
const ValueSetT & | getLiveOut (Block *block) const |
Returns a reference to a set containing live-out values (unordered). More... | |
bool | isDeadAfter (Value value, Operation *operation) const |
Returns true if value is not live after operation . More... | |
void | dump () const |
Dumps the liveness information in a human readable format. More... | |
void | print (raw_ostream &os) const |
Dumps the liveness information to the given stream. More... | |
Represents an analysis for computing liveness information from a given top-level operation.
The analysis iterates over all associated regions that are attached to the given top-level operation. It computes liveness information for every value and block that are included in the mentioned regions. It relies on a fixpoint iteration to compute all live-in and live-out values of all included blocks. Sample usage: Liveness liveness(topLevelOp); auto &allInValues = liveness.getLiveIn(block); auto &allOutValues = liveness.getLiveOut(block); auto allOperationsInWhichValueIsLive = liveness.resolveLiveness(value); bool isDeafAfter = liveness.isDeadAfter(value, operation);
Definition at line 47 of file Liveness.h.
using mlir::Liveness::BlockMapT = DenseMap<Block *, LivenessBlockInfo> |
Definition at line 50 of file Liveness.h.
using mlir::Liveness::OperationListT = std::vector<Operation *> |
Definition at line 49 of file Liveness.h.
using mlir::Liveness::ValueSetT = SmallPtrSet<Value, 16> |
Definition at line 51 of file Liveness.h.
Liveness::Liveness | ( | Operation * | op | ) |
Creates a new Liveness analysis that computes liveness information for all associated regions.
Definition at line 161 of file Liveness.cpp.
void Liveness::dump | ( | ) | const |
Dumps the liveness information in a human readable format.
Definition at line 261 of file Liveness.cpp.
References print().
const Liveness::ValueSetT & Liveness::getLiveIn | ( | Block * | block | ) | const |
Returns a reference to a set containing live-in values (unordered).
Returns a reference to a set containing live-in values.
Definition at line 235 of file Liveness.cpp.
References getLiveness(), and mlir::LivenessBlockInfo::in().
Referenced by mlir::bufferization::DeallocationState::getLiveMemrefsIn(), and mlir::bufferization::DeallocationState::getMemrefsToRetain().
const LivenessBlockInfo * Liveness::getLiveness | ( | Block * | block | ) | const |
Gets liveness info (if any) for the block.
Definition at line 229 of file Liveness.cpp.
Referenced by getLiveIn(), getLiveOut(), mlir::bufferization::BufferPlacementAllocs::getStartOperation(), isDeadAfter(), and resolveLiveness().
const Liveness::ValueSetT & Liveness::getLiveOut | ( | Block * | block | ) | const |
Returns a reference to a set containing live-out values (unordered).
Returns a reference to a set containing live-out values.
Definition at line 240 of file Liveness.cpp.
References getLiveness(), and mlir::LivenessBlockInfo::out().
Referenced by mlir::bufferization::DeallocationState::getMemrefsToRetain().
|
inline |
Returns the operation this analysis was constructed from.
Definition at line 59 of file Liveness.h.
Returns true if value
is not live after operation
.
Definition at line 245 of file Liveness.cpp.
References mlir::Operation::getBlock(), mlir::LivenessBlockInfo::getEndOperation(), getLiveness(), mlir::Operation::isBeforeInBlock(), and mlir::LivenessBlockInfo::isLiveOut().
void Liveness::print | ( | raw_ostream & | os | ) | const |
Dumps the liveness information to the given stream.
Definition at line 264 of file Liveness.cpp.
References mlir::Operation::getResults(), mlir::PreOrder, and mlir::Operation::walk().
Referenced by dump().
Liveness::OperationListT Liveness::resolveLiveness | ( | Value | value | ) | const |
Gets liveness info (if any) for the given value.
This includes all operations in which the given value is live. Note that the operations in this list are not ordered and the current implementation is computationally expensive (as it iterates over all blocks in which the given value is live).
Definition at line 181 of file Liveness.cpp.
References mlir::Value::getDefiningOp(), mlir::LivenessBlockInfo::getEndOperation(), getLiveness(), mlir::LivenessBlockInfo::getStartOperation(), mlir::Block::getSuccessors(), and mlir::Value::getUses().