[Mlir-commits] [mlir] [mlir] Remove unused DenseMapInfo::getEmptyKey (PR #201991)
Fangrui Song
llvmlistbot at llvm.org
Fri Jun 5 19:52:57 PDT 2026
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/201991
After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.
>From 03421e69a506e6e18385bfc0fe5619e1b35d760e Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Fri, 5 Jun 2026 19:08:15 -0700
Subject: [PATCH] [mlir] Remove unused DenseMapInfo::getEmptyKey
After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.
---
mlir/docs/DefiningDialects/Operations.md | 8 --------
mlir/include/mlir/Analysis/CallGraph.h | 1 -
mlir/include/mlir/Analysis/DataFlowFramework.h | 6 ------
mlir/include/mlir/IR/AffineExpr.h | 4 ----
mlir/include/mlir/IR/AffineMap.h | 4 ----
mlir/include/mlir/IR/Attributes.h | 12 ------------
mlir/include/mlir/IR/Block.h | 4 ----
mlir/include/mlir/IR/BlockSupport.h | 6 ------
mlir/include/mlir/IR/BuiltinAttributes.h | 4 ----
mlir/include/mlir/IR/DialectInterface.h | 2 --
mlir/include/mlir/IR/IntegerSet.h | 4 ----
mlir/include/mlir/IR/Location.h | 4 ----
mlir/include/mlir/IR/OpDefinition.h | 4 ----
mlir/include/mlir/IR/OpImplementation.h | 4 ----
mlir/include/mlir/IR/OperationSupport.h | 8 --------
mlir/include/mlir/IR/Remarks.h | 7 -------
mlir/include/mlir/IR/TypeRange.h | 18 ------------------
mlir/include/mlir/IR/Types.h | 8 --------
mlir/include/mlir/IR/Value.h | 16 ----------------
mlir/include/mlir/Pass/PassInstrumentation.h | 4 ----
mlir/include/mlir/Pass/PassManager.h | 5 ++---
mlir/include/mlir/Support/InterfaceSupport.h | 2 --
mlir/include/mlir/Support/TypeID.h | 4 ----
mlir/include/mlir/TableGen/Constraint.h | 1 -
mlir/include/mlir/TableGen/Format.h | 3 ---
mlir/include/mlir/TableGen/Pattern.h | 8 --------
mlir/include/mlir/Tools/PDLL/AST/Types.h | 5 -----
.../PDLToPDLInterp/PredicateTree.cpp | 1 -
.../DuplicateFunctionElimination.cpp | 3 ---
.../Dialect/Vector/Transforms/VectorUnroll.cpp | 2 --
mlir/lib/Support/StorageUniquer.cpp | 6 ------
mlir/lib/TableGen/Constraint.cpp | 11 -----------
mlir/lib/Transforms/Utils/CFGToSCF.cpp | 2 --
mlir/lib/Transforms/Utils/CSE.cpp | 2 --
.../lib/Transforms/Utils/DialectConversion.cpp | 1 -
mlir/tools/mlir-tblgen/EnumsGen.cpp | 4 ----
36 files changed, 2 insertions(+), 186 deletions(-)
diff --git a/mlir/docs/DefiningDialects/Operations.md b/mlir/docs/DefiningDialects/Operations.md
index 7e6d49a7b53f2..4302edbddf22c 100644
--- a/mlir/docs/DefiningDialects/Operations.md
+++ b/mlir/docs/DefiningDialects/Operations.md
@@ -1567,10 +1567,6 @@ namespace llvm {
template<> struct DenseMapInfo<Outer::Inner::MyIntEnum> {
using StorageInfo = llvm::DenseMapInfo<uint32_t>;
- static inline Outer::Inner::MyIntEnum getEmptyKey() {
- return static_cast<Outer::Inner::MyIntEnum>(StorageInfo::getEmptyKey());
- }
-
static unsigned getHashValue(const Outer::Inner::MyIntEnum &val) {
return StorageInfo::getHashValue(static_cast<uint32_t>(val));
}
@@ -1693,10 +1689,6 @@ namespace llvm {
template<> struct DenseMapInfo<::MyBitEnum> {
using StorageInfo = llvm::DenseMapInfo<uint32_t>;
- static inline ::MyBitEnum getEmptyKey() {
- return static_cast<::MyBitEnum>(StorageInfo::getEmptyKey());
- }
-
static unsigned getHashValue(const ::MyBitEnum &val) {
return StorageInfo::getHashValue(static_cast<uint32_t>(val));
}
diff --git a/mlir/include/mlir/Analysis/CallGraph.h b/mlir/include/mlir/Analysis/CallGraph.h
index 6b34a08b4799b..9808aea1239cf 100644
--- a/mlir/include/mlir/Analysis/CallGraph.h
+++ b/mlir/include/mlir/Analysis/CallGraph.h
@@ -120,7 +120,6 @@ class CallGraphNode {
using BaseInfo =
DenseMapInfo<llvm::PointerIntPair<CallGraphNode *, 2, Edge::Kind>>;
- static Edge getEmptyKey() { return Edge(BaseInfo::getEmptyKey()); }
static unsigned getHashValue(const Edge &edge) {
return BaseInfo::getHashValue(edge.targetAndKind);
}
diff --git a/mlir/include/mlir/Analysis/DataFlowFramework.h b/mlir/include/mlir/Analysis/DataFlowFramework.h
index 0995fe1fcdef8..30fed25befa5d 100644
--- a/mlir/include/mlir/Analysis/DataFlowFramework.h
+++ b/mlir/include/mlir/Analysis/DataFlowFramework.h
@@ -811,12 +811,6 @@ namespace llvm {
/// Allow hashing of lattice anchors and program points.
template <>
struct DenseMapInfo<mlir::ProgramPoint> {
- static mlir::ProgramPoint getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::ProgramPoint(
- (mlir::Block *)pointer,
- mlir::Block::iterator((mlir::Operation *)pointer));
- }
static unsigned getHashValue(mlir::ProgramPoint pp) {
return hash_combine(pp.getBlock(), pp.getPoint().getNodePtr());
}
diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h
index a5a7e9f2455ea..51b5e972abd41 100644
--- a/mlir/include/mlir/IR/AffineExpr.h
+++ b/mlir/include/mlir/IR/AffineExpr.h
@@ -354,10 +354,6 @@ namespace llvm {
// AffineExpr hash just like pointers
template <>
struct DenseMapInfo<mlir::AffineExpr> {
- static mlir::AffineExpr getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::AffineExpr(static_cast<mlir::AffineExpr::ImplType *>(pointer));
- }
static unsigned getHashValue(mlir::AffineExpr val) {
return mlir::hash_value(val);
}
diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h
index d483d5f271560..0643f0a4b308f 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -715,10 +715,6 @@ namespace llvm {
// AffineExpr hash just like pointers
template <>
struct DenseMapInfo<mlir::AffineMap> {
- static mlir::AffineMap getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::AffineMap(static_cast<mlir::AffineMap::ImplType *>(pointer));
- }
static unsigned getHashValue(mlir::AffineMap val) {
return mlir::hash_value(val);
}
diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h
index 011b7c496268f..a2f9c5fcda873 100644
--- a/mlir/include/mlir/IR/Attributes.h
+++ b/mlir/include/mlir/IR/Attributes.h
@@ -302,10 +302,6 @@ namespace llvm {
// Attribute hash just like pointers.
template <>
struct DenseMapInfo<mlir::Attribute> {
- static mlir::Attribute getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::Attribute(static_cast<mlir::Attribute::ImplType *>(pointer));
- }
static unsigned getHashValue(mlir::Attribute val) {
return mlir::hash_value(val);
}
@@ -318,10 +314,6 @@ struct DenseMapInfo<
T, std::enable_if_t<std::is_base_of<mlir::Attribute, T>::value &&
!mlir::detail::IsInterface<T>::value>>
: public DenseMapInfo<mlir::Attribute> {
- static T getEmptyKey() {
- const void *pointer = llvm::DenseMapInfo<const void *>::getEmptyKey();
- return T::getFromOpaquePointer(pointer);
- }
};
/// Allow LLVM to steal the low bits of Attributes.
@@ -339,10 +331,6 @@ struct PointerLikeTypeTraits<mlir::Attribute> {
template <>
struct DenseMapInfo<mlir::NamedAttribute> {
- static mlir::NamedAttribute getEmptyKey() {
- auto emptyAttr = llvm::DenseMapInfo<mlir::Attribute>::getEmptyKey();
- return mlir::NamedAttribute(emptyAttr, emptyAttr);
- }
static unsigned getHashValue(mlir::NamedAttribute val) {
return mlir::hash_value(val);
}
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 72a07e04e0d3a..bb3484af2aaf7 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -440,10 +440,6 @@ raw_ostream &operator<<(raw_ostream &, Block &);
namespace llvm {
template <>
struct DenseMapInfo<mlir::Block::iterator> {
- static mlir::Block::iterator getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::Block::iterator((mlir::Operation *)pointer);
- }
static unsigned getHashValue(mlir::Block::iterator iter) {
return hash_value(iter.getNodePtr());
}
diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h
index f256708a1afa6..782e977adbd7f 100644
--- a/mlir/include/mlir/IR/BlockSupport.h
+++ b/mlir/include/mlir/IR/BlockSupport.h
@@ -176,16 +176,10 @@ namespace llvm {
/// Provide support for hashing successor ranges.
template <>
struct DenseMapInfo<mlir::SuccessorRange> {
- static mlir::SuccessorRange getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<mlir::BlockOperand *>::getEmptyKey();
- return mlir::SuccessorRange(pointer, 0);
- }
static unsigned getHashValue(mlir::SuccessorRange value) {
return llvm::hash_combine_range(value);
}
static bool isEqual(mlir::SuccessorRange lhs, mlir::SuccessorRange rhs) {
- if (rhs.getBase() == getEmptyKey().getBase())
- return lhs.getBase() == getEmptyKey().getBase();
return lhs == rhs;
}
};
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.h b/mlir/include/mlir/IR/BuiltinAttributes.h
index ce3870f00bc13..8522ffc7abaab 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.h
+++ b/mlir/include/mlir/IR/BuiltinAttributes.h
@@ -1104,10 +1104,6 @@ namespace llvm {
template <>
struct DenseMapInfo<mlir::StringAttr> : public DenseMapInfo<mlir::Attribute> {
- static mlir::StringAttr getEmptyKey() {
- const void *pointer = llvm::DenseMapInfo<const void *>::getEmptyKey();
- return mlir::StringAttr::getFromOpaquePointer(pointer);
- }
};
template <>
struct PointerLikeTypeTraits<mlir::StringAttr>
diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h
index fcef3cafb1b43..601c53f074f20 100644
--- a/mlir/include/mlir/IR/DialectInterface.h
+++ b/mlir/include/mlir/IR/DialectInterface.h
@@ -87,8 +87,6 @@ class DialectInterfaceCollectionBase {
}
static bool isEqual(Dialect *lhs, const DialectInterface *rhs) {
- if (rhs == getEmptyKey())
- return false;
return lhs == rhs->getDialect();
}
};
diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h
index 68b0b9f324f4e..3c84131e8ecd5 100644
--- a/mlir/include/mlir/IR/IntegerSet.h
+++ b/mlir/include/mlir/IR/IntegerSet.h
@@ -131,10 +131,6 @@ namespace llvm {
// IntegerSet hash just like pointers.
template <>
struct DenseMapInfo<mlir::IntegerSet> {
- static mlir::IntegerSet getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::IntegerSet(static_cast<mlir::IntegerSet::ImplType *>(pointer));
- }
static unsigned getHashValue(mlir::IntegerSet val) {
return mlir::hash_value(val);
}
diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h
index 772a974950408..abc435b9b08ff 100644
--- a/mlir/include/mlir/IR/Location.h
+++ b/mlir/include/mlir/IR/Location.h
@@ -228,10 +228,6 @@ namespace llvm {
// Type hash just like pointers.
template <>
struct DenseMapInfo<mlir::Location> {
- static mlir::Location getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::Location::getFromOpaquePointer(pointer);
- }
static unsigned getHashValue(mlir::Location val) {
return mlir::hash_value(val);
}
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index a0a36f2bd53c4..bd7fa1ffd4428 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -2176,10 +2176,6 @@ template <typename T>
struct DenseMapInfo<T,
std::enable_if_t<std::is_base_of<mlir::OpState, T>::value &&
!mlir::detail::IsInterface<T>::value>> {
- static inline T getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return T::getFromOpaquePointer(pointer);
- }
static unsigned getHashValue(T val) {
return hash_value(val.getAsOpaquePointer());
}
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index 6142a986b89e0..6e0f001f83ba9 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -1844,10 +1844,6 @@ ParseResult parseDimensionList(OpAsmParser &parser,
namespace llvm {
template <>
struct DenseMapInfo<mlir::AsmDialectResourceHandle> {
- static inline mlir::AsmDialectResourceHandle getEmptyKey() {
- return {DenseMapInfo<void *>::getEmptyKey(),
- DenseMapInfo<mlir::TypeID>::getEmptyKey(), nullptr};
- }
static unsigned getHashValue(const mlir::AsmDialectResourceHandle &handle) {
return DenseMapInfo<void *>::getHashValue(handle.getResource());
}
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index f7d9c4f936b8f..942b55e8f7a76 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1451,10 +1451,6 @@ class OperationFingerPrint {
namespace llvm {
template <>
struct DenseMapInfo<mlir::OperationName> {
- static mlir::OperationName getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::OperationName::getFromOpaquePointer(pointer);
- }
static unsigned getHashValue(mlir::OperationName val) {
return DenseMapInfo<void *>::getHashValue(val.getAsOpaquePointer());
}
@@ -1465,10 +1461,6 @@ struct DenseMapInfo<mlir::OperationName> {
template <>
struct DenseMapInfo<mlir::RegisteredOperationName>
: public DenseMapInfo<mlir::OperationName> {
- static mlir::RegisteredOperationName getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::RegisteredOperationName::getFromOpaquePointer(pointer);
- }
};
template <>
diff --git a/mlir/include/mlir/IR/Remarks.h b/mlir/include/mlir/IR/Remarks.h
index 8390ac7520c6c..5cfb888be44a2 100644
--- a/mlir/include/mlir/IR/Remarks.h
+++ b/mlir/include/mlir/IR/Remarks.h
@@ -758,13 +758,6 @@ struct DenseMapInfo<mlir::remark::detail::Remark> {
}
/// Create an empty remark
- static inline mlir::remark::detail::Remark getEmptyKey() {
- return mlir::remark::detail::Remark(
- mlir::remark::RemarkKind::RemarkUnknown, mlir::DiagnosticSeverity::Note,
- mlir::UnknownLoc::get(getStaticDummyContext()),
- mlir::remark::RemarkOpts::name(kEmptyKey));
- }
-
/// Compute the hash value of the remark
static unsigned getHashValue(const mlir::remark::detail::Remark &remark) {
return llvm::hash_combine(
diff --git a/mlir/include/mlir/IR/TypeRange.h b/mlir/include/mlir/IR/TypeRange.h
index ffe49e6ca4e87..916d5788c36fa 100644
--- a/mlir/include/mlir/IR/TypeRange.h
+++ b/mlir/include/mlir/IR/TypeRange.h
@@ -205,29 +205,11 @@ namespace llvm {
// Provide DenseMapInfo for TypeRange.
template <>
struct DenseMapInfo<mlir::TypeRange> {
- static mlir::TypeRange getEmptyKey() {
- return mlir::TypeRange(getEmptyKeyPointer(), 0);
- }
-
static unsigned getHashValue(mlir::TypeRange val) { return hash_value(val); }
static bool isEqual(mlir::TypeRange lhs, mlir::TypeRange rhs) {
- if (isEmptyKey(rhs))
- return isEmptyKey(lhs);
return lhs == rhs;
}
-
-private:
- static const mlir::Type *getEmptyKeyPointer() {
- return DenseMapInfo<mlir::Type *>::getEmptyKey();
- }
-
- static bool isEmptyKey(mlir::TypeRange range) {
- if (const auto *type =
- llvm::dyn_cast_if_present<const mlir::Type *>(range.getBase()))
- return type == getEmptyKeyPointer();
- return false;
- }
};
} // namespace llvm
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index 3d010b234f49a..70599b448f76e 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -313,10 +313,6 @@ namespace llvm {
// Type hash just like pointers.
template <>
struct DenseMapInfo<mlir::Type> {
- static mlir::Type getEmptyKey() {
- auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::Type(static_cast<mlir::Type::ImplType *>(pointer));
- }
static unsigned getHashValue(mlir::Type val) { return mlir::hash_value(val); }
static bool isEqual(mlir::Type LHS, mlir::Type RHS) { return LHS == RHS; }
};
@@ -324,10 +320,6 @@ template <typename T>
struct DenseMapInfo<T, std::enable_if_t<std::is_base_of<mlir::Type, T>::value &&
!mlir::detail::IsInterface<T>::value>>
: public DenseMapInfo<mlir::Type> {
- static T getEmptyKey() {
- const void *pointer = llvm::DenseMapInfo<const void *>::getEmptyKey();
- return T::getFromOpaquePointer(pointer);
- }
};
/// We align TypeStorage by 8, so allow LLVM to steal the low bits.
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index 78061af400687..a34837bfcea1a 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -500,10 +500,6 @@ namespace llvm {
template <>
struct DenseMapInfo<mlir::Value> {
- static mlir::Value getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::Value::getFromOpaquePointer(pointer);
- }
static unsigned getHashValue(mlir::Value val) {
return mlir::hash_value(val);
}
@@ -511,25 +507,13 @@ struct DenseMapInfo<mlir::Value> {
};
template <>
struct DenseMapInfo<mlir::BlockArgument> : public DenseMapInfo<mlir::Value> {
- static mlir::BlockArgument getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return reinterpret_cast<mlir::detail::BlockArgumentImpl *>(pointer);
- }
};
template <>
struct DenseMapInfo<mlir::OpResult> : public DenseMapInfo<mlir::Value> {
- static mlir::OpResult getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
- }
};
template <typename T>
struct DenseMapInfo<mlir::detail::TypedValue<T>>
: public DenseMapInfo<mlir::Value> {
- static mlir::detail::TypedValue<T> getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return reinterpret_cast<mlir::detail::ValueImpl *>(pointer);
- }
};
/// Allow stealing the low bits of a value.
diff --git a/mlir/include/mlir/Pass/PassInstrumentation.h b/mlir/include/mlir/Pass/PassInstrumentation.h
index 6f121da843235..0247db6060e2e 100644
--- a/mlir/include/mlir/Pass/PassInstrumentation.h
+++ b/mlir/include/mlir/Pass/PassInstrumentation.h
@@ -135,10 +135,6 @@ struct DenseMapInfo<mlir::PassInstrumentation::PipelineParentInfo> {
using T = mlir::PassInstrumentation::PipelineParentInfo;
using PairInfo = DenseMapInfo<std::pair<uint64_t, void *>>;
- static T getEmptyKey() {
- auto pair = PairInfo::getEmptyKey();
- return {pair.first, reinterpret_cast<mlir::Pass *>(pair.second)};
- }
static unsigned getHashValue(T val) {
return PairInfo::getHashValue({val.parentThreadID, val.parentPass});
}
diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h
index 4f7f60f6dba1a..0f2a2bd060acd 100644
--- a/mlir/include/mlir/Pass/PassManager.h
+++ b/mlir/include/mlir/Pass/PassManager.h
@@ -487,10 +487,9 @@ class PassManager : public OpPassManager {
std::unique_ptr<detail::PassCrashReproducerGenerator> crashReproGenerator;
/// Hash keys used to detect when reinitialization is necessary.
- llvm::hash_code initializationKey =
- DenseMapInfo<llvm::hash_code>::getEmptyKey();
+ llvm::hash_code initializationKey = llvm::hash_code(static_cast<size_t>(-1));
llvm::hash_code pipelineInitializationKey =
- DenseMapInfo<llvm::hash_code>::getEmptyKey();
+ llvm::hash_code(static_cast<size_t>(-1));
/// Flag that specifies if pass timing is enabled.
bool passTiming : 1;
diff --git a/mlir/include/mlir/Support/InterfaceSupport.h b/mlir/include/mlir/Support/InterfaceSupport.h
index ddb1b2fe6856f..c70c081b7fcbc 100644
--- a/mlir/include/mlir/Support/InterfaceSupport.h
+++ b/mlir/include/mlir/Support/InterfaceSupport.h
@@ -298,8 +298,6 @@ template <typename T>
struct DenseMapInfo<T, std::enable_if_t<mlir::detail::IsInterface<T>::value>> {
using ValueTypeInfo = llvm::DenseMapInfo<typename T::ValueType>;
- static T getEmptyKey() { return T(ValueTypeInfo::getEmptyKey(), nullptr); }
-
static unsigned getHashValue(T val) {
return ValueTypeInfo::getHashValue(val);
}
diff --git a/mlir/include/mlir/Support/TypeID.h b/mlir/include/mlir/Support/TypeID.h
index 807a3ee391dc5..a3844178e11a0 100644
--- a/mlir/include/mlir/Support/TypeID.h
+++ b/mlir/include/mlir/Support/TypeID.h
@@ -394,10 +394,6 @@ MLIR_DECLARE_EXPLICIT_SELF_OWNING_TYPE_ID(void)
namespace llvm {
template <>
struct DenseMapInfo<mlir::TypeID> {
- static inline mlir::TypeID getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::TypeID::getFromOpaquePointer(pointer);
- }
static unsigned getHashValue(mlir::TypeID val) {
return mlir::hash_value(val);
}
diff --git a/mlir/include/mlir/TableGen/Constraint.h b/mlir/include/mlir/TableGen/Constraint.h
index 21438a9dd99ea..bf416d36f30f5 100644
--- a/mlir/include/mlir/TableGen/Constraint.h
+++ b/mlir/include/mlir/TableGen/Constraint.h
@@ -121,7 +121,6 @@ template <>
struct DenseMapInfo<mlir::tblgen::Constraint> {
using RecordDenseMapInfo = llvm::DenseMapInfo<const llvm::Record *>;
- static mlir::tblgen::Constraint getEmptyKey();
static unsigned getHashValue(mlir::tblgen::Constraint constraint);
static bool isEqual(mlir::tblgen::Constraint lhs,
mlir::tblgen::Constraint rhs);
diff --git a/mlir/include/mlir/TableGen/Format.h b/mlir/include/mlir/TableGen/Format.h
index e81195d9b77ca..e9f151e248340 100644
--- a/mlir/include/mlir/TableGen/Format.h
+++ b/mlir/include/mlir/TableGen/Format.h
@@ -68,9 +68,6 @@ class FmtContext {
struct PHKindInfo : DenseMapInfo<PHKind> {
using CharInfo = DenseMapInfo<char>;
- static inline PHKind getEmptyKey() {
- return static_cast<PHKind>(CharInfo::getEmptyKey());
- }
static unsigned getHashValue(const PHKind &val) {
return CharInfo::getHashValue(static_cast<char>(val));
}
diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h
index 66b272cb67dbd..16172fcfba6be 100644
--- a/mlir/include/mlir/TableGen/Pattern.h
+++ b/mlir/include/mlir/TableGen/Pattern.h
@@ -672,10 +672,6 @@ class Pattern {
namespace llvm {
template <>
struct DenseMapInfo<mlir::tblgen::DagNode> {
- static mlir::tblgen::DagNode getEmptyKey() {
- return mlir::tblgen::DagNode(
- llvm::DenseMapInfo<llvm::DagInit *>::getEmptyKey());
- }
static unsigned getHashValue(mlir::tblgen::DagNode node) {
return llvm::hash_value(node.getAsOpaquePointer());
}
@@ -686,10 +682,6 @@ struct DenseMapInfo<mlir::tblgen::DagNode> {
template <>
struct DenseMapInfo<mlir::tblgen::DagLeaf> {
- static mlir::tblgen::DagLeaf getEmptyKey() {
- return mlir::tblgen::DagLeaf(
- llvm::DenseMapInfo<llvm::Init *>::getEmptyKey());
- }
static unsigned getHashValue(mlir::tblgen::DagLeaf leaf) {
return llvm::hash_value(leaf.getAsOpaquePointer());
}
diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h
index 6e0ace101c654..2a61ab22c8e3f 100644
--- a/mlir/include/mlir/Tools/PDLL/AST/Types.h
+++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h
@@ -394,11 +394,6 @@ MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::ValueTypeStorage)
namespace llvm {
template <>
struct DenseMapInfo<mlir::pdll::ast::Type> {
- static mlir::pdll::ast::Type getEmptyKey() {
- void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
- return mlir::pdll::ast::Type(
- static_cast<mlir::pdll::ast::Type::Storage *>(pointer));
- }
static unsigned getHashValue(mlir::pdll::ast::Type val) {
return llvm::hash_value(val.getImpl());
}
diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
index 93f963753a6cf..23ce2eaba8286 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
@@ -767,7 +767,6 @@ struct OrderedPredicate {
struct OrderedPredicateDenseInfo {
using Base = DenseMapInfo<std::pair<Position *, Qualifier *>>;
- static OrderedPredicate getEmptyKey() { return Base::getEmptyKey(); }
static bool isEqual(const OrderedPredicate &lhs,
const OrderedPredicate &rhs) {
return lhs.position == rhs.position && lhs.question == rhs.question;
diff --git a/mlir/lib/Dialect/Func/Transforms/DuplicateFunctionElimination.cpp b/mlir/lib/Dialect/Func/Transforms/DuplicateFunctionElimination.cpp
index 6441504d9d297..a2186e433f544 100644
--- a/mlir/lib/Dialect/Func/Transforms/DuplicateFunctionElimination.cpp
+++ b/mlir/lib/Dialect/Func/Transforms/DuplicateFunctionElimination.cpp
@@ -53,9 +53,6 @@ struct DuplicateFuncOpEquivalenceInfo
static bool isEqual(func::FuncOp lhs, func::FuncOp rhs) {
if (lhs == rhs)
return true;
- if (lhs == getEmptyKey() || rhs == getEmptyKey())
- return false;
-
if (lhs.isDeclaration() || rhs.isDeclaration())
return false;
diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
index 4847de420c281..b33828d5d5867 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
@@ -261,8 +261,6 @@ struct UnrollTransferWritePattern
};
struct OffsetMapInfo {
- static SmallVector<int64_t> getEmptyKey() { return {int64_t(-1)}; }
-
static unsigned getHashValue(const SmallVector<int64_t> &v) {
return static_cast<unsigned>(llvm::hash_combine_range(v));
}
diff --git a/mlir/lib/Support/StorageUniquer.cpp b/mlir/lib/Support/StorageUniquer.cpp
index 71e0bf74ed402..ef7f19b9918d9 100644
--- a/mlir/lib/Support/StorageUniquer.cpp
+++ b/mlir/lib/Support/StorageUniquer.cpp
@@ -48,10 +48,6 @@ class ParametricStorageUniquer {
/// Storage info for derived TypeStorage objects.
struct StorageKeyInfo {
- static inline HashedStorage getEmptyKey() {
- return HashedStorage(0, DenseMapInfo<BaseStorage *>::getEmptyKey());
- }
-
static inline unsigned getHashValue(const HashedStorage &key) {
return key.hashValue;
}
@@ -64,8 +60,6 @@ class ParametricStorageUniquer {
return lhs.storage == rhs.storage;
}
static inline bool isEqual(const LookupKey &lhs, const HashedStorage &rhs) {
- if (isEqual(rhs, getEmptyKey()))
- return false;
// Invoke the equality function on the lookup key.
return lhs.isEqual(rhs.storage);
}
diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp
index 68452610c58fc..ca356a90bf534 100644
--- a/mlir/lib/TableGen/Constraint.cpp
+++ b/mlir/lib/TableGen/Constraint.cpp
@@ -125,24 +125,13 @@ AppliedConstraint::AppliedConstraint(Constraint &&constraint,
: constraint(constraint), self(std::string(self)),
entities(std::move(entities)) {}
-Constraint DenseMapInfo<Constraint>::getEmptyKey() {
- return Constraint(RecordDenseMapInfo::getEmptyKey(),
- Constraint::CK_Uncategorized);
-}
-
unsigned DenseMapInfo<Constraint>::getHashValue(Constraint constraint) {
- if (constraint == getEmptyKey())
- return RecordDenseMapInfo::getHashValue(RecordDenseMapInfo::getEmptyKey());
return llvm::hash_combine(constraint.getPredicate(), constraint.getSummary());
}
bool DenseMapInfo<Constraint>::isEqual(Constraint lhs, Constraint rhs) {
if (lhs == rhs)
return true;
- if (lhs == getEmptyKey())
- return false;
- if (rhs == getEmptyKey())
- return false;
return lhs.getPredicate() == rhs.getPredicate() &&
lhs.getSummary() == rhs.getSummary();
}
diff --git a/mlir/lib/Transforms/Utils/CFGToSCF.cpp b/mlir/lib/Transforms/Utils/CFGToSCF.cpp
index 6981c1e4837b3..0cc6bb43ddd38 100644
--- a/mlir/lib/Transforms/Utils/CFGToSCF.cpp
+++ b/mlir/lib/Transforms/Utils/CFGToSCF.cpp
@@ -404,8 +404,6 @@ struct ReturnLikeOpEquivalence : public llvm::DenseMapInfo<Operation *> {
static bool isEqual(const Operation *lhs, const Operation *rhs) {
if (lhs == rhs)
return true;
- if (lhs == getEmptyKey() || rhs == getEmptyKey())
- return false;
return OperationEquivalence::isEquivalentTo(
const_cast<Operation *>(lhs), const_cast<Operation *>(rhs),
OperationEquivalence::ignoreValueEquivalence, nullptr,
diff --git a/mlir/lib/Transforms/Utils/CSE.cpp b/mlir/lib/Transforms/Utils/CSE.cpp
index 612d3eac4dce4..6caaadca15d54 100644
--- a/mlir/lib/Transforms/Utils/CSE.cpp
+++ b/mlir/lib/Transforms/Utils/CSE.cpp
@@ -38,8 +38,6 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
auto *rhs = const_cast<Operation *>(rhsC);
if (lhs == rhs)
return true;
- if (lhs == getEmptyKey() || rhs == getEmptyKey())
- return false;
return OperationEquivalence::isEquivalentTo(
const_cast<Operation *>(lhsC), const_cast<Operation *>(rhsC),
OperationEquivalence::IgnoreLocations);
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index c0af1d59b4c18..c76e3808d3b37 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -123,7 +123,6 @@ namespace {
/// Helper class to make it possible to use `ValueVector` as a key in DenseMap.
struct ValueVectorMapInfo {
- static ValueVector getEmptyKey() { return ValueVector{Value()}; }
static ::llvm::hash_code getHashValue(const ValueVector &val) {
return ::llvm::hash_combine_range(val);
}
diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp
index 04f2a27cc1913..4b90082176dc0 100644
--- a/mlir/tools/mlir-tblgen/EnumsGen.cpp
+++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp
@@ -313,10 +313,6 @@ namespace llvm {
template<> struct DenseMapInfo<{0}> {{
using StorageInfo = ::llvm::DenseMapInfo<{1}>;
- static inline {0} getEmptyKey() {{
- return static_cast<{0}>(StorageInfo::getEmptyKey());
- }
-
static unsigned getHashValue(const {0} &val) {{
return StorageInfo::getHashValue(static_cast<{1}>(val));
}
More information about the Mlir-commits
mailing list