[mlir-c] Fix pattern-set leak in rewrite.c materialization tests - #211358
Merged
makslevental merged 1 commit intoJul 22, 2026
Merged
Conversation
The materialization tests added in #208934 freeze their MlirRewritePatternSet but never destroy it. mlirFreezeRewritePattern only moves the patterns out of the heap-allocated RewritePatternSet; the container itself must still be freed with mlirRewritePatternSetDestroy (as testConversionTargetDynamicLegality already does). The leak was caught by LeakSanitizer on the aarch64 HWASan bootstrap bot (builder 55).
Contributor
Author
makslevental
marked this pull request as ready for review
July 22, 2026 21:28
makslevental
requested review from
PragmaTwice,
jpienaar and
kuhar
and removed request for
jpienaar
July 22, 2026 21:36
makslevental
deleted the
users/makslevental/fix-capi-rewrite-materialization-leak
branch
July 22, 2026 22:02
|
@llvm/pr-subscribers-mlir Author: Maksim Levental (makslevental) ChangesThe This was caught by LeakSanitizer on the aarch64 HWASan bootstrap bot (builder 55, build 30763): Fix: call Assisted by: Claude Full diff: https://github.com/llvm/llvm-project/pull/211358.diff 1 Files Affected:
diff --git a/mlir/test/CAPI/rewrite.c b/mlir/test/CAPI/rewrite.c
index 03cde15165c8a..230ae58fd23ba 100644
--- a/mlir/test/CAPI/rewrite.c
+++ b/mlir/test/CAPI/rewrite.c
@@ -911,6 +911,7 @@ void testTypeConverterSourceMaterialization(MlirContext ctx) {
mlirRewritePatternSetAdd(patterns,
mlirConversionPatternAsRewritePattern(pattern));
MlirFrozenRewritePatternSet frozen = mlirFreezeRewritePattern(patterns);
+ mlirRewritePatternSetDestroy(patterns);
MlirConversionTarget target = mlirConversionTargetCreate(ctx);
mlirConversionTargetAddIllegalOp(
@@ -1002,6 +1003,7 @@ void testTypeConverterTargetMaterialization(MlirContext ctx) {
mlirRewritePatternSetAdd(patterns,
mlirConversionPatternAsRewritePattern(pattern));
MlirFrozenRewritePatternSet frozen = mlirFreezeRewritePattern(patterns);
+ mlirRewritePatternSetDestroy(patterns);
MlirConversionTarget target = mlirConversionTargetCreate(ctx);
mlirConversionTargetAddIllegalOp(
|
midhuncodes7
pushed a commit
to midhuncodes7/llvm-project
that referenced
this pull request
Jul 28, 2026
…m#211358) The `TypeConverter` materialization tests added in llvm#208934 (`testTypeConverterSourceMaterialization` / `testTypeConverterTargetMaterialization`) freeze their `MlirRewritePatternSet` but never destroy it. This was caught by LeakSanitizer on the aarch64 HWASan bootstrap bot ([builder 55, build 30763](https://lab.llvm.org/buildbot/#/builders/55/builds/30763)): Fix: call `mlirRewritePatternSetDestroy(patterns)` after freezing in both tests, matching existing usage. Assisted by: Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
TypeConvertermaterialization tests added in #208934 (testTypeConverterSourceMaterialization/testTypeConverterTargetMaterialization) freeze theirMlirRewritePatternSetbut never destroy it.This was caught by LeakSanitizer on the aarch64 HWASan bootstrap bot (builder 55, build 30763):
Fix: call
mlirRewritePatternSetDestroy(patterns)after freezing in both tests, matching existing usage.Assisted by: Claude