Skip to content

Commit 57d9ade

Browse files
committed
Fix memory leaks in MLIR unit-tests (NFC)
1 parent 107198f commit 57d9ade

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

mlir/test/CAPI/pass.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ void testParsePassPipeline() {
189189
mlirPrintPassPipeline(mlirPassManagerGetAsOpPassManager(pm), printToStderr,
190190
NULL);
191191
fprintf(stderr, "\n");
192+
mlirPassManagerDestroy(pm);
193+
mlirContextDestroy(ctx);
192194
}
193195

194196
int main() {

mlir/unittests/Rewrite/PatternBenefit.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "mlir/IR/OwningOpRef.h"
910
#include "mlir/IR/PatternMatch.h"
1011
#include "mlir/Rewrite/PatternApplicator.h"
1112
#include "gtest/gtest.h"
@@ -20,7 +21,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
2021
MLIRContext context;
2122

2223
OpBuilder builder(&context);
23-
auto module = ModuleOp::create(builder.getUnknownLoc());
24+
OwningOpRef<ModuleOp> module = ModuleOp::create(builder.getUnknownLoc());
2425

2526
struct Pattern1 : public OpRewritePattern<ModuleOp> {
2627
Pattern1(mlir::MLIRContext *context, bool *called)
@@ -71,7 +72,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
7172
};
7273

7374
MyPatternRewriter rewriter(&context);
74-
(void)pa.matchAndRewrite(module, rewriter);
75+
(void)pa.matchAndRewrite(*module, rewriter);
7576

7677
EXPECT_TRUE(called1);
7778
EXPECT_TRUE(called2);

0 commit comments

Comments
 (0)