[llvm] 82e436c - [llvm] Remove unused DenseMapInfo::getEmptyKey (#201996)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 6 12:41:25 PDT 2026


Author: Fangrui Song
Date: 2026-06-06T19:41:20Z
New Revision: 82e436c17196b649ec5278ee51b995a8b9d0d309

URL: https://github.com/llvm/llvm-project/commit/82e436c17196b649ec5278ee51b995a8b9d0d309
DIFF: https://github.com/llvm/llvm-project/commit/82e436c17196b649ec5278ee51b995a8b9d0d309.diff

LOG: [llvm] Remove unused DenseMapInfo::getEmptyKey (#201996)

After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.

Added: 
    

Modified: 
    llvm/include/llvm/BinaryFormat/Minidump.h
    llvm/include/llvm/BinaryFormat/WasmTraits.h
    llvm/include/llvm/CAS/CASID.h
    llvm/include/llvm/CAS/CASReference.h
    llvm/include/llvm/CodeGenTypes/LowLevelType.h
    llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
    llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
    llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
    llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
    llvm/include/llvm/Frontend/OpenMP/OMPContext.h
    llvm/include/llvm/Linker/IRMover.h
    llvm/include/llvm/MC/MCRegister.h
    llvm/include/llvm/Object/ObjectFile.h
    llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
    llvm/include/llvm/ProfileData/FunctionId.h
    llvm/include/llvm/ProfileData/SampleProf.h
    llvm/include/llvm/SandboxIR/Context.h
    llvm/include/llvm/TextAPI/SymbolSet.h
    llvm/lib/Linker/IRMover.cpp
    llvm/lib/Object/Minidump.cpp
    llvm/tools/dsymutil/BinaryHolder.h
    llvm/tools/llvm-c-test/echo.cpp
    llvm/tools/llvm-reduce/deltas/Delta.h
    llvm/tools/llvm-split/llvm-split.cpp
    llvm/unittests/Object/MinidumpTest.cpp
    llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/BinaryFormat/Minidump.h b/llvm/include/llvm/BinaryFormat/Minidump.h
index 012838af2e7aa..4e96b54415e84 100644
--- a/llvm/include/llvm/BinaryFormat/Minidump.h
+++ b/llvm/include/llvm/BinaryFormat/Minidump.h
@@ -270,8 +270,6 @@ static_assert(sizeof(ExceptionStream) == 168);
 } // namespace minidump
 
 template <> struct DenseMapInfo<minidump::StreamType> {
-  static minidump::StreamType getEmptyKey() { return minidump::StreamType(-1); }
-
   static unsigned getHashValue(minidump::StreamType Val) {
     return DenseMapInfo<uint32_t>::getHashValue(static_cast<uint32_t>(Val));
   }

diff  --git a/llvm/include/llvm/BinaryFormat/WasmTraits.h b/llvm/include/llvm/BinaryFormat/WasmTraits.h
index 35bd89067a880..46eae5bb4302c 100644
--- a/llvm/include/llvm/BinaryFormat/WasmTraits.h
+++ b/llvm/include/llvm/BinaryFormat/WasmTraits.h
@@ -20,11 +20,6 @@ namespace llvm {
 
 // Traits for using WasmSignature in a DenseMap.
 template <> struct DenseMapInfo<wasm::WasmSignature, void> {
-  static wasm::WasmSignature getEmptyKey() {
-    wasm::WasmSignature Sig;
-    Sig.State = wasm::WasmSignature::Empty;
-    return Sig;
-  }
   static unsigned getHashValue(const wasm::WasmSignature &Sig) {
     uintptr_t H = hash_value(Sig.State);
     for (auto Ret : Sig.Returns)
@@ -41,9 +36,6 @@ template <> struct DenseMapInfo<wasm::WasmSignature, void> {
 
 // Traits for using WasmGlobalType in a DenseMap
 template <> struct DenseMapInfo<wasm::WasmGlobalType, void> {
-  static wasm::WasmGlobalType getEmptyKey() {
-    return wasm::WasmGlobalType{1, true};
-  }
   static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType) {
     return hash_combine(GlobalType.Type, GlobalType.Mutable);
   }
@@ -55,9 +47,6 @@ template <> struct DenseMapInfo<wasm::WasmGlobalType, void> {
 
 // Traits for using WasmLimits in a DenseMap
 template <> struct DenseMapInfo<wasm::WasmLimits, void> {
-  static wasm::WasmLimits getEmptyKey() {
-    return wasm::WasmLimits{0xff, 0xff, 0xff, 0xff};
-  }
   static unsigned getHashValue(const wasm::WasmLimits &Limits) {
     unsigned Hash = hash_value(Limits.Flags);
     Hash = hash_combine(Hash, Limits.Minimum);
@@ -74,10 +63,6 @@ template <> struct DenseMapInfo<wasm::WasmLimits, void> {
 
 // Traits for using WasmTableType in a DenseMap
 template <> struct DenseMapInfo<wasm::WasmTableType, void> {
-  static wasm::WasmTableType getEmptyKey() {
-    return wasm::WasmTableType{
-        wasm::ValType(0), DenseMapInfo<wasm::WasmLimits, void>::getEmptyKey()};
-  }
   static unsigned getHashValue(const wasm::WasmTableType &TableType) {
     return hash_combine(
         TableType.ElemType,

diff  --git a/llvm/include/llvm/CAS/CASID.h b/llvm/include/llvm/CAS/CASID.h
index 81a7089a2ca05..45f4cf15965f9 100644
--- a/llvm/include/llvm/CAS/CASID.h
+++ b/llvm/include/llvm/CAS/CASID.h
@@ -80,7 +80,7 @@ class CASID {
     if (LHS.Context == RHS.Context)
       return LHS.Hash == RHS.Hash;
 
-    // EmptyKey or TombstoneKey.
+    // TombstoneKey.
     if (!LHS.Context || !RHS.Context)
       return false;
 
@@ -99,13 +99,10 @@ class CASID {
   }
 
   const CASContext &getContext() const {
-    assert(Context && "Tombstone or empty key for DenseMap?");
+    assert(Context && "Tombstone key for DenseMap?");
     return *Context;
   }
 
-  static CASID getDenseMapEmptyKey() {
-    return CASID(nullptr, DenseMapInfo<StringRef>::getEmptyKey());
-  }
   static CASID getDenseMapTombstoneKey() {
     // A reserved StringRef value distinct from the empty key, used only as a
     // DenseMap sentinel for CASID.
@@ -132,8 +129,6 @@ class CASID {
 } // namespace cas
 
 template <> struct DenseMapInfo<cas::CASID> {
-  static cas::CASID getEmptyKey() { return cas::CASID::getDenseMapEmptyKey(); }
-
   static unsigned getHashValue(cas::CASID ID) {
     return (unsigned)hash_value(ID);
   }

diff  --git a/llvm/include/llvm/CAS/CASReference.h b/llvm/include/llvm/CAS/CASReference.h
index 04242f55499bc..cdf251219290c 100644
--- a/llvm/include/llvm/CAS/CASReference.h
+++ b/llvm/include/llvm/CAS/CASReference.h
@@ -26,7 +26,6 @@ class ObjectRef;
 /// Base class for references to things in \a ObjectStore.
 class ReferenceBase {
 protected:
-  struct DenseMapEmptyTag {};
   static constexpr uint64_t getDenseMapEmptyRef() { return -1ULL; }
   static constexpr uint64_t getDenseMapTombstoneRef() { return -2ULL; }
 
@@ -75,8 +74,6 @@ class ReferenceBase {
     assert(InternalRef != getDenseMapTombstoneRef() &&
            "Reserved for DenseMapInfo");
   }
-  explicit ReferenceBase(DenseMapEmptyTag)
-      : InternalRef(getDenseMapEmptyRef()) {}
 
 private:
   uint64_t InternalRef;
@@ -103,8 +100,6 @@ class ReferenceBase {
 /// ObjectStore::getReferenceKind() can expect the type of reference without
 /// asking for unloaded objects to be loaded.
 class ObjectRef : public ReferenceBase {
-  struct DenseMapTag {};
-
 public:
   friend bool operator==(const ObjectRef &LHS, const ObjectRef &RHS) {
     return LHS.hasSameInternalRef(RHS);
@@ -113,10 +108,6 @@ class ObjectRef : public ReferenceBase {
     return !(LHS == RHS);
   }
 
-  static ObjectRef getDenseMapEmptyKey() {
-    return ObjectRef(DenseMapEmptyTag{});
-  }
-
   /// Print internal ref and/or CASID. Only suitable for debugging.
   void print(raw_ostream &OS) const { return ReferenceBase::print(OS, *this); }
 
@@ -131,7 +122,6 @@ class ObjectRef : public ReferenceBase {
     assert(InternalRef != -1ULL && "Reserved for DenseMapInfo");
     assert(InternalRef != -2ULL && "Reserved for DenseMapInfo");
   }
-  explicit ObjectRef(DenseMapEmptyTag T) : ReferenceBase(T) {}
   explicit ObjectRef(ReferenceBase) = delete;
 };
 
@@ -166,10 +156,6 @@ class ObjectHandle : public ReferenceBase {
 } // namespace cas
 
 template <> struct DenseMapInfo<cas::ObjectRef> {
-  static cas::ObjectRef getEmptyKey() {
-    return cas::ObjectRef::getDenseMapEmptyKey();
-  }
-
   static unsigned getHashValue(cas::ObjectRef Ref) {
     return Ref.getDenseMapHash();
   }

diff  --git a/llvm/include/llvm/CodeGenTypes/LowLevelType.h b/llvm/include/llvm/CodeGenTypes/LowLevelType.h
index f91a9fe6c50fd..c3277ba95f86f 100644
--- a/llvm/include/llvm/CodeGenTypes/LowLevelType.h
+++ b/llvm/include/llvm/CodeGenTypes/LowLevelType.h
@@ -717,11 +717,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const LLT &Ty) {
 }
 
 template <> struct DenseMapInfo<LLT> {
-  static inline LLT getEmptyKey() {
-    LLT Invalid;
-    Invalid.Info = LLT::Kind::POINTER;
-    return Invalid;
-  }
   static inline unsigned getHashValue(const LLT &Ty) {
     uint64_t Val = Ty.getUniqueRAWLLTData();
     return DenseMapInfo<uint64_t>::getHashValue(Val);

diff  --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
index 34977cbe4eb8d..d16387b28d332 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
@@ -172,15 +172,11 @@ class DeclContextTree {
 
 /// Info type for the DenseMap storing the DeclContext pointers.
 struct DeclMapInfo : private DenseMapInfo<DeclContext *> {
-  using DenseMapInfo<DeclContext *>::getEmptyKey;
-
   static unsigned getHashValue(const DeclContext *Ctxt) {
     return Ctxt->QualifiedNameHash;
   }
 
   static bool isEqual(const DeclContext *LHS, const DeclContext *RHS) {
-    if (RHS == getEmptyKey())
-      return RHS == LHS;
     return LHS->QualifiedNameHash == RHS->QualifiedNameHash &&
            LHS->Line == RHS->Line && LHS->ByteSize == RHS->ByteSize &&
            LHS->NameForUniquing.data() == RHS->NameForUniquing.data() &&

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
index 9c72b28d1169f..688d0bc1da0f2 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
@@ -344,10 +344,6 @@ using SPSExecutorAddrRangeSequence = SPSSequence<SPSExecutorAddrRange>;
 
 // Provide DenseMapInfo for ExecutorAddrs.
 template <> struct DenseMapInfo<orc::ExecutorAddr> {
-  static inline orc::ExecutorAddr getEmptyKey() {
-    return orc::ExecutorAddr(DenseMapInfo<uint64_t>::getEmptyKey());
-  }
-
   static unsigned getHashValue(const orc::ExecutorAddr &Addr) {
     return DenseMapInfo<uint64_t>::getHashValue(Addr.getValue());
   }

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
index 696632e9132f7..4952106610af6 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
@@ -209,7 +209,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, AllocGroup AG) {
 } // end namespace orc
 
 template <> struct DenseMapInfo<orc::MemProt> {
-  static inline orc::MemProt getEmptyKey() { return orc::MemProt(~uint8_t(0)); }
   static unsigned getHashValue(const orc::MemProt &Val) {
     using UT = std::underlying_type_t<orc::MemProt>;
     return DenseMapInfo<UT>::getHashValue(static_cast<UT>(Val));
@@ -220,9 +219,6 @@ template <> struct DenseMapInfo<orc::MemProt> {
 };
 
 template <> struct DenseMapInfo<orc::AllocGroup> {
-  static inline orc::AllocGroup getEmptyKey() {
-    return orc::AllocGroup(~uint8_t(0));
-  }
   static unsigned getHashValue(const orc::AllocGroup &Val) {
     return DenseMapInfo<orc::AllocGroup::underlying_type>::getHashValue(Val.Id);
   }

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h b/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
index 48be96d98d100..4b53de6af77bb 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
@@ -115,14 +115,6 @@ class SymbolStringPtrBase {
 
   SymbolStringPtrBase(PoolEntryPtr S) : S(S) {}
 
-  constexpr static uintptr_t EmptyBitPattern =
-      std::numeric_limits<uintptr_t>::max()
-      << PointerLikeTypeTraits<PoolEntryPtr>::NumLowBitsAvailable;
-
-  constexpr static uintptr_t TombstoneBitPattern =
-      (std::numeric_limits<uintptr_t>::max() - 1)
-      << PointerLikeTypeTraits<PoolEntryPtr>::NumLowBitsAvailable;
-
   constexpr static uintptr_t InvalidPtrMask =
       (std::numeric_limits<uintptr_t>::max() - 3)
       << PointerLikeTypeTraits<PoolEntryPtr>::NumLowBitsAvailable;
@@ -187,14 +179,6 @@ class SymbolStringPtr : public SymbolStringPtrBase {
       --S->getValue();
     }
   }
-
-  static SymbolStringPtr getEmptyVal() {
-    return SymbolStringPtr(reinterpret_cast<PoolEntryPtr>(EmptyBitPattern));
-  }
-
-  static SymbolStringPtr getTombstoneVal() {
-    return SymbolStringPtr(reinterpret_cast<PoolEntryPtr>(TombstoneBitPattern));
-  }
 };
 
 /// Provides unsafe access to ownership operations on SymbolStringPtr.
@@ -262,16 +246,6 @@ class NonOwningSymbolStringPtr : public SymbolStringPtrBase {
 
 private:
   NonOwningSymbolStringPtr(PoolEntryPtr S) : SymbolStringPtrBase(S) {}
-
-  static NonOwningSymbolStringPtr getEmptyVal() {
-    return NonOwningSymbolStringPtr(
-        reinterpret_cast<PoolEntryPtr>(EmptyBitPattern));
-  }
-
-  static NonOwningSymbolStringPtr getTombstoneVal() {
-    return NonOwningSymbolStringPtr(
-        reinterpret_cast<PoolEntryPtr>(TombstoneBitPattern));
-  }
 };
 
 inline SymbolStringPtr::SymbolStringPtr(NonOwningSymbolStringPtr Other)
@@ -329,10 +303,6 @@ inline hash_code hash_value(const orc::SymbolStringPtrBase &S) {
 template <>
 struct DenseMapInfo<orc::SymbolStringPtr> {
 
-  static orc::SymbolStringPtr getEmptyKey() {
-    return orc::SymbolStringPtr::getEmptyVal();
-  }
-
   static unsigned getHashValue(const orc::SymbolStringPtrBase &V) {
     return DenseMapInfo<orc::SymbolStringPtr::PoolEntryPtr>::getHashValue(V.S);
   }
@@ -345,10 +315,6 @@ struct DenseMapInfo<orc::SymbolStringPtr> {
 
 template <> struct DenseMapInfo<orc::NonOwningSymbolStringPtr> {
 
-  static orc::NonOwningSymbolStringPtr getEmptyKey() {
-    return orc::NonOwningSymbolStringPtr::getEmptyVal();
-  }
-
   static unsigned getHashValue(const orc::SymbolStringPtrBase &V) {
     return DenseMapInfo<
         orc::NonOwningSymbolStringPtr::PoolEntryPtr>::getHashValue(V.S);

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPContext.h b/llvm/include/llvm/Frontend/OpenMP/OMPContext.h
index 83ad94f13dda4..7849d32665994 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPContext.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPContext.h
@@ -202,9 +202,6 @@ getBestVariantMatchForContext(const SmallVectorImpl<VariantMatchInfo> &VMIs,
 } // namespace omp
 
 template <> struct DenseMapInfo<omp::TraitProperty> {
-  static inline omp::TraitProperty getEmptyKey() {
-    return omp::TraitProperty(-1);
-  }
   static unsigned getHashValue(omp::TraitProperty val) {
     return std::hash<unsigned>{}(unsigned(val));
   }

diff  --git a/llvm/include/llvm/Linker/IRMover.h b/llvm/include/llvm/Linker/IRMover.h
index ce3509330d329..0ec8a51ed570d 100644
--- a/llvm/include/llvm/Linker/IRMover.h
+++ b/llvm/include/llvm/Linker/IRMover.h
@@ -38,7 +38,6 @@ class IRMover {
       LLVM_ABI bool operator==(const KeyTy &that) const;
       LLVM_ABI bool operator!=(const KeyTy &that) const;
     };
-    LLVM_ABI static StructType *getEmptyKey();
     LLVM_ABI static unsigned getHashValue(const KeyTy &Key);
     LLVM_ABI static unsigned getHashValue(const StructType *ST);
     LLVM_ABI static bool isEqual(const KeyTy &LHS, const StructType *RHS);

diff  --git a/llvm/include/llvm/MC/MCRegister.h b/llvm/include/llvm/MC/MCRegister.h
index 60bfacf82a799..c176904be35c3 100644
--- a/llvm/include/llvm/MC/MCRegister.h
+++ b/llvm/include/llvm/MC/MCRegister.h
@@ -109,9 +109,6 @@ class MCRegister {
 
 // Provide DenseMapInfo for MCRegister
 template <> struct DenseMapInfo<MCRegister> {
-  static inline MCRegister getEmptyKey() {
-    return DenseMapInfo<unsigned>::getEmptyKey();
-  }
   static unsigned getHashValue(const MCRegister &Val) {
     return DenseMapInfo<unsigned>::getHashValue(Val.id());
   }

diff  --git a/llvm/include/llvm/Object/ObjectFile.h b/llvm/include/llvm/Object/ObjectFile.h
index 823b6a7e51f84..89ab7a70de55b 100644
--- a/llvm/include/llvm/Object/ObjectFile.h
+++ b/llvm/include/llvm/Object/ObjectFile.h
@@ -653,9 +653,6 @@ template <> struct DenseMapInfo<object::SectionRef> {
                       const object::SectionRef &B) {
     return A == B;
   }
-  static object::SectionRef getEmptyKey() {
-    return object::SectionRef({}, nullptr);
-  }
   static unsigned getHashValue(const object::SectionRef &Sec) {
     object::DataRefImpl Raw = Sec.getRawDataRefImpl();
     return hash_combine(Raw.p, Raw.d.a, Raw.d.b);

diff  --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
index ccd7ebd6fd75e..a664b6b5fa560 100644
--- a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
+++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
@@ -1525,15 +1525,7 @@ template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
 } // end namespace coverage
 
 /// Provide DenseMapInfo for CounterExpression
-template<> struct DenseMapInfo<coverage::CounterExpression> {
-  static inline coverage::CounterExpression getEmptyKey() {
-    using namespace coverage;
-
-    return CounterExpression(CounterExpression::ExprKind::Subtract,
-                             Counter::getCounter(~0U),
-                             Counter::getCounter(~0U));
-  }
-
+template <> struct DenseMapInfo<coverage::CounterExpression> {
   static unsigned getHashValue(const coverage::CounterExpression &V) {
     return static_cast<unsigned>(
         hash_combine(V.Kind, V.LHS.getKind(), V.LHS.getCounterID(),

diff  --git a/llvm/include/llvm/ProfileData/FunctionId.h b/llvm/include/llvm/ProfileData/FunctionId.h
index 5f8248111a1bb..ef43573da8b49 100644
--- a/llvm/include/llvm/ProfileData/FunctionId.h
+++ b/llvm/include/llvm/ProfileData/FunctionId.h
@@ -178,10 +178,6 @@ inline uint64_t hash_value(const FunctionId &Obj) {
 /// containers.
 template <> struct DenseMapInfo<sampleprof::FunctionId, void> {
 
-  static inline sampleprof::FunctionId getEmptyKey() {
-    return sampleprof::FunctionId(~0ULL);
-  }
-
   static unsigned getHashValue(const sampleprof::FunctionId &Val) {
     return Val.getHashCode();
   }

diff  --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index 97fe3acbfec9d..534c97b295bc5 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -1704,8 +1704,6 @@ class ProfileSymbolList {
 using namespace sampleprof;
 // Provide DenseMapInfo for SampleContext.
 template <> struct DenseMapInfo<SampleContext> {
-  static inline SampleContext getEmptyKey() { return SampleContext(); }
-
   static unsigned getHashValue(const SampleContext &Val) {
     return Val.getHashCode();
   }

diff  --git a/llvm/include/llvm/SandboxIR/Context.h b/llvm/include/llvm/SandboxIR/Context.h
index 9afc47fc29fc0..750892eb84933 100644
--- a/llvm/include/llvm/SandboxIR/Context.h
+++ b/llvm/include/llvm/SandboxIR/Context.h
@@ -318,9 +318,6 @@ template <> struct DenseMapInfo<sandboxir::Context::CallbackID> {
   using CallbackID = sandboxir::Context::CallbackID;
   using ReprInfo = DenseMapInfo<CallbackID::ValTy>;
 
-  static CallbackID getEmptyKey() {
-    return CallbackID{ReprInfo::getEmptyKey()};
-  }
   static unsigned getHashValue(const CallbackID &ID) {
     return ReprInfo::getHashValue(ID.Val);
   }

diff  --git a/llvm/include/llvm/TextAPI/SymbolSet.h b/llvm/include/llvm/TextAPI/SymbolSet.h
index a5890d19d9ca9..9c7a11899e8cf 100644
--- a/llvm/include/llvm/TextAPI/SymbolSet.h
+++ b/llvm/include/llvm/TextAPI/SymbolSet.h
@@ -31,10 +31,6 @@ struct SymbolsMapKey {
       : Kind(Kind), Name(Name) {}
 };
 template <> struct DenseMapInfo<SymbolsMapKey> {
-  static inline SymbolsMapKey getEmptyKey() {
-    return SymbolsMapKey(MachO::EncodeKind::GlobalSymbol, StringRef{});
-  }
-
   static unsigned getHashValue(const SymbolsMapKey &Key) {
     return hash_combine(hash_value(Key.Kind), hash_value(Key.Name));
   }

diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 57911ef50335d..239201bde1cec 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1613,10 +1613,6 @@ bool IRMover::StructTypeKeyInfo::KeyTy::operator!=(const KeyTy &That) const {
   return !this->operator==(That);
 }
 
-StructType *IRMover::StructTypeKeyInfo::getEmptyKey() {
-  return DenseMapInfo<StructType *>::getEmptyKey();
-}
-
 unsigned IRMover::StructTypeKeyInfo::getHashValue(const KeyTy &Key) {
   return hash_combine(hash_combine_range(Key.ETypes), Key.IsPacked);
 }
@@ -1627,15 +1623,11 @@ unsigned IRMover::StructTypeKeyInfo::getHashValue(const StructType *ST) {
 
 bool IRMover::StructTypeKeyInfo::isEqual(const KeyTy &LHS,
                                          const StructType *RHS) {
-  if (RHS == getEmptyKey())
-    return false;
   return LHS == KeyTy(RHS);
 }
 
 bool IRMover::StructTypeKeyInfo::isEqual(const StructType *LHS,
                                          const StructType *RHS) {
-  if (RHS == getEmptyKey())
-    return LHS == RHS;
   return KeyTy(LHS) == KeyTy(RHS);
 }
 

diff  --git a/llvm/lib/Object/Minidump.cpp b/llvm/lib/Object/Minidump.cpp
index caa38bff1666b..1c69687dc47f3 100644
--- a/llvm/lib/Object/Minidump.cpp
+++ b/llvm/lib/Object/Minidump.cpp
@@ -129,9 +129,6 @@ MinidumpFile::create(MemoryBufferRef Source) {
       continue;
     }
 
-    if (Type == DenseMapInfo<StreamType>::getEmptyKey())
-      return createError("Cannot handle one of the minidump streams");
-
     // Update the directory map, checking for duplicate stream types.
     if (!StreamMap.try_emplace(Type, StreamDescriptor.index()).second)
       return createError("Duplicate stream type");

diff  --git a/llvm/tools/dsymutil/BinaryHolder.h b/llvm/tools/dsymutil/BinaryHolder.h
index 86f7cab95fc8b..75f0090571a9b 100644
--- a/llvm/tools/dsymutil/BinaryHolder.h
+++ b/llvm/tools/dsymutil/BinaryHolder.h
@@ -157,10 +157,6 @@ class BinaryHolder {
 
 template <> struct DenseMapInfo<dsymutil::BinaryHolder::ArchiveEntry::KeyTy> {
 
-  static inline dsymutil::BinaryHolder::ArchiveEntry::KeyTy getEmptyKey() {
-    return dsymutil::BinaryHolder::ArchiveEntry::KeyTy();
-  }
-
   static unsigned
   getHashValue(const dsymutil::BinaryHolder::ArchiveEntry::KeyTy &K) {
     return hash_combine(DenseMapInfo<StringRef>::getHashValue(K.Filename),

diff  --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp
index 58376039f91ee..1574d0ffe84cc 100644
--- a/llvm/tools/llvm-c-test/echo.cpp
+++ b/llvm/tools/llvm-c-test/echo.cpp
@@ -38,10 +38,6 @@ struct CAPIDenseMap {};
 template<typename T>
 struct CAPIDenseMap<T*> {
   struct CAPIDenseMapInfo {
-    static inline T* getEmptyKey() {
-      uintptr_t Val = static_cast<uintptr_t>(-1);
-      return reinterpret_cast<T*>(Val);
-    }
     static unsigned getHashValue(const T *PtrVal) {
       return hash_value(PtrVal);
     }

diff  --git a/llvm/tools/llvm-reduce/deltas/Delta.h b/llvm/tools/llvm-reduce/deltas/Delta.h
index 533b30bcc77e2..2e3929a5dde96 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.h
+++ b/llvm/tools/llvm-reduce/deltas/Delta.h
@@ -55,13 +55,7 @@ struct Chunk {
   }
 };
 
-template<>
-struct DenseMapInfo<Chunk> {
-  static inline Chunk getEmptyKey() {
-    return {DenseMapInfo<int>::getEmptyKey(),
-            DenseMapInfo<int>::getEmptyKey()};
-  }
-
+template <> struct DenseMapInfo<Chunk> {
   static unsigned getHashValue(const Chunk Val) {
     std::pair<int, int> PairVal = std::make_pair(Val.Begin, Val.End);
     return DenseMapInfo<std::pair<int, int>>::getHashValue(PairVal);
@@ -72,7 +66,6 @@ struct DenseMapInfo<Chunk> {
   }
 };
 
-
 /// Provides opaque interface for querying into ChunksToKeep without having to
 /// actually understand what is going on.
 class Oracle {

diff  --git a/llvm/tools/llvm-split/llvm-split.cpp b/llvm/tools/llvm-split/llvm-split.cpp
index e95a507c0f1ca..e7c9d52127274 100644
--- a/llvm/tools/llvm-split/llvm-split.cpp
+++ b/llvm/tools/llvm-split/llvm-split.cpp
@@ -189,8 +189,6 @@ class EntryPointCategorizer {
 
 private:
   struct KeyInfo {
-    static SmallString<0> getEmptyKey() { return SmallString<0>(""); }
-
     static bool isEqual(const SmallString<0> &LHS, const SmallString<0> &RHS) {
       return LHS == RHS;
     }

diff  --git a/llvm/unittests/Object/MinidumpTest.cpp b/llvm/unittests/Object/MinidumpTest.cpp
index 44a9661bd3f34..6e7b88cf0fccb 100644
--- a/llvm/unittests/Object/MinidumpTest.cpp
+++ b/llvm/unittests/Object/MinidumpTest.cpp
@@ -164,8 +164,13 @@ TEST(MinidumpFile, create_ErrorCases) {
                                             // Stream
       'C', 'P', 'U', 'I', 'N', 'F', 'O'};
   EXPECT_THAT_EXPECTED(create(DuplicateStream), Failed<BinaryError>());
+}
 
-  std::vector<uint8_t> DenseMapInfoConflict{
+// A stream type equal to the value DenseMapInfo<StreamType> historically
+// reserved as its empty key (-1) used to be rejected. DenseMap no longer
+// reserves that value, so such a stream is now handled like any other.
+TEST(MinidumpFile, StreamTypeReservedDenseMapKey) {
+  std::vector<uint8_t> Data{
       // Header
       'M', 'D', 'M', 'P', 0x93, 0xa7, 0, 0, // Signature, Version
       1, 0, 0, 0,                           // NumberOfStreams,
@@ -177,7 +182,13 @@ TEST(MinidumpFile, create_ErrorCases) {
       0x2c, 0, 0, 0,                        // RVA
                                             // Stream
       'C', 'P', 'U', 'I', 'N', 'F', 'O'};
-  EXPECT_THAT_EXPECTED(create(DenseMapInfoConflict), Failed<BinaryError>());
+  auto ExpectedFile = create(Data);
+  ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+  const MinidumpFile &File = **ExpectedFile;
+  ASSERT_EQ(1u, File.streams().size());
+  const Directory &Stream0 = File.streams()[0];
+  EXPECT_EQ(StreamType(0xffffffff), Stream0.Type);
+  EXPECT_EQ("CPUINFO", toStringRef(File.getRawStream(Stream0)));
 }
 
 TEST(MinidumpFile, IngoresDummyStreams) {

diff  --git a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
index 891a8d598fbe4..9f986aa9069c9 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
@@ -47,11 +47,6 @@ inline bool operator==(PredicateWithCC LHS, PredicateWithCC RHS) {
 
 namespace llvm {
 template <> struct DenseMapInfo<PredicateWithCC, void> {
-  static inline PredicateWithCC getEmptyKey() {
-    return DenseMapInfo<
-        std::pair<const Record *, const Record *>>::getEmptyKey();
-  }
-
   static unsigned getHashValue(const PredicateWithCC Val) {
     auto Pair = std::make_pair(Val.Predicate, Val.CallingConv);
     return DenseMapInfo<


        


More information about the llvm-commits mailing list