MLIR  19.0.0git
Public Types | Public Member Functions | List of all members
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. More...
 
OperationgetOperation () 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 LivenessBlockInfogetLiveness (Block *block) const
 Gets liveness info (if any) for the block. More...
 
const ValueSetTgetLiveIn (Block *block) const
 Returns a reference to a set containing live-in values (unordered). More...
 
const ValueSetTgetLiveOut (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...
 

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 157 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().

Referenced by mlir::bufferization::DeallocationState::getLiveMemrefsIn(), and mlir::bufferization::DeallocationState::getMemrefsToRetain().

◆ getLiveness()

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

Gets liveness info (if any) for the block.

Definition at line 225 of file Liveness.cpp.

Referenced by getLiveIn(), getLiveOut(), mlir::bufferization::BufferPlacementAllocs::getStartOperation(), isDeadAfter(), 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().

Referenced by mlir::bufferization::DeallocationState::getMemrefsToRetain().

◆ 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

◆ 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 mlir::Operation::getResults(), mlir::PreOrder, and mlir::Operation::walk().

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

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


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