Skip to content

[mlir][bufferization][NFC] Buffer deallocation: Add comment to handleInterface #76956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

matthias-springer
Copy link
Member

This is a follow-up for #68648.

@llvmbot llvmbot added mlir mlir:bufferization Bufferization infrastructure labels Jan 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 4, 2024

@llvm/pr-subscribers-mlir-bufferization

@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)

Changes

This is a follow-up for #68648.


Full diff: https://github.com/llvm/llvm-project/pull/76956.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation.cpp (+6)
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation.cpp
index 9459cc43547faf..529d5a808c012a 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation.cpp
@@ -861,6 +861,12 @@ BufferDeallocation::handleInterface(MemoryEffectOpInterface op) {
 
   for (auto operand : llvm::make_filter_range(op->getOperands(), isMemref)) {
     if (op.getEffectOnValue<MemoryEffects::Free>(operand).has_value()) {
+      // The bufferization.manual_deallocation attribute can be attached to ops
+      // with an allocation and/or deallocation side effect. It indicates that
+      // the op is under a "manual deallocation" scheme. Deallocation ops are
+      // usually forbidden in the input IR (not supported by the buffer
+      // deallocation pass). However, if they are under manual deallocation,
+      // they can be safely ignored by the buffer deallocation pass.
       if (!op->hasAttr(BufferizationDialect::kManualDeallocation))
         return op->emitError(
             "memory free side-effect on MemRef value not supported!");

@matthias-springer matthias-springer merged commit b662c9a into llvm:main Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:bufferization Bufferization infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants