[Mlir-commits] [clang] [llvm] [mlir] [ASan] Document limitations of container overflow checks (PR #183590)
Vitaly Buka
llvmlistbot at llvm.org
Fri Feb 27 11:49:57 PST 2026
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/183590
>From 51fa58317015134e350a7e54621206eafbeb724f Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Thu, 26 Feb 2026 10:34:42 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
=?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.7
[skip ci]
---
llvm/include/llvm/ADT/DenseMap.h | 9 +++++++++
mlir/tools/mlir-tblgen/OpDocGen.cpp | 6 ++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index d967a231804f6..e1f1ab251d66c 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -1037,6 +1037,12 @@ class SmallDenseMap
// Note that this cast does not violate aliasing rules as we assert that
// the memory's dynamic type is the small, inline bucket buffer, and the
// 'storage' is a POD containing a char buffer.
+#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_HWADDRESS__)
+ // Unless it's a sanitizer with container overflow detection. In this case
+ // some items in buckets can be partially poisoned, triggering sanitizer
+ // report on load.
+ __asm__ volatile("" ::: "memory");
+#endif
return reinterpret_cast<const BucketT *>(&storage);
}
@@ -1048,6 +1054,9 @@ class SmallDenseMap
const LargeRep *getLargeRep() const {
assert(!Small);
// Note, same rule about aliasing as with getInlineBuckets.
+#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_HWADDRESS__)
+ __asm__ volatile("" ::: "memory");
+#endif
return reinterpret_cast<const LargeRep *>(&storage);
}
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index ac29225de44b1..5e3cf302ed3ea 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -110,9 +110,7 @@ static void emitNamedConstraint(const T &it, raw_ostream &os) {
// Records
//===----------------------------------------------------------------------===//
-// FIXME: Restore namespace {} when
-// https://github.com/llvm/llvm-project/issues/182720 fixed.
-// namespace {
+namespace {
struct OpDocGroup {
const Dialect &getDialect() const { return ops.front().getDialect(); }
@@ -141,7 +139,7 @@ struct DialectRecords {
std::vector<TypeDef> typeDefs;
std::vector<EnumInfo> enums;
};
-// } // namespace
+} // namespace
//===----------------------------------------------------------------------===//
// Operation Documentation
>From c35717124ce5d9747b11721894ae6375d85795f6 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 27 Feb 2026 11:49:40 -0800
Subject: [PATCH 2/2] reword
Created using spr 1.3.7
---
clang/docs/AddressSanitizer.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index 2139a12d0822c..80b1cdd95d77a 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -173,9 +173,9 @@ AddressSanitizer runtime to indicate which memory is poisoned etc.
Note that this feature is prone to false positives:
* Partially poisoning objects on stack, e.g. for small string optimization, can
- cause both, false positives and negatives.
- * In environments where not all the process binaries can be recompiled with
- AddressSanitizer enabled, these checks can cause false positives.
+ cause both false positives and negatives.
+ * If the binary is partially AddressSanitizer instrumented, these
+ checks can cause false positives.
See `Disabling container overflow checks`_ for details on suppressing checks.
More information about the Mlir-commits
mailing list