MLIR 22.0.0git
mlir::Liveness Class Reference

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.
OperationgetOperation () const
 Returns the operation this analysis was constructed from.
OperationListT resolveLiveness (Value value) const
 Gets liveness info (if any) for the given value.
const LivenessBlockInfogetLiveness (Block *block) const
 Gets liveness info (if any) for the block.
const ValueSetTgetLiveIn (Block *block) const
 Returns a reference to a set containing live-in values (unordered).
const ValueSetTgetLiveOut (Block *block) const
 Returns a reference to a set containing live-out values (unordered).
bool isDeadAfter (Value value, Operation *operation) const
 Returns true if value is not live after operation.
void dump () const
 Dumps the liveness information in a human readable format.
void print (raw_ostream &os) const
 Dumps the liveness information to the given stream.

Detailed Description

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.

Member Typedef Documentation

◆ BlockMapT

Definition at line 50 of file Liveness.h.

◆ OperationListT

using mlir::Liveness::OperationListT = std::vector<Operation *>

Definition at line 49 of file Liveness.h.

◆ ValueSetT

Definition at line 51 of file Liveness.h.

Constructor & Destructor Documentation

◆ Liveness()

Liveness::Liveness ( Operation * op)

Creates a new Liveness analysis that computes liveness information for all associated regions.

Definition at line 158 of file Liveness.cpp.

Member Function Documentation

◆ dump()

void Liveness::dump ( ) const

Dumps the liveness information in a human readable format.

Definition at line 257 of file Liveness.cpp.

References print().

◆ getLiveIn()

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 231 of file Liveness.cpp.

References getLiveness(), and mlir::LivenessBlockInfo::in().

◆ getLiveness()

const LivenessBlockInfo * Liveness::getLiveness ( Block * block) const

Gets liveness info (if any) for the block.

Definition at line 225 of file Liveness.cpp.

References nullptr.

Referenced by getLiveIn(), getLiveOut(), mlir::bufferization::BufferPlacementAllocs::getStartOperation(), isDeadAfter(), print(), and resolveLiveness().

◆ getLiveOut()

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 236 of file Liveness.cpp.

References getLiveness(), and mlir::LivenessBlockInfo::out().

◆ getOperation()

Operation * mlir::Liveness::getOperation ( ) const
inline

Returns the operation this analysis was constructed from.

Definition at line 59 of file Liveness.h.

◆ isDeadAfter()

bool Liveness::isDeadAfter ( Value value,
Operation * operation ) const

Returns true if value is not live after operation.

Definition at line 241 of file Liveness.cpp.

References mlir::LivenessBlockInfo::getEndOperation(), getLiveness(), mlir::Operation::isBeforeInBlock(), and mlir::LivenessBlockInfo::isLiveOut().

◆ print()

void Liveness::print ( raw_ostream & os) const

Dumps the liveness information to the given stream.

Definition at line 260 of file Liveness.cpp.

References getLiveness(), mlir::Operation::getNumResults(), mlir::Operation::getResults(), mlir::PreOrder, mlir::Operation::print(), resolveLiveness(), and result.

Referenced by dump().

◆ resolveLiveness()

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 178 of file Liveness.cpp.

References mlir::Value::getDefiningOp(), mlir::LivenessBlockInfo::getEndOperation(), getLiveness(), mlir::LivenessBlockInfo::getStartOperation(), mlir::Block::getSuccessors(), mlir::Value::getUses(), and result.

Referenced by print().


The documentation for this class was generated from the following files: