Skip to content

Commit 8da1997

Browse files
bangtianliuqedawkins
authored andcommitted
Revert "[MLIR][NFC] Retire let constructor for Bufferization (llvm#129850)"
This reverts commit 1a3dc8e.
1 parent 681b241 commit 8da1997

13 files changed

+271
-126
lines changed

mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ using DeallocHelperMap = llvm::DenseMap<Operation *, func::FuncOp>;
3030
#define GEN_PASS_DECL
3131
#include "mlir/Dialect/Bufferization/Transforms/Passes.h.inc"
3232

33+
/// Creates an instance of the OwnershipBasedBufferDeallocation pass to free all
34+
/// allocated buffers.
35+
std::unique_ptr<Pass> createOwnershipBasedBufferDeallocationPass(
36+
DeallocationOptions options = DeallocationOptions());
37+
38+
/// Creates a pass that finds all temporary allocations
39+
/// and attempts to move the deallocation after the last user/dependency
40+
/// of the allocation, thereby optimizing allocation liveness.
41+
std::unique_ptr<Pass> createOptimizeAllocationLivenessPass();
42+
43+
/// Creates a pass that optimizes `bufferization.dealloc` operations. For
44+
/// example, it reduces the number of alias checks needed at runtime using
45+
/// static alias analysis.
46+
std::unique_ptr<Pass> createBufferDeallocationSimplificationPass();
47+
48+
/// Creates an instance of the LowerDeallocations pass to lower
49+
/// `bufferization.dealloc` operations to the `memref` dialect.
50+
std::unique_ptr<Pass> createLowerDeallocationsPass();
51+
3352
/// Adds the conversion pattern of the `bufferization.dealloc` operation to the
3453
/// given pattern set for use in other transformation passes.
3554
void populateBufferizationDeallocLoweringPattern(
@@ -122,6 +141,14 @@ func::FuncOp buildDeallocationLibraryFunction(OpBuilder &builder, Location loc,
122141
LogicalResult deallocateBuffersOwnershipBased(FunctionOpInterface op,
123142
DeallocationOptions options);
124143

144+
/// Creates a pass that moves allocations upwards to reduce the number of
145+
/// required copies that are inserted during the BufferDeallocation pass.
146+
std::unique_ptr<Pass> createBufferHoistingPass();
147+
148+
/// Creates a pass that moves allocations upwards out of loops. This avoids
149+
/// reallocations inside of loops.
150+
std::unique_ptr<Pass> createBufferLoopHoistingPass();
151+
125152
// Options struct for BufferResultsToOutParams pass.
126153
// Note: defined only here, not in tablegen.
127154
struct BufferResultsToOutParamsOpts {
@@ -165,20 +192,51 @@ struct BufferResultsToOutParamsOpts {
165192
bool hoistStaticAllocs = false;
166193
};
167194

195+
/// Creates a pass that converts memref function results to out-params.
196+
std::unique_ptr<Pass> createBufferResultsToOutParamsPass(
197+
const BufferResultsToOutParamsOpts &options = {});
198+
168199
/// Replace buffers that are returned from a function with an out parameter.
169200
/// Also update all call sites.
170201
LogicalResult
171202
promoteBufferResultsToOutParams(ModuleOp module,
172203
const BufferResultsToOutParamsOpts &options);
173204

205+
/// Creates a pass that drops memref function results that are equivalent to a
206+
/// function argument.
207+
std::unique_ptr<Pass> createDropEquivalentBufferResultsPass();
208+
209+
/// Create a pass that rewrites tensor.empty to bufferization.alloc_tensor.
210+
std::unique_ptr<Pass> createEmptyTensorToAllocTensorPass();
211+
174212
/// Drop all memref function results that are equivalent to a function argument.
175213
LogicalResult dropEquivalentBufferResults(ModuleOp module);
176214

215+
/// Create a pass that bufferizes all ops that implement BufferizableOpInterface
216+
/// with One-Shot Bufferize.
217+
std::unique_ptr<Pass> createOneShotBufferizePass();
218+
219+
/// Create a pass that bufferizes all ops that implement BufferizableOpInterface
220+
/// with One-Shot Bufferize and the specified bufferization options.
221+
std::unique_ptr<Pass>
222+
createOneShotBufferizePass(const OneShotBufferizationOptions &options);
223+
224+
/// Creates a pass that promotes heap-based allocations to stack-based ones.
225+
/// Only buffers smaller than the provided size are promoted.
226+
/// Dynamic shaped buffers are promoted up to the given rank.
227+
std::unique_ptr<Pass>
228+
createPromoteBuffersToStackPass(unsigned maxAllocSizeInBytes = 1024,
229+
unsigned maxRankOfAllocatedMemRef = 1);
230+
177231
/// Creates a pass that promotes heap-based allocations to stack-based ones.
178232
/// Only buffers smaller with `isSmallAlloc(alloc) == true` are promoted.
179233
std::unique_ptr<Pass>
180234
createPromoteBuffersToStackPass(std::function<bool(Value)> isSmallAlloc);
181235

236+
/// Create a pass that tries to eliminate tensor.empty ops that are anchored on
237+
/// insert_slice ops.
238+
std::unique_ptr<Pass> createEmptyTensorEliminationPass();
239+
182240
//===----------------------------------------------------------------------===//
183241
// Registration
184242
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)