MLIR 22.0.0git
mlir::bufferization::OneShotAnalysisState Class Reference

State for analysis-enabled bufferization. More...

#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"

Inheritance diagram for mlir::bufferization::OneShotAnalysisState:

Classes

class  Extension
 Base class for OneShotAnalysisState extensions that allow OneShotAnalysisState to contain user-specified information in the state object. More...

Public Member Functions

 OneShotAnalysisState (Operation *op, const OneShotBufferizationOptions &options)
 OneShotAnalysisState (const OneShotAnalysisState &)=delete
 ~OneShotAnalysisState () override=default
const OneShotBufferizationOptionsgetOptions () const
 Return a reference to the BufferizationOptions.
LogicalResult analyzeOp (Operation *op, const DominanceInfo &domInfo)
 Analyze the given op and its nested ops.
LogicalResult analyzeSingleOp (Operation *op, const DominanceInfo &domInfo)
 Analyze a single op (without nested ops).
void applyOnEquivalenceClass (Value v, function_ref< void(Value)> fun) const
 Apply fun to all the members of the equivalence class of v.
void applyOnAliases (Value v, function_ref< void(Value)> fun) const
 Apply fun to all aliases of v.
bool areEquivalentBufferizedValues (Value v1, Value v2) const override
 Return true if v1 and v2 bufferize to equivalent buffers.
bool areAliasingBufferizedValues (Value v1, Value v2) const override
 Return true if v1 and v2 may bufferize to aliasing buffers.
void bufferizeInPlace (OpOperand &operand)
 Mark the given OpOperand as in-place and merge the results' and operand's aliasing sets.
void bufferizeOutOfPlace (OpOperand &operand)
 Mark the given OpOperand as out-of-place.
void createAliasInfoEntry (Value v)
 Add a new entry for v in the aliasInfo and equivalentInfo.
void gatherUndefinedTensorUses (Operation *op)
 Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses.
int64_t getStatNumTensorOutOfPlace () const
int64_t getStatNumTensorInPlace () const
bool hasUndefinedContents (OpOperand *opOperand) const override
 Return true if the given tensor has undefined contents.
bool isInPlace (OpOperand &opOperand) const override
 Return true if the given OpResult has been decided to bufferize inplace.
bool isValueWritten (Value value) const
 Return true if the buffer of the given tensor value is written to.
bool isWritable (Value value) const
 Return true if the buffer of the given tensor value is writable.
const SetVector< Value > & findDefinitionsCached (OpOperand *opOperand)
 Find the definitions of the given operand's value or retrieve them from the cache.
void resetCache () override
 Reset cached data structures.
void unionAliasSets (Value v1, Value v2)
 Union the alias sets of v1 and v2.
void unionEquivalenceClasses (Value v1, Value v2)
 Union the equivalence classes of v1 and v2.
template<typename Ty, typename... Args>
Ty & addExtension (Args &&...args)
 Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided.
template<typename Ty>
Ty * getExtension ()
 Returns the extension of the specified type.
template<typename Ty>
const Ty * getExtension () const
 Returns the extension of the specified type.
Public Member Functions inherited from mlir::AnalysisState
virtual ~AnalysisState ()
 AnalysisState (LatticeAnchor anchor)
 Create the analysis state on the given lattice anchor.
LatticeAnchor getAnchor () const
 Returns the lattice anchor this state is located at.
virtual void print (raw_ostream &os) const =0
 Print the contents of the analysis state.
LLVM_DUMP_METHOD void dump () const
void addDependency (ProgramPoint *point, DataFlowAnalysis *analysis)
 Add a dependency to this analysis state on a lattice anchor and an analysis.

Static Public Member Functions

static bool classof (const AnalysisState *base)

Additional Inherited Members

Protected Member Functions inherited from mlir::AnalysisState
virtual void onUpdate (DataFlowSolver *solver) const
 This function is called by the solver when the analysis state is updated to enqueue more work items.
Protected Attributes inherited from mlir::AnalysisState
LatticeAnchor anchor
 The lattice anchor to which the state belongs.

Detailed Description

State for analysis-enabled bufferization.

This class keeps track of alias sets, equivalence sets, in-place OpOperands and other things.

Note: Modifying the IR generally invalidates the result of the analysis. Adding new operations is safe if they are analyzed subsequently.

Definition at line 62 of file OneShotAnalysis.h.

Constructor & Destructor Documentation

◆ OneShotAnalysisState() [1/2]

◆ OneShotAnalysisState() [2/2]

mlir::bufferization::OneShotAnalysisState::OneShotAnalysisState ( const OneShotAnalysisState & )
delete

◆ ~OneShotAnalysisState()

mlir::bufferization::OneShotAnalysisState::~OneShotAnalysisState ( )
overridedefault

Member Function Documentation

◆ addExtension()

template<typename Ty, typename... Args>
Ty & mlir::bufferization::OneShotAnalysisState::addExtension ( Args &&... args)
inline

Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided.

The extension is owned by the OneShotAnalysisState. It is expected that the state does not already have an extension of the same type. Extension constructors are expected to take a reference to OneShotAnalysisState as first argument, automatically supplied by this call.

Definition at line 198 of file OneShotAnalysis.h.

References mlir::TypeID::get(), and result.

Referenced by getOrCreateFuncAnalysisState().

◆ analyzeOp()

◆ analyzeSingleOp()

LogicalResult OneShotAnalysisState::analyzeSingleOp ( Operation * op,
const DominanceInfo & domInfo )

Analyze a single op (without nested ops).

Definition at line 996 of file OneShotAnalysis.cpp.

References bufferizableInPlaceAnalysisImpl(), mlir::Operation::getOpOperands(), and success().

Referenced by analyzeOp().

◆ applyOnAliases()

void OneShotAnalysisState::applyOnAliases ( Value v,
function_ref< void(Value)> fun ) const

◆ applyOnEquivalenceClass()

void OneShotAnalysisState::applyOnEquivalenceClass ( Value v,
function_ref< void(Value)> fun ) const

Apply fun to all the members of the equivalence class of v.

Definition at line 137 of file OneShotAnalysis.cpp.

◆ areAliasingBufferizedValues()

bool OneShotAnalysisState::areAliasingBufferizedValues ( Value v1,
Value v2 ) const
override

Return true if v1 and v2 may bufferize to aliasing buffers.

Definition at line 159 of file OneShotAnalysis.cpp.

◆ areEquivalentBufferizedValues()

bool OneShotAnalysisState::areEquivalentBufferizedValues ( Value v1,
Value v2 ) const
override

Return true if v1 and v2 bufferize to equivalent buffers.

Definition at line 154 of file OneShotAnalysis.cpp.

Referenced by equivalenceAnalysis().

◆ bufferizeInPlace()

void OneShotAnalysisState::bufferizeInPlace ( OpOperand & operand)

Mark the given OpOperand as in-place and merge the results' and operand's aliasing sets.

Definition at line 164 of file OneShotAnalysis.cpp.

References mlir::IROperand< DerivedT, IRValueT >::get().

Referenced by bufferizableInPlaceAnalysisImpl(), and OneShotAnalysisState().

◆ bufferizeOutOfPlace()

void OneShotAnalysisState::bufferizeOutOfPlace ( OpOperand & operand)

Mark the given OpOperand as out-of-place.

Definition at line 173 of file OneShotAnalysis.cpp.

Referenced by bufferizableInPlaceAnalysisImpl().

◆ classof()

bool mlir::bufferization::OneShotAnalysisState::classof ( const AnalysisState * base)
inlinestatic

Definition at line 71 of file OneShotAnalysis.h.

References mlir::AnalysisState::AnalysisState(), and mlir::TypeID::get().

◆ createAliasInfoEntry()

void OneShotAnalysisState::createAliasInfoEntry ( Value v)

Add a new entry for v in the aliasInfo and equivalentInfo.

In the beginning the alias and equivalence sets only contain v itself.

Definition at line 179 of file OneShotAnalysis.cpp.

Referenced by OneShotAnalysisState().

◆ findDefinitionsCached()

const llvm::SetVector< Value > & OneShotAnalysisState::findDefinitionsCached ( OpOperand * opOperand)

Find the definitions of the given operand's value or retrieve them from the cache.

Definition at line 962 of file OneShotAnalysis.cpp.

References mlir::IROperand< DerivedT, IRValueT >::get().

Referenced by gatherUndefinedTensorUses(), and hasReadAfterWriteInterference().

◆ gatherUndefinedTensorUses()

void OneShotAnalysisState::gatherUndefinedTensorUses ( Operation * op)

Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses.

Definition at line 184 of file OneShotAnalysis.cpp.

References mlir::WalkResult::advance(), findDefinitionsCached(), mlir::Operation::getOpResults(), getOptions(), mlir::WalkResult::skip(), and mlir::Operation::walk().

Referenced by mlir::bufferization::analyzeOp().

◆ getExtension() [1/2]

template<typename Ty>
Ty * mlir::bufferization::OneShotAnalysisState::getExtension ( )
inline

Returns the extension of the specified type.

Definition at line 210 of file OneShotAnalysis.h.

References mlir::TypeID::get().

Referenced by getExtension(), and getOrCreateFuncAnalysisState().

◆ getExtension() [2/2]

template<typename Ty>
const Ty * mlir::bufferization::OneShotAnalysisState::getExtension ( ) const
inline

Returns the extension of the specified type.

Definition at line 222 of file OneShotAnalysis.h.

References getExtension(), and OneShotAnalysisState().

◆ getOptions()

◆ getStatNumTensorInPlace()

int64_t mlir::bufferization::OneShotAnalysisState::getStatNumTensorInPlace ( ) const
inline

Definition at line 115 of file OneShotAnalysis.h.

Referenced by mlir::bufferization::analyzeOp().

◆ getStatNumTensorOutOfPlace()

int64_t mlir::bufferization::OneShotAnalysisState::getStatNumTensorOutOfPlace ( ) const
inline

Definition at line 114 of file OneShotAnalysis.h.

Referenced by mlir::bufferization::analyzeOp().

◆ hasUndefinedContents()

bool OneShotAnalysisState::hasUndefinedContents ( OpOperand * opOperand) const
override

Return true if the given tensor has undefined contents.

Definition at line 212 of file OneShotAnalysis.cpp.

◆ isInPlace()

bool OneShotAnalysisState::isInPlace ( OpOperand & opOperand) const
override

◆ isValueWritten()

bool OneShotAnalysisState::isValueWritten ( Value value) const

Return true if the buffer of the given tensor value is written to.

Must not be called for values inside not yet analyzed functions.

Definition at line 220 of file OneShotAnalysis.cpp.

References applyOnAliases(), mlir::Value::getUses(), and isInPlace().

◆ isWritable()

bool OneShotAnalysisState::isWritable ( Value value) const

Return true if the buffer of the given tensor value is writable.

Definition at line 230 of file OneShotAnalysis.cpp.

References getOptions(), and getOwnerOfValue().

Referenced by wouldCreateWriteToNonWritableBuffer().

◆ resetCache()

void OneShotAnalysisState::resetCache ( )
override

Reset cached data structures.

Definition at line 969 of file OneShotAnalysis.cpp.

Referenced by mlir::bufferization::eliminateEmptyTensors(), and mlir::linalg::linalgOpAnchoredEmptyTensorEliminationStep().

◆ unionAliasSets()

void OneShotAnalysisState::unionAliasSets ( Value v1,
Value v2 )

Union the alias sets of v1 and v2.

Definition at line 241 of file OneShotAnalysis.cpp.

◆ unionEquivalenceClasses()

void OneShotAnalysisState::unionEquivalenceClasses ( Value v1,
Value v2 )

Union the equivalence classes of v1 and v2.

Definition at line 245 of file OneShotAnalysis.cpp.

Referenced by equivalenceAnalysis().


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