diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h @@ -474,31 +474,6 @@ const BufferizationOptions &options; }; -/// This a "no analysis, always copy" AnalysisState. In the absence of an -/// analysis, a buffer must be copied each time it is written to. Therefore, all -/// OpOperands that bufferize to a memory write must bufferize out-of-place. -class AlwaysCopyAnalysisState : public AnalysisState { -public: - explicit AlwaysCopyAnalysisState(const BufferizationOptions &options); - - AlwaysCopyAnalysisState(const AlwaysCopyAnalysisState &) = delete; - - virtual ~AlwaysCopyAnalysisState() = default; - - /// Return `true` if the given OpResult has been decided to bufferize inplace. - bool isInPlace(OpOperand &opOperand) const override; - - /// Return true if `v1` and `v2` bufferize to equivalent buffers. - bool areEquivalentBufferizedValues(Value v1, Value v2) const override; - - /// Return `true` if the given tensor has undefined contents. - bool hasUndefinedContents(OpOperand *opOperand) const override; - - /// Return true if the given tensor (or an aliasing tensor) is yielded from - /// the containing block. Also include all aliasing tensors in the same block. - bool isTensorYielded(Value tensor) const override; -}; - /// BufferizationState provides helper functions for performing bufferization /// rewrites and handling memref buffers. struct BufferizationState { diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp --- a/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp @@ -374,43 +374,6 @@ rewriter.replaceOp(op, replacements); } -AlwaysCopyAnalysisState::AlwaysCopyAnalysisState( - const BufferizationOptions &options) - : AnalysisState(options) { - // Note: Allocations must be deallocated with a subsequent run of the buffer - // deallocation pass. - assert(!options.createDeallocs && - "cannot create deallocs with AlwaysCopyBufferizationState"); -} - -/// Return `true` if the given OpResult has been decided to bufferize inplace. -bool AlwaysCopyAnalysisState::isInPlace(OpOperand &opOperand) const { - // OpOperands that bufferize to a memory write are out-of-place, i.e., an - // alloc and copy is inserted. - return !bufferizesToMemoryWrite(opOperand); -} - -/// Return true if `v1` and `v2` bufferize to equivalent buffers. -bool AlwaysCopyAnalysisState::areEquivalentBufferizedValues(Value v1, - Value v2) const { - // There is no analysis, so we do not know if the values are equivalent. The - // conservative answer is "false". - return false; -} - -/// Return `true` if the given tensor has undefined contents. -bool AlwaysCopyAnalysisState::hasUndefinedContents(OpOperand *opOperand) const { - // There is no analysis, so the conservative answer is "false". - return false; -} - -/// Return true if the given tensor (or an aliasing tensor) is yielded from -/// the containing block. Also include all aliasing tensors in the same block. -bool AlwaysCopyAnalysisState::isTensorYielded(Value tensor) const { - // There is no analysis, so conservatively answer "true". - return true; -} - //===----------------------------------------------------------------------===// // Bufferization-specific scoped alloc/dealloc insertion support. //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp @@ -478,7 +478,12 @@ class AlwaysCopyAnalysisState : public AnalysisState { public: AlwaysCopyAnalysisState(const BufferizationOptions &options) - : AnalysisState(options) {} + : AnalysisState(options) { + // Note: Allocations must be deallocated with a subsequent run of the buffer + // deallocation pass. + assert(!options.createDeallocs && + "cannot create deallocs with AlwaysCopyBufferizationState"); + } AlwaysCopyAnalysisState(const AlwaysCopyAnalysisState &) = delete; @@ -497,6 +502,19 @@ // conservative answer is "false". return false; } + + /// Return `true` if the given tensor has undefined contents. + bool hasUndefinedContents(OpOperand *opOperand) const override { + // There is no analysis, so the conservative answer is "false". + return false; + } + + /// Return true if the given tensor (or an aliasing tensor) is yielded from + /// the containing block. Also include all aliasing tensors in the same block. + bool isTensorYielded(Value tensor) const override { + // There is no analysis, so conservatively answer "true". + return true; + } }; } // namespace