[Mlir-commits] [mlir] 57d9ade - Fix memory leaks in MLIR unit-tests (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Sat Oct 2 14:32:42 PDT 2021
Author: Mehdi Amini
Date: 2021-10-02T21:31:46Z
New Revision: 57d9adefa04dc65096b8ba3e5763c15305676f73
URL: https://github.com/llvm/llvm-project/commit/57d9adefa04dc65096b8ba3e5763c15305676f73
DIFF: https://github.com/llvm/llvm-project/commit/57d9adefa04dc65096b8ba3e5763c15305676f73.diff
LOG: Fix memory leaks in MLIR unit-tests (NFC)
Added:
Modified:
mlir/test/CAPI/pass.c
mlir/unittests/Rewrite/PatternBenefit.cpp
Removed:
################################################################################
diff --git a/mlir/test/CAPI/pass.c b/mlir/test/CAPI/pass.c
index 5e78287ca6471..0cf015e0d9138 100644
--- a/mlir/test/CAPI/pass.c
+++ b/mlir/test/CAPI/pass.c
@@ -189,6 +189,8 @@ void testParsePassPipeline() {
mlirPrintPassPipeline(mlirPassManagerGetAsOpPassManager(pm), printToStderr,
NULL);
fprintf(stderr, "\n");
+ mlirPassManagerDestroy(pm);
+ mlirContextDestroy(ctx);
}
int main() {
diff --git a/mlir/unittests/Rewrite/PatternBenefit.cpp b/mlir/unittests/Rewrite/PatternBenefit.cpp
index 86b1aa13a8cac..79552f06025be 100644
--- a/mlir/unittests/Rewrite/PatternBenefit.cpp
+++ b/mlir/unittests/Rewrite/PatternBenefit.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "mlir/IR/OwningOpRef.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Rewrite/PatternApplicator.h"
#include "gtest/gtest.h"
@@ -20,7 +21,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
MLIRContext context;
OpBuilder builder(&context);
- auto module = ModuleOp::create(builder.getUnknownLoc());
+ OwningOpRef<ModuleOp> module = ModuleOp::create(builder.getUnknownLoc());
struct Pattern1 : public OpRewritePattern<ModuleOp> {
Pattern1(mlir::MLIRContext *context, bool *called)
@@ -71,7 +72,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
};
MyPatternRewriter rewriter(&context);
- (void)pa.matchAndRewrite(module, rewriter);
+ (void)pa.matchAndRewrite(*module, rewriter);
EXPECT_TRUE(called1);
EXPECT_TRUE(called2);
More information about the Mlir-commits
mailing list