[Mlir-commits] [mlir] 4b99afb - [MLIR][NFC] Drop sentinel leftovers from DenseMapInfo<Remark> (#224612)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 21 04:16:09 PDT 2026
Author: Henrich Lauko
Date: 2026-09-21T13:16:02+02:00
New Revision: 4b99afb361a8cfd45fc17aebc637688661e9e472
URL: https://github.com/llvm/llvm-project/commit/4b99afb361a8cfd45fc17aebc637688661e9e472
DIFF: https://github.com/llvm/llvm-project/commit/4b99afb361a8cfd45fc17aebc637688661e9e472.diff
LOG: [MLIR][NFC] Drop sentinel leftovers from DenseMapInfo<Remark> (#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 also wrong. 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 saying what the specialization
compares, which is 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).
Added:
Modified:
mlir/include/mlir/IR/Remarks.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Remarks.h b/mlir/include/mlir/IR/Remarks.h
index f0cdedbadb7e7..9e406f2263f1e 100644
--- a/mlir/include/mlir/IR/Remarks.h
+++ b/mlir/include/mlir/IR/Remarks.h
@@ -761,20 +761,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(),
@@ -785,12 +776,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