[Mlir-commits] [mlir] [MLIR][Remark][NFC] Drop sentinel leftovers from DenseMapInfo<Remark> (PR #224612)
Henrich Lauko
llvmlistbot at llvm.org
Fri Sep 18 04:58:07 PDT 2026
https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/224612
`DenseMap` no longer uses sentinel keys, and the `getEmptyKey` and `getTombstoneKey` members of `DenseMapInfo<Remark>` were removed in #200633 and #201991. Two leftovers stayed behind: the `"<EMPTY_KEY>"` comparison at the top of `isEqual`, and the static dummy `MLIRContext` that used to back the sentinel remarks.
The comparison is not only dead weight. A remark literally named `<EMPTY_KEY>` compares unequal to any other remark, including one with a matching hash, which breaks the hash and equality contract. This change removes both leftovers and adds a comment stating what the specialization compares: location, remark name, combined category name and kind.
No behaviour change for any remark with a normal name. Existing Remark unit tests and `mlir/test/Pass/remark-final.mlir` cover the specialization through `RemarkEmittingPolicyFinal`.
Assisted-by: Claude Code (Claude Fable 5.1). I read and reviewed the change before opening it.
>From 3c953811e2b27c2da941036cf526d07e3fe2e6ed Mon Sep 17 00:00:00 2001
From: Henrich Lauko <hlauko at nvidia.com>
Date: Fri, 18 Sep 2026 11:57:54 +0000
Subject: [PATCH] [MLIR][Remark][NFC] Drop sentinel leftovers from
DenseMapInfo<Remark>
DenseMap no longer uses sentinel keys, and the getEmptyKey and
getTombstoneKey members of DenseMapInfo<Remark> were removed in #200633
and #201991. The "<EMPTY_KEY>" comparison in isEqual and the static
dummy MLIRContext that backed the sentinels stayed behind. The
comparison also made a remark literally named "<EMPTY_KEY>" compare
unequal to remarks with a matching hash. Remove both and document what
the specialization compares.
Assisted-by: Claude Code (Claude Fable 5.1)
---
mlir/include/mlir/IR/Remarks.h | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/mlir/include/mlir/IR/Remarks.h b/mlir/include/mlir/IR/Remarks.h
index 81073efa4e0263..c2408e0c0bc5e2 100644
--- a/mlir/include/mlir/IR/Remarks.h
+++ b/mlir/include/mlir/IR/Remarks.h
@@ -760,20 +760,11 @@ LogicalResult enableOptimizationRemarks(
} // namespace mlir::remark
-// DenseMapInfo specialization for Remark
+/// Two remarks are the same for RemarkEmittingPolicyFinal when they have the
+/// same location, remark name, combined category name and kind.
namespace llvm {
template <>
struct DenseMapInfo<mlir::remark::detail::Remark> {
- static constexpr StringRef kEmptyKey = "<EMPTY_KEY>";
-
- /// Helper to provide a static dummy context for sentinel keys.
- static mlir::MLIRContext *getStaticDummyContext() {
- static mlir::MLIRContext dummyContext;
- return &dummyContext;
- }
-
- /// Create an empty remark
- /// Compute the hash value of the remark
static unsigned getHashValue(const mlir::remark::detail::Remark &remark) {
return llvm::hash_combine(
remark.getLocation().getAsOpaquePointer(),
@@ -784,12 +775,6 @@ struct DenseMapInfo<mlir::remark::detail::Remark> {
static bool isEqual(const mlir::remark::detail::Remark &lhs,
const mlir::remark::detail::Remark &rhs) {
- // Check for empty keys first.
- if (lhs.getRemarkName() == kEmptyKey || rhs.getRemarkName() == kEmptyKey) {
- return lhs.getRemarkName() == rhs.getRemarkName();
- }
-
- // For regular remarks, compare key identifying fields
return lhs.getLocation() == rhs.getLocation() &&
lhs.getRemarkName() == rhs.getRemarkName() &&
lhs.getCombinedCategoryName() == rhs.getCombinedCategoryName() &&
More information about the Mlir-commits
mailing list