[Mlir-commits] [mlir] 7dfd3bb - [mlir][linalg][bufferize][NFC] API change of aliasesNonWritableBuffer

Matthias Springer llvmlistbot at llvm.org
Thu Oct 7 22:51:32 PDT 2021


Author: Matthias Springer
Date: 2021-10-08T14:47:29+09:00
New Revision: 7dfd3bb0345eb0e67e7d547dd70607e1b0e4df9c

URL: https://github.com/llvm/llvm-project/commit/7dfd3bb0345eb0e67e7d547dd70607e1b0e4df9c
DIFF: https://github.com/llvm/llvm-project/commit/7dfd3bb0345eb0e67e7d547dd70607e1b0e4df9c.diff

LOG: [mlir][linalg][bufferize][NFC] API change of aliasesNonWritableBuffer

The function now takes a Value instead of an OpOperand.

Differential Revision: https://reviews.llvm.org/D111378

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h
    mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h b/mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h
index b0249ff38a569..c10dfdeff1267 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h
@@ -56,10 +56,9 @@ class BufferizationAliasInfo {
   /// `alias`. Additionally, merge their equivalence classes.
   void insertNewBufferEquivalence(Value newValue, Value alias);
 
-  /// Return true if the buffer to which `operand` would bufferize aliases a
-  /// buffer that is known to not be writable. This implies that the matching
-  /// OpResult cannot be bufferized inplace.
-  bool aliasesNonWritableBuffer(OpOperand &operand) const;
+  /// Return true if, under current bufferization decisions, the buffer of
+  /// `value` is not writable.
+  bool aliasesNonWritableBuffer(Value value) const;
 
   /// Return true if the buffer to which `operand` would bufferize is equivalent
   /// to some buffer write.

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
index ddbc8a74d147d..0d735825cf701 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
@@ -736,40 +736,36 @@ void BufferizationAliasInfo::insertNewBufferEquivalence(Value newValue,
   equivalentInfo.unionSets(newValue, alias);
 }
 
-/// Return true if the buffer to which `operand` would bufferize aliases a
-/// buffer that is known to not be writable. This implies that the matching
-/// OpResult cannot be bufferized inplace.
-bool BufferizationAliasInfo::aliasesNonWritableBuffer(
-    OpOperand &operand) const {
+/// Return true if, under current bufferization decisions, the buffer of `value`
+/// is not writable.
+bool BufferizationAliasInfo::aliasesNonWritableBuffer(Value value) const {
   LDBG("----Start aliasesNonWritableBuffer\n");
-  LDBG("-------for -> #" << operand.getOperandNumber() << ": "
-                         << printOperationInfo(operand.getOwner()) << '\n');
-  for (Value v : getAliases(operand.get())) {
+  for (Value v : getAliases(value)) {
     LDBG("-----------examine: " << printValueInfo(v) << '\n');
     if (bufferizesToWritableMemory(v)) {
-      LDBG("-----------Value is known to be writeable -> skip: "
+      LDBG("-----------Value is known to be writable -> skip: "
            << printValueInfo(v) << '\n');
       continue;
     }
 
     if (auto bbArg = v.dyn_cast<BlockArgument>()) {
       if (getInPlace(bbArg) == InPlaceSpec::True) {
-        LDBG("-----------bbArg is writeable -> skip: " << printValueInfo(bbArg)
-                                                       << '\n');
+        LDBG("-----------bbArg is writable -> skip: " << printValueInfo(bbArg)
+                                                      << '\n');
         continue;
       }
-      LDBG("-----------notWriteable\n");
+      LDBG("-----------notWritable bbArg\n");
       return true;
     }
 
     if (Operation *op = v.getDefiningOp()) {
       if (isa<ConstantOp>(op) || !hasKnownBufferizationAliasingBehavior(op)) {
-        LDBG("-----------notWritable\n");
+        LDBG("-----------notWritable op\n");
         return true;
       }
     }
   }
-  LDBG("---->operand is writable\n");
+  LDBG("---->value is writable\n");
   return false;
 }
 
@@ -2239,7 +2235,7 @@ bufferizableInPlaceAnalysis(ExtractSliceOp extractSliceOp,
   // aliasing a write into a non-writable buffer.
   bool wouldCreateAliasingWriteToNonWritableBuffer =
       aliasInfo.aliasesInPlaceWrite(extractSliceOp.result()) &&
-      aliasInfo.aliasesNonWritableBuffer(extractSliceOp->getOpOperand(0));
+      aliasInfo.aliasesNonWritableBuffer(extractSliceOp.source());
 
   if (wouldCreateAliasingWriteToNonWritableBuffer)
     LDBG("->the corresponding buffer is not writable\n");
@@ -2292,7 +2288,7 @@ bufferizableInPlaceAnalysis(OpOperand &operand,
   //   2. a constant op.
   // to be considered for inplace bufferization
   bool wouldCreateAliasingWriteToNonWritableBuffer =
-      aliasInfo.aliasesNonWritableBuffer(operand);
+      aliasInfo.aliasesNonWritableBuffer(operand.get());
   if (wouldCreateAliasingWriteToNonWritableBuffer)
     LDBG("->the corresponding buffer is not writable\n");
   else


        


More information about the Mlir-commits mailing list