[Mlir-commits] [mlir] [mlir][linalg] Edit the yieldOutputs method's builder (PR #73900)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Nov 29 22:43:36 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-linalg
Author: Amir Bishara (amirBish)
<details>
<summary>Changes</summary>
Passing the `RegionBuilder`'s builder to the `yieldOutputs` method, Instead of creating a new one within the `yieldOutputs` method. This change is being made since having memory leaks issues (when compiling with address sanitizer) when applying `RewritePattern` on `LinalgStructuredOp` (creating and erasing op within `matchAndRewrite` method would reproduce the issue).
---
Full diff: https://github.com/llvm/llvm-project/pull/73900.diff
3 Files Affected:
- (modified) mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp (+2-2)
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp (+1)
- (modified) mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp (+1-1)
``````````diff
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 58af9995548e939..11ebbabe9773787 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -480,8 +480,8 @@ class RegionBuilderHelper {
llvm_unreachable("unsupported type conversion function");
}
- void yieldOutputs(ValueRange values) {
- OpBuilder builder = getBuilder();
+ void yieldOutputs(OpBuilder builder, ValueRange values) {
+ builder.setInsertionPointToEnd(&block);
Location loc = builder.getUnknownLoc();
builder.create<YieldOp>(loc, values);
}
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
index 375e10f9068e43b..e14efd8def0920d 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
@@ -260,6 +260,7 @@ struct SparseTensorCodegenPass
// The following operations and dialects may be introduced by the
// codegen rules, and are therefore marked as legal.
target.addLegalOp<linalg::FillOp>();
+ target.addLegalOp<linalg::YieldOp>();
target.addLegalDialect<
arith::ArithDialect, bufferization::BufferizationDialect,
complex::ComplexDialect, memref::MemRefDialect, scf::SCFDialect>();
diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
index fb3c9d48f9a9821..cd8398b973a5677 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
@@ -1012,7 +1012,7 @@ void {0}::regionBuilder(ImplicitLocOpBuilder &b,
SmallVector<Value> yields;
{2}
{3}
- helper.yieldOutputs(yields);
+ helper.yieldOutputs(b, yields);
}
)FMT";
auto &args = opConfig.structuredOp->args;
``````````
</details>
https://github.com/llvm/llvm-project/pull/73900
More information about the Mlir-commits
mailing list