|
MLIR 22.0.0git
|
State for analysis-enabled bufferization. More...
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
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 OneShotBufferizationOptions & | getOptions () 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. | |
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.
| OneShotAnalysisState::OneShotAnalysisState | ( | Operation * | op, |
| const OneShotBufferizationOptions & | options ) |
Definition at line 110 of file OneShotAnalysis.cpp.
References mlir::WalkResult::advance(), mlir::AnalysisState::AnalysisState(), b, bufferizeInPlace(), createAliasInfoEntry(), mlir::get(), mlir::Operation::getRegions(), mlir::Operation::getResults(), OneShotAnalysisState(), options, mlir::WalkResult::skip(), and mlir::Operation::walk().
Referenced by getExtension(), OneShotAnalysisState(), and OneShotAnalysisState().
|
delete |
References OneShotAnalysisState().
|
overridedefault |
|
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().
| LogicalResult OneShotAnalysisState::analyzeOp | ( | Operation * | op, |
| const DominanceInfo & | domInfo ) |
Analyze the given op and its nested ops.
Definition at line 1119 of file OneShotAnalysis.cpp.
References mlir::bufferization::OneShotBufferizationOptions::analysisHeuristic, analyzeSingleOp(), mlir::bufferization::OneShotBufferizationOptions::BottomUp, mlir::bufferization::OneShotBufferizationOptions::BottomUpFromTerminators, bottomUpFromTerminatorsHeuristic(), equivalenceAnalysis(), mlir::bufferization::OneShotBufferizationOptions::Fuzzer, getOptions(), success(), mlir::bufferization::OneShotBufferizationOptions::TopDown, and mlir::Operation::walk().
Referenced by mlir::bufferization::analyzeOp().
| 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().
| void OneShotAnalysisState::applyOnAliases | ( | Value | v, |
| function_ref< void(Value)> | fun ) const |
Apply fun to all aliases of v.
Definition at line 146 of file OneShotAnalysis.cpp.
Referenced by annotateOpsWithAliasSets(), getAliasingInplaceWrites(), getAliasingReads(), isValueWritten(), and wouldCreateWriteToNonWritableBuffer().
| 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.
Return true if v1 and v2 may bufferize to aliasing buffers.
Definition at line 159 of file OneShotAnalysis.cpp.
Return true if v1 and v2 bufferize to equivalent buffers.
Definition at line 154 of file OneShotAnalysis.cpp.
Referenced by equivalenceAnalysis().
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().
Mark the given OpOperand as out-of-place.
Definition at line 173 of file OneShotAnalysis.cpp.
Referenced by bufferizableInPlaceAnalysisImpl().
|
inlinestatic |
Definition at line 71 of file OneShotAnalysis.h.
References mlir::AnalysisState::AnalysisState(), and mlir::TypeID::get().
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().
| 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().
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().
|
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().
|
inline |
Returns the extension of the specified type.
Definition at line 222 of file OneShotAnalysis.h.
References getExtension(), and OneShotAnalysisState().
|
inline |
Return a reference to the BufferizationOptions.
Definition at line 76 of file OneShotAnalysis.h.
Referenced by mlir::bufferization::analyzeModuleOp(), mlir::bufferization::analyzeOp(), analyzeOp(), checkPreBufferizationAssumptions(), equivalenceAnalysis(), gatherUndefinedTensorUses(), hasReadAfterWriteInterference(), isWritable(), and wouldCreateWriteToNonWritableBuffer().
|
inline |
Definition at line 115 of file OneShotAnalysis.h.
Referenced by mlir::bufferization::analyzeOp().
|
inline |
Definition at line 114 of file OneShotAnalysis.h.
Referenced by mlir::bufferization::analyzeOp().
Return true if the given tensor has undefined contents.
Definition at line 212 of file OneShotAnalysis.cpp.
Return true if the given OpResult has been decided to bufferize inplace.
Definition at line 216 of file OneShotAnalysis.cpp.
Referenced by annotateOpsWithBufferizationMarkers(), checkPreBufferizationAssumptions(), mlir::bufferization::eliminateEmptyTensors(), equivalenceAnalysis(), isInplaceMemoryWrite(), and isValueWritten().
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().
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().
|
override |
Reset cached data structures.
Definition at line 969 of file OneShotAnalysis.cpp.
Referenced by mlir::bufferization::eliminateEmptyTensors(), and mlir::linalg::linalgOpAnchoredEmptyTensorEliminationStep().
Union the alias sets of v1 and v2.
Definition at line 241 of file OneShotAnalysis.cpp.
Union the equivalence classes of v1 and v2.
Definition at line 245 of file OneShotAnalysis.cpp.
Referenced by equivalenceAnalysis().