[Mlir-commits] [mlir] 3f3f4d5 - [mlir][Linalg] Fix expected buffer semantics crash

Nicolas Vasilache llvmlistbot at llvm.org
Thu Feb 9 06:04:29 PST 2023


Author: Nicolas Vasilache
Date: 2023-02-09T06:02:32-08:00
New Revision: 3f3f4d558e00e740e517070a9508242d52592e62

URL: https://github.com/llvm/llvm-project/commit/3f3f4d558e00e740e517070a9508242d52592e62
DIFF: https://github.com/llvm/llvm-project/commit/3f3f4d558e00e740e517070a9508242d52592e62.diff

LOG: [mlir][Linalg] Fix expected buffer semantics crash

Fixes #58747

Added: 
    

Modified: 
    mlir/lib/Dialect/Linalg/Transforms/Loops.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
index d2adaadf233d2..ae680a1f2c837 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -261,8 +261,10 @@ class LinalgRewritePattern : public RewritePattern {
   LogicalResult matchAndRewrite(Operation *op,
                                 PatternRewriter &rewriter) const override {
     auto linalgOp = dyn_cast<LinalgOp>(op);
-    if (!isa<LinalgOp>(op))
-      return failure();
+    if (!isa<LinalgOp>(op) || !linalgOp.hasBufferSemantics()) {
+      return rewriter.notifyMatchFailure(
+          op, "expected linalg op with buffer semantics");
+    }
     if (failed(linalgOpToLoopsImpl<LoopType>(rewriter, linalgOp)))
       return failure();
     rewriter.eraseOp(op);


        


More information about the Mlir-commits mailing list