[llvm] [mlir][bufferization] Add deallocation option to remove existing dealloc operations, add option to specify the kind of alloc operations to consider (PR #67556)

Martin Erhart via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 05:16:28 PDT 2023


================
@@ -106,6 +111,48 @@ struct DeallocationOptions {
   /// to, an error will already be emitted at compile time. This cannot be
   /// changed with this option.
   bool verifyFunctionBoundaryABI = true;
+
+  /// Given an allocation side-effect on the passed operation, determine whether
+  /// this allocation operation is of relevance (i.e., should assign ownership
+  /// to the allocated value). If it is determined to not be relevant,
+  /// ownership will be set to 'false', i.e., it will be leaked. This is useful
+  /// to support deallocation of multiple different kinds of allocation ops.
+  DetectionFn isRelevantAllocOp = [](Operation *op) {
+    return isa<memref::MemRefDialect, bufferization::BufferizationDialect>(
----------------
maerhart wrote:

`BufferizationDialect` is here because of `bufferization.clone` which has an allocation side-effect as well.

https://github.com/llvm/llvm-project/pull/67556


More information about the llvm-commits mailing list