[Mlir-commits] [mlir] [mlir][IR] Initialize empty AsmResourceBlob mutability (PR #220586)
Mehdi Amini
llvmlistbot at llvm.org
Wed Sep 2 06:11:39 PDT 2026
https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/220586
The default constructor leaves dataIsMutable indeterminate even though isMutable may be called on an empty blob. Treat default-constructed blobs as immutable and cover that state with a unit test.
Valgrind pre-fix trace:
```
Invalid read of size 8
at testing::Test::Run()
Invalid write of size 8
Invalid free() / delete / delete[] / realloc()
ERROR SUMMARY: 6 errors from 6 contexts
```
Found by Coverity.
Assisted-by: Codex
>From 8a6dafe7494402b8ea2c6e577bc42c0bbd3da3d6 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Wed, 2 Sep 2026 05:56:04 -0700
Subject: [PATCH] [mlir][IR] Initialize empty AsmResourceBlob mutability
The default constructor leaves dataIsMutable indeterminate even though
isMutable may be called on an empty blob. Treat default-constructed blobs as
immutable and cover that state with a unit test.
Valgrind pre-fix trace:
Invalid read of size 8
at testing::Test::Run()
Invalid write of size 8
Invalid free() / delete / delete[] / realloc()
ERROR SUMMARY: 6 errors from 6 contexts
Found by Coverity.
Assisted-by: Codex
---
mlir/include/mlir/IR/AsmState.h | 2 +-
mlir/unittests/IR/AttributeTest.cpp | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/IR/AsmState.h b/mlir/include/mlir/IR/AsmState.h
index 5e9311742bd94..2c611f6060394 100644
--- a/mlir/include/mlir/IR/AsmState.h
+++ b/mlir/include/mlir/IR/AsmState.h
@@ -179,7 +179,7 @@ class AsmResourceBlob {
DeleterFn deleter;
/// Whether the data is mutable.
- bool dataIsMutable;
+ bool dataIsMutable = false;
friend class HeapAsmResourceBlob;
};
diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp
index 17d8e567fbebc..5db6a0c636aa3 100644
--- a/mlir/unittests/IR/AttributeTest.cpp
+++ b/mlir/unittests/IR/AttributeTest.cpp
@@ -262,6 +262,17 @@ TEST(DenseSplatMapValuesTest, I32ToFalse) {
}
} // namespace
+//===----------------------------------------------------------------------===//
+// AsmResourceBlob
+//===----------------------------------------------------------------------===//
+
+namespace {
+TEST(AsmResourceBlobTest, DefaultBlobIsImmutable) {
+ AsmResourceBlob blob;
+ EXPECT_FALSE(blob.isMutable());
+}
+} // namespace
+
//===----------------------------------------------------------------------===//
// DenseResourceElementsAttr
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list