Skip to content

[ADT] Remove unused DenseMapInfo::getTombstoneKey#200959

Merged
MaskRay merged 2 commits into
llvm:mainfrom
MaskRay:pr/drop-tombstone-llvm-adt
Jun 2, 2026
Merged

[ADT] Remove unused DenseMapInfo::getTombstoneKey#200959
MaskRay merged 2 commits into
llvm:mainfrom
MaskRay:pr/drop-tombstone-llvm-adt

Conversation

@MaskRay
Copy link
Copy Markdown
Member

@MaskRay MaskRay commented Jun 1, 2026

#200595 changed DenseMap to no longer create tombstone buckets, so
DenseMapInfo::getTombstoneKey() is never called. Remove dead
definitions and dead tombstone branches.

llvm#200595 changed DenseMap to no longer create tombstone buckets, so
DenseMapInfo<T>::getTombstoneKey() is never called. Remove dead
definitions and dead tombstone branches.
@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-support

Author: Fangrui Song (MaskRay)

Changes

#200595 changed DenseMap to no longer create tombstone buckets, so
DenseMapInfo<T>::getTombstoneKey() is never called. Remove dead
definitions and dead tombstone branches.


Patch is 26.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/200959.diff

26 Files Affected:

  • (modified) llvm/include/llvm/ADT/APFixedPoint.h (-8)
  • (modified) llvm/include/llvm/ADT/APInt.h (-6)
  • (modified) llvm/include/llvm/ADT/APSInt.h (-4)
  • (modified) llvm/include/llvm/ADT/ArrayRef.h (-9)
  • (modified) llvm/include/llvm/ADT/BitVector.h (-13)
  • (modified) llvm/include/llvm/ADT/CachedHashString.h (+12-28)
  • (modified) llvm/include/llvm/ADT/DenseMapInfo.h (-32)
  • (modified) llvm/include/llvm/ADT/DenseMapInfoVariant.h (-5)
  • (modified) llvm/include/llvm/ADT/Hashing.h (-1)
  • (modified) llvm/include/llvm/ADT/ImmutableList.h (-4)
  • (modified) llvm/include/llvm/ADT/PointerEmbeddedInt.h (-1)
  • (modified) llvm/include/llvm/ADT/PointerIntPair.h (-6)
  • (modified) llvm/include/llvm/ADT/PointerSumType.h (-5)
  • (modified) llvm/include/llvm/ADT/PointerUnion.h (-4)
  • (modified) llvm/include/llvm/ADT/SmallBitVector.h (-13)
  • (modified) llvm/include/llvm/ADT/SmallVector.h (-4)
  • (modified) llvm/include/llvm/ADT/StringRef.h (-7)
  • (modified) llvm/include/llvm/Support/FileSystem/UniqueID.h (-6)
  • (modified) llvm/include/llvm/Support/TypeSize.h (-3)
  • (modified) llvm/include/llvm/Support/UniqueBBID.h (-5)
  • (modified) llvm/include/llvm/Support/VersionTuple.h (-3)
  • (modified) llvm/lib/Support/StringRef.cpp (+1-4)
  • (modified) llvm/unittests/ADT/DenseMapTest.cpp (-5)
  • (modified) llvm/unittests/ADT/DenseSetTest.cpp (-4)
  • (modified) llvm/unittests/ADT/MapVectorTest.cpp (-1)
  • (modified) llvm/unittests/Support/ReverseIterationTest.cpp (-5)
diff --git a/llvm/include/llvm/ADT/APFixedPoint.h b/llvm/include/llvm/ADT/APFixedPoint.h
index 0a47cd50516d4..790a5e775fb56 100644
--- a/llvm/include/llvm/ADT/APFixedPoint.h
+++ b/llvm/include/llvm/ADT/APFixedPoint.h
@@ -143,10 +143,6 @@ template <> struct DenseMapInfo<FixedPointSemantics> {
     return FixedPointSemantics(0, 0, false, false, false);
   }
 
-  static inline FixedPointSemantics getTombstoneKey() {
-    return FixedPointSemantics(0, 1, false, false, false);
-  }
-
   static unsigned getHashValue(const FixedPointSemantics &Val) {
     return hash_value(Val);
   }
@@ -323,10 +319,6 @@ template <> struct DenseMapInfo<APFixedPoint> {
     return APFixedPoint(DenseMapInfo<FixedPointSemantics>::getEmptyKey());
   }
 
-  static inline APFixedPoint getTombstoneKey() {
-    return APFixedPoint(DenseMapInfo<FixedPointSemantics>::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const APFixedPoint &Val) {
     return hash_value(Val);
   }
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index e8d806cf78578..1a4788248e554 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -2533,12 +2533,6 @@ template <> struct DenseMapInfo<APInt, void> {
     return V;
   }
 
-  static inline APInt getTombstoneKey() {
-    APInt V(nullptr, 0);
-    V.U.VAL = ~1ULL;
-    return V;
-  }
-
   LLVM_ABI static unsigned getHashValue(const APInt &Key);
 
   static bool isEqual(const APInt &LHS, const APInt &RHS) {
diff --git a/llvm/include/llvm/ADT/APSInt.h b/llvm/include/llvm/ADT/APSInt.h
index aca0579b3e796..c5f8ad731bdb0 100644
--- a/llvm/include/llvm/ADT/APSInt.h
+++ b/llvm/include/llvm/ADT/APSInt.h
@@ -371,10 +371,6 @@ template <> struct DenseMapInfo<APSInt, void> {
     return APSInt(DenseMapInfo<APInt, void>::getEmptyKey());
   }
 
-  static inline APSInt getTombstoneKey() {
-    return APSInt(DenseMapInfo<APInt, void>::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const APSInt &Key) {
     return DenseMapInfo<APInt, void>::getHashValue(Key);
   }
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index cf2c6d85dc272..badac76affdc9 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -569,23 +569,14 @@ template <typename T> struct DenseMapInfo<ArrayRef<T>, void> {
                        size_t(0));
   }
 
-  static inline ArrayRef<T> getTombstoneKey() {
-    return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)),
-                       size_t(0));
-  }
-
   static unsigned getHashValue(ArrayRef<T> Val) {
     assert(Val.data() != getEmptyKey().data() && "Cannot hash the empty key!");
-    assert(Val.data() != getTombstoneKey().data() &&
-           "Cannot hash the tombstone key!");
     return (unsigned)(hash_value(Val));
   }
 
   static bool isEqual(ArrayRef<T> LHS, ArrayRef<T> RHS) {
     if (RHS.data() == getEmptyKey().data())
       return LHS.data() == getEmptyKey().data();
-    if (RHS.data() == getTombstoneKey().data())
-      return LHS.data() == getTombstoneKey().data();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index 48b75b045cfbf..72c8a84c15ecf 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -705,12 +705,6 @@ class BitVector {
     std::swap(Size, RHS.Size);
   }
 
-  void invalid() {
-    assert(!Size && Bits.empty());
-    Size = (unsigned)-1;
-  }
-  bool isInvalid() const { return Size == (unsigned)-1; }
-
   ArrayRef<BitWord> getData() const { return {Bits.data(), Bits.size()}; }
 
   //===--------------------------------------------------------------------===//
@@ -854,18 +848,11 @@ inline BitVector::size_type capacity_in_bytes(const BitVector &X) {
 
 template <> struct DenseMapInfo<BitVector> {
   static inline BitVector getEmptyKey() { return {}; }
-  static inline BitVector getTombstoneKey() {
-    BitVector V;
-    V.invalid();
-    return V;
-  }
   static unsigned getHashValue(const BitVector &V) {
     return DenseMapInfo<std::pair<BitVector::size_type, ArrayRef<uintptr_t>>>::
         getHashValue(std::make_pair(V.size(), V.getData()));
   }
   static bool isEqual(const BitVector &LHS, const BitVector &RHS) {
-    if (LHS.isInvalid() || RHS.isInvalid())
-      return LHS.isInvalid() == RHS.isInvalid();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/ADT/CachedHashString.h b/llvm/include/llvm/ADT/CachedHashString.h
index ebd40e3207156..cc26216176198 100644
--- a/llvm/include/llvm/ADT/CachedHashString.h
+++ b/llvm/include/llvm/ADT/CachedHashString.h
@@ -12,8 +12,8 @@
 /// their string data.
 ///
 /// Unlike std::string, CachedHashString can be used in DenseSet/DenseMap
-/// (because, unlike std::string, CachedHashString lets us have empty and
-/// tombstone values).
+/// (because, unlike std::string, CachedHashString lets us have an empty
+/// value).
 ///
 //===----------------------------------------------------------------------===//
 
@@ -51,12 +51,8 @@ template <> struct DenseMapInfo<CachedHashStringRef> {
   static CachedHashStringRef getEmptyKey() {
     return CachedHashStringRef(DenseMapInfo<StringRef>::getEmptyKey(), 0);
   }
-  static CachedHashStringRef getTombstoneKey() {
-    return CachedHashStringRef(DenseMapInfo<StringRef>::getTombstoneKey(), 1);
-  }
   static unsigned getHashValue(const CachedHashStringRef &S) {
     assert(!isEqual(S, getEmptyKey()) && "Cannot hash the empty key!");
-    assert(!isEqual(S, getTombstoneKey()) && "Cannot hash the tombstone key!");
     return S.hash();
   }
   static bool isEqual(const CachedHashStringRef &LHS,
@@ -77,19 +73,14 @@ class CachedHashString {
   uint32_t Hash;
 
   static char *getEmptyKeyPtr() { return DenseMapInfo<char *>::getEmptyKey(); }
-  static char *getTombstoneKeyPtr() {
-    return DenseMapInfo<char *>::getTombstoneKey();
-  }
 
-  bool isEmptyOrTombstone() const {
-    return P == getEmptyKeyPtr() || P == getTombstoneKeyPtr();
-  }
+  bool isEmpty() const { return P == getEmptyKeyPtr(); }
 
-  struct ConstructEmptyOrTombstoneTy {};
+  struct ConstructEmptyTy {};
 
-  CachedHashString(ConstructEmptyOrTombstoneTy, char *EmptyOrTombstonePtr)
-      : P(EmptyOrTombstonePtr), Size(0), Hash(0) {
-    assert(isEmptyOrTombstone());
+  CachedHashString(ConstructEmptyTy, char *EmptyKeyPtr)
+      : P(EmptyKeyPtr), Size(0), Hash(0) {
+    assert(isEmpty());
   }
 
   // TODO: Use small-string optimization to avoid allocating.
@@ -110,7 +101,7 @@ class CachedHashString {
   // keys, and we want this to be usable there.
   CachedHashString(const CachedHashString &Other)
       : Size(Other.Size), Hash(Other.Hash) {
-    if (Other.isEmptyOrTombstone()) {
+    if (Other.isEmpty()) {
       P = Other.P;
     } else {
       P = new char[Size];
@@ -129,7 +120,7 @@ class CachedHashString {
   }
 
   ~CachedHashString() {
-    if (!isEmptyOrTombstone())
+    if (!isEmpty())
       delete[] P;
   }
 
@@ -152,16 +143,11 @@ class CachedHashString {
 
 template <> struct DenseMapInfo<CachedHashString> {
   static CachedHashString getEmptyKey() {
-    return CachedHashString(CachedHashString::ConstructEmptyOrTombstoneTy(),
+    return CachedHashString(CachedHashString::ConstructEmptyTy(),
                             CachedHashString::getEmptyKeyPtr());
   }
-  static CachedHashString getTombstoneKey() {
-    return CachedHashString(CachedHashString::ConstructEmptyOrTombstoneTy(),
-                            CachedHashString::getTombstoneKeyPtr());
-  }
   static unsigned getHashValue(const CachedHashString &S) {
     assert(!isEqual(S, getEmptyKey()) && "Cannot hash the empty key!");
-    assert(!isEqual(S, getTombstoneKey()) && "Cannot hash the tombstone key!");
     return S.hash();
   }
   static bool isEqual(const CachedHashString &LHS,
@@ -170,11 +156,9 @@ template <> struct DenseMapInfo<CachedHashString> {
       return false;
     if (LHS.P == CachedHashString::getEmptyKeyPtr())
       return RHS.P == CachedHashString::getEmptyKeyPtr();
-    if (LHS.P == CachedHashString::getTombstoneKeyPtr())
-      return RHS.P == CachedHashString::getTombstoneKeyPtr();
 
-    // This is safe because if RHS.P is the empty or tombstone key, it will have
-    // length 0, so we'll never dereference its pointer.
+    // This is safe because if RHS.P is the empty key, it will have length 0, so
+    // we'll never dereference its pointer.
     return LHS.val() == RHS.val();
   }
 };
diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h
index 832c12fc6482c..e8e21e4a15e66 100644
--- a/llvm/include/llvm/ADT/DenseMapInfo.h
+++ b/llvm/include/llvm/ADT/DenseMapInfo.h
@@ -53,7 +53,6 @@ inline unsigned combineHashValue(unsigned a, unsigned b) {
 template<typename T, typename Enable = void>
 struct DenseMapInfo {
   // static constexpr T getEmptyKey();
-  // static constexpr T getTombstoneKey();
   // static unsigned getHashValue(const T &Val);
   // static bool isEqual(const T &LHS, const T &RHS);
 };
@@ -77,12 +76,6 @@ struct DenseMapInfo<T*> {
     return reinterpret_cast<T*>(Val);
   }
 
-  static constexpr T *getTombstoneKey() {
-    uintptr_t Val = static_cast<uintptr_t>(-2);
-    Val <<= Log2MaxAlign;
-    return reinterpret_cast<T*>(Val);
-  }
-
   static unsigned getHashValue(const T *PtrVal) {
     return densemap::detail::mix(reinterpret_cast<uintptr_t>(PtrVal));
   }
@@ -93,7 +86,6 @@ struct DenseMapInfo<T*> {
 // Provide DenseMapInfo for chars.
 template<> struct DenseMapInfo<char> {
   static constexpr char getEmptyKey() { return ~0; }
-  static constexpr char getTombstoneKey() { return ~0 - 1; }
   static unsigned getHashValue(const char& Val) { return Val * 37U; }
 
   static bool isEqual(const char &LHS, const char &RHS) {
@@ -112,13 +104,6 @@ struct DenseMapInfo<
     T, std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, char>>> {
   static constexpr T getEmptyKey() { return std::numeric_limits<T>::max(); }
 
-  static constexpr T getTombstoneKey() {
-    if constexpr (std::is_unsigned_v<T> || std::is_same_v<T, long>)
-      return std::numeric_limits<T>::max() - 1;
-    else
-      return std::numeric_limits<T>::min();
-  }
-
   static unsigned getHashValue(const T &Val) {
     if constexpr (std::is_unsigned_v<T> && sizeof(T) > sizeof(unsigned))
       return densemap::detail::mix(Val);
@@ -141,10 +126,6 @@ struct DenseMapInfo<std::pair<T, U>> {
     return {FirstInfo::getEmptyKey(), SecondInfo::getEmptyKey()};
   }
 
-  static constexpr Pair getTombstoneKey() {
-    return {FirstInfo::getTombstoneKey(), SecondInfo::getTombstoneKey()};
-  }
-
   static unsigned getHashValue(const Pair& PairVal) {
     return detail::combineHashValue(FirstInfo::getHashValue(PairVal.first),
                                     SecondInfo::getHashValue(PairVal.second));
@@ -172,10 +153,6 @@ template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
     return Tuple(DenseMapInfo<Ts>::getEmptyKey()...);
   }
 
-  static constexpr Tuple getTombstoneKey() {
-    return Tuple(DenseMapInfo<Ts>::getTombstoneKey()...);
-  }
-
   template <unsigned I> static unsigned getHashValueImpl(const Tuple &values) {
     if constexpr (I == sizeof...(Ts)) {
       return 0;
@@ -223,11 +200,6 @@ struct DenseMapInfo<Enum, std::enable_if_t<std::is_enum_v<Enum>>> {
     return V;
   }
 
-  static constexpr Enum getTombstoneKey() {
-    constexpr Enum V = static_cast<Enum>(Info::getTombstoneKey());
-    return V;
-  }
-
   static unsigned getHashValue(const Enum &Val) {
     return Info::getHashValue(static_cast<UnderlyingType>(Val));
   }
@@ -241,10 +213,6 @@ template <typename T> struct DenseMapInfo<std::optional<T>> {
 
   static constexpr Optional getEmptyKey() { return {Info::getEmptyKey()}; }
 
-  static constexpr Optional getTombstoneKey() {
-    return {Info::getTombstoneKey()};
-  }
-
   static unsigned getHashValue(const Optional &OptionalVal) {
     return detail::combineHashValue(
         OptionalVal.has_value(),
diff --git a/llvm/include/llvm/ADT/DenseMapInfoVariant.h b/llvm/include/llvm/ADT/DenseMapInfoVariant.h
index a97f9b9566c81..9729f2a300098 100644
--- a/llvm/include/llvm/ADT/DenseMapInfoVariant.h
+++ b/llvm/include/llvm/ADT/DenseMapInfoVariant.h
@@ -29,11 +29,6 @@ template <typename... Ts> struct DenseMapInfo<std::variant<Ts...>> {
     return Variant(std::in_place_index<0>, DenseMapInfo<FirstT>::getEmptyKey());
   }
 
-  static inline Variant getTombstoneKey() {
-    return Variant(std::in_place_index<0>,
-                   DenseMapInfo<FirstT>::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const Variant &Val) {
     return std::visit(
         [&Val](auto &&Alternative) {
diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index 6d679d815a417..5565b09543233 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -392,7 +392,6 @@ template <typename T> hash_code hash_value(const std::optional<T> &arg) {
 
 template <> struct DenseMapInfo<hash_code, void> {
   static constexpr hash_code getEmptyKey() { return hash_code(-1); }
-  static constexpr hash_code getTombstoneKey() { return hash_code(-2); }
   static constexpr unsigned getHashValue(hash_code val) {
     return static_cast<unsigned>(size_t(val));
   }
diff --git a/llvm/include/llvm/ADT/ImmutableList.h b/llvm/include/llvm/ADT/ImmutableList.h
index c9c289ca4dfa1..ef3f8a21db470 100644
--- a/llvm/include/llvm/ADT/ImmutableList.h
+++ b/llvm/include/llvm/ADT/ImmutableList.h
@@ -224,10 +224,6 @@ template <typename T> struct DenseMapInfo<ImmutableList<T>, void> {
     return reinterpret_cast<ImmutableListImpl<T>*>(-1);
   }
 
-  static inline ImmutableList<T> getTombstoneKey() {
-    return reinterpret_cast<ImmutableListImpl<T>*>(-2);
-  }
-
   static unsigned getHashValue(ImmutableList<T> X) {
     uintptr_t PtrVal = reinterpret_cast<uintptr_t>(X.getInternalPointer());
     return (unsigned((uintptr_t)PtrVal) >> 4) ^
diff --git a/llvm/include/llvm/ADT/PointerEmbeddedInt.h b/llvm/include/llvm/ADT/PointerEmbeddedInt.h
index 04a2b7bff78e0..76b03a40a9e27 100644
--- a/llvm/include/llvm/ADT/PointerEmbeddedInt.h
+++ b/llvm/include/llvm/ADT/PointerEmbeddedInt.h
@@ -102,7 +102,6 @@ struct DenseMapInfo<PointerEmbeddedInt<IntT, Bits>> {
   using IntInfo = DenseMapInfo<IntT>;
 
   static inline T getEmptyKey() { return IntInfo::getEmptyKey(); }
-  static inline T getTombstoneKey() { return IntInfo::getTombstoneKey(); }
 
   static unsigned getHashValue(const T &Arg) {
     return IntInfo::getHashValue(Arg);
diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index 75e3a58e7ca61..db6714ffcfe91 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -223,12 +223,6 @@ struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType>, void> {
     return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
   }
 
-  static Ty getTombstoneKey() {
-    uintptr_t Val = static_cast<uintptr_t>(-2);
-    Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
-    return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
-  }
-
   static unsigned getHashValue(Ty V) {
     uintptr_t IV = reinterpret_cast<uintptr_t>(V.getOpaqueValue());
     return unsigned(IV) ^ unsigned(IV >> 9);
diff --git a/llvm/include/llvm/ADT/PointerSumType.h b/llvm/include/llvm/ADT/PointerSumType.h
index c8e6cffd796a6..beaaf49a32b52 100644
--- a/llvm/include/llvm/ADT/PointerSumType.h
+++ b/llvm/include/llvm/ADT/PointerSumType.h
@@ -259,11 +259,6 @@ struct DenseMapInfo<PointerSumType<TagT, MemberTs...>> {
     return SumType::template create<SomeTag>(SomePointerInfo::getEmptyKey());
   }
 
-  static inline SumType getTombstoneKey() {
-    return SumType::template create<SomeTag>(
-        SomePointerInfo::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const SumType &Arg) {
     uintptr_t OpaqueValue = Arg.getOpaqueValue();
     return DenseMapInfo<uintptr_t>::getHashValue(OpaqueValue);
diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index 52cb12168f9b7..15565ee3ff51a 100644
--- a/llvm/include/llvm/ADT/PointerUnion.h
+++ b/llvm/include/llvm/ADT/PointerUnion.h
@@ -428,10 +428,6 @@ template <typename... PTs> struct DenseMapInfo<PointerUnion<PTs...>> {
 
   static inline Union getEmptyKey() { return Union(FirstInfo::getEmptyKey()); }
 
-  static inline Union getTombstoneKey() {
-    return Union(FirstInfo::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const Union &UnionVal) {
     auto Key = reinterpret_cast<uintptr_t>(UnionVal.getOpaqueValue());
     return DenseMapInfo<uintptr_t>::getHashValue(Key);
diff --git a/llvm/include/llvm/ADT/SmallBitVector.h b/llvm/include/llvm/ADT/SmallBitVector.h
index 978dc3f073031..78049cbb44da5 100644
--- a/llvm/include/llvm/ADT/SmallBitVector.h
+++ b/llvm/include/llvm/ADT/SmallBitVector.h
@@ -683,12 +683,6 @@ class SmallBitVector {
       getPointer()->clearBitsNotInMask(Mask, MaskWords);
   }
 
-  void invalid() {
-    assert(empty());
-    X = (uintptr_t)-1;
-  }
-  bool isInvalid() const { return X == (uintptr_t)-1; }
-
   ArrayRef<uintptr_t> getData(uintptr_t &Store) const {
     if (!isSmall())
       return getPointer()->getData();
@@ -735,11 +729,6 @@ operator^(const SmallBitVector &LHS, const SmallBitVector &RHS) {
 
 template <> struct DenseMapInfo<SmallBitVector> {
   static inline SmallBitVector getEmptyKey() { return SmallBitVector(); }
-  static inline SmallBitVector getTombstoneKey() {
-    SmallBitVector V;
-    V.invalid();
-    return V;
-  }
   static unsigned getHashValue(const SmallBitVector &V) {
     uintptr_t Store;
     return DenseMapInfo<
@@ -747,8 +736,6 @@ template <> struct DenseMapInfo<SmallBitVector> {
         getHashValue(std::make_pair(V.size(), V.getData(Store)));
   }
   static bool isEqual(const SmallBitVector &LHS, const SmallBitVector &RHS) {
-    if (LHS.isInvalid() || RHS.isInvalid())
-      return LHS.isInvalid() == RHS.isInvalid();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 3d655daea471b..7e375792df4c0 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -1353,10 +1353,6 @@ template <typename T, unsigned N> struct DenseMapInfo<llvm::SmallVector<T, N>> {
     return {DenseMapInfo<T>::getEmptyKey()};
   }
 
-  static SmallVector<T, N> getTombstoneKey() {
-    return {DenseMapInfo<T>::getTombstoneKey()};
-  }
-
   static unsigned getHashValue(const SmallVector<T, N> &V) {
     return static_cast<unsigned>(hash_combine_range(V));
   }
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 5421224e6a1d3..f15e120451638 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -956,18 +956,11 @@ template <> struct DenseMapInfo<StringRef, void> {
                      0);
   }
 
-  static inline StringRef getTombstoneKey() {
-    return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)),
-                     0);
-  }
-
   LLVM_ABI static unsigned getHashValue(StringRef Val);
 
   static bool isEqual(StringRef LHS, StringRef RHS) {
     if (RHS.data() == getEmptyKey().data())
       return LHS.data() == getEmptyKey().data();
-    if (RHS.data() == getTombstoneKey().data())
-      return LHS.data() == getTombstoneKey().data();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/Support/FileSystem/UniqueID.h b/llvm/include/llvm/Support/FileSystem/UniqueID.h
index 0d5367236e8dc..3bfd8b7405505 100644
--- a/llvm/include/llvm/Support/FileSystem/UniqueID.h
+++ b/llvm/include/llvm/Support/FileSystem/UniqueID.h
@@ -58,12 +58,6 @@ template <> struct DenseMapInfo<llvm::sys::fs::UniqueID> {
     return {EmptyKey.first, EmptyKey.second};
   }
 
-  static inline llvm::sys::fs::UniqueID getTombstoneKey() {
-    auto TombstoneKey =
-        DenseMapInfo<std::pair<uint64_t, uint64_t>>::getTombstoneKey();
-    return {TombstoneKey.first, TombstoneKey.second};
-  }
-
   static hash_code getHashValue(const llvm::sys::fs::UniqueID &Tag) {
     return hash_value(std::make_pair(Tag.getDevice(), Tag.getFile()));
   }
diff --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h
index 421d6613bfafc..c60bae2872f92 100644
--- a/llvm/include/llvm/Support/TypeSize.h
+++ b/llvm/include/llvm/Suppo...
[truncated]

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-adt

Author: Fangrui Song (MaskRay)

Changes

#200595 changed DenseMap to no longer create tombstone buckets, so
DenseMapInfo<T>::getTombstoneKey() is never called. Remove dead
definitions and dead tombstone branches.


Patch is 26.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/200959.diff

26 Files Affected:

  • (modified) llvm/include/llvm/ADT/APFixedPoint.h (-8)
  • (modified) llvm/include/llvm/ADT/APInt.h (-6)
  • (modified) llvm/include/llvm/ADT/APSInt.h (-4)
  • (modified) llvm/include/llvm/ADT/ArrayRef.h (-9)
  • (modified) llvm/include/llvm/ADT/BitVector.h (-13)
  • (modified) llvm/include/llvm/ADT/CachedHashString.h (+12-28)
  • (modified) llvm/include/llvm/ADT/DenseMapInfo.h (-32)
  • (modified) llvm/include/llvm/ADT/DenseMapInfoVariant.h (-5)
  • (modified) llvm/include/llvm/ADT/Hashing.h (-1)
  • (modified) llvm/include/llvm/ADT/ImmutableList.h (-4)
  • (modified) llvm/include/llvm/ADT/PointerEmbeddedInt.h (-1)
  • (modified) llvm/include/llvm/ADT/PointerIntPair.h (-6)
  • (modified) llvm/include/llvm/ADT/PointerSumType.h (-5)
  • (modified) llvm/include/llvm/ADT/PointerUnion.h (-4)
  • (modified) llvm/include/llvm/ADT/SmallBitVector.h (-13)
  • (modified) llvm/include/llvm/ADT/SmallVector.h (-4)
  • (modified) llvm/include/llvm/ADT/StringRef.h (-7)
  • (modified) llvm/include/llvm/Support/FileSystem/UniqueID.h (-6)
  • (modified) llvm/include/llvm/Support/TypeSize.h (-3)
  • (modified) llvm/include/llvm/Support/UniqueBBID.h (-5)
  • (modified) llvm/include/llvm/Support/VersionTuple.h (-3)
  • (modified) llvm/lib/Support/StringRef.cpp (+1-4)
  • (modified) llvm/unittests/ADT/DenseMapTest.cpp (-5)
  • (modified) llvm/unittests/ADT/DenseSetTest.cpp (-4)
  • (modified) llvm/unittests/ADT/MapVectorTest.cpp (-1)
  • (modified) llvm/unittests/Support/ReverseIterationTest.cpp (-5)
diff --git a/llvm/include/llvm/ADT/APFixedPoint.h b/llvm/include/llvm/ADT/APFixedPoint.h
index 0a47cd50516d4..790a5e775fb56 100644
--- a/llvm/include/llvm/ADT/APFixedPoint.h
+++ b/llvm/include/llvm/ADT/APFixedPoint.h
@@ -143,10 +143,6 @@ template <> struct DenseMapInfo<FixedPointSemantics> {
     return FixedPointSemantics(0, 0, false, false, false);
   }
 
-  static inline FixedPointSemantics getTombstoneKey() {
-    return FixedPointSemantics(0, 1, false, false, false);
-  }
-
   static unsigned getHashValue(const FixedPointSemantics &Val) {
     return hash_value(Val);
   }
@@ -323,10 +319,6 @@ template <> struct DenseMapInfo<APFixedPoint> {
     return APFixedPoint(DenseMapInfo<FixedPointSemantics>::getEmptyKey());
   }
 
-  static inline APFixedPoint getTombstoneKey() {
-    return APFixedPoint(DenseMapInfo<FixedPointSemantics>::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const APFixedPoint &Val) {
     return hash_value(Val);
   }
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index e8d806cf78578..1a4788248e554 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -2533,12 +2533,6 @@ template <> struct DenseMapInfo<APInt, void> {
     return V;
   }
 
-  static inline APInt getTombstoneKey() {
-    APInt V(nullptr, 0);
-    V.U.VAL = ~1ULL;
-    return V;
-  }
-
   LLVM_ABI static unsigned getHashValue(const APInt &Key);
 
   static bool isEqual(const APInt &LHS, const APInt &RHS) {
diff --git a/llvm/include/llvm/ADT/APSInt.h b/llvm/include/llvm/ADT/APSInt.h
index aca0579b3e796..c5f8ad731bdb0 100644
--- a/llvm/include/llvm/ADT/APSInt.h
+++ b/llvm/include/llvm/ADT/APSInt.h
@@ -371,10 +371,6 @@ template <> struct DenseMapInfo<APSInt, void> {
     return APSInt(DenseMapInfo<APInt, void>::getEmptyKey());
   }
 
-  static inline APSInt getTombstoneKey() {
-    return APSInt(DenseMapInfo<APInt, void>::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const APSInt &Key) {
     return DenseMapInfo<APInt, void>::getHashValue(Key);
   }
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index cf2c6d85dc272..badac76affdc9 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -569,23 +569,14 @@ template <typename T> struct DenseMapInfo<ArrayRef<T>, void> {
                        size_t(0));
   }
 
-  static inline ArrayRef<T> getTombstoneKey() {
-    return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)),
-                       size_t(0));
-  }
-
   static unsigned getHashValue(ArrayRef<T> Val) {
     assert(Val.data() != getEmptyKey().data() && "Cannot hash the empty key!");
-    assert(Val.data() != getTombstoneKey().data() &&
-           "Cannot hash the tombstone key!");
     return (unsigned)(hash_value(Val));
   }
 
   static bool isEqual(ArrayRef<T> LHS, ArrayRef<T> RHS) {
     if (RHS.data() == getEmptyKey().data())
       return LHS.data() == getEmptyKey().data();
-    if (RHS.data() == getTombstoneKey().data())
-      return LHS.data() == getTombstoneKey().data();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index 48b75b045cfbf..72c8a84c15ecf 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -705,12 +705,6 @@ class BitVector {
     std::swap(Size, RHS.Size);
   }
 
-  void invalid() {
-    assert(!Size && Bits.empty());
-    Size = (unsigned)-1;
-  }
-  bool isInvalid() const { return Size == (unsigned)-1; }
-
   ArrayRef<BitWord> getData() const { return {Bits.data(), Bits.size()}; }
 
   //===--------------------------------------------------------------------===//
@@ -854,18 +848,11 @@ inline BitVector::size_type capacity_in_bytes(const BitVector &X) {
 
 template <> struct DenseMapInfo<BitVector> {
   static inline BitVector getEmptyKey() { return {}; }
-  static inline BitVector getTombstoneKey() {
-    BitVector V;
-    V.invalid();
-    return V;
-  }
   static unsigned getHashValue(const BitVector &V) {
     return DenseMapInfo<std::pair<BitVector::size_type, ArrayRef<uintptr_t>>>::
         getHashValue(std::make_pair(V.size(), V.getData()));
   }
   static bool isEqual(const BitVector &LHS, const BitVector &RHS) {
-    if (LHS.isInvalid() || RHS.isInvalid())
-      return LHS.isInvalid() == RHS.isInvalid();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/ADT/CachedHashString.h b/llvm/include/llvm/ADT/CachedHashString.h
index ebd40e3207156..cc26216176198 100644
--- a/llvm/include/llvm/ADT/CachedHashString.h
+++ b/llvm/include/llvm/ADT/CachedHashString.h
@@ -12,8 +12,8 @@
 /// their string data.
 ///
 /// Unlike std::string, CachedHashString can be used in DenseSet/DenseMap
-/// (because, unlike std::string, CachedHashString lets us have empty and
-/// tombstone values).
+/// (because, unlike std::string, CachedHashString lets us have an empty
+/// value).
 ///
 //===----------------------------------------------------------------------===//
 
@@ -51,12 +51,8 @@ template <> struct DenseMapInfo<CachedHashStringRef> {
   static CachedHashStringRef getEmptyKey() {
     return CachedHashStringRef(DenseMapInfo<StringRef>::getEmptyKey(), 0);
   }
-  static CachedHashStringRef getTombstoneKey() {
-    return CachedHashStringRef(DenseMapInfo<StringRef>::getTombstoneKey(), 1);
-  }
   static unsigned getHashValue(const CachedHashStringRef &S) {
     assert(!isEqual(S, getEmptyKey()) && "Cannot hash the empty key!");
-    assert(!isEqual(S, getTombstoneKey()) && "Cannot hash the tombstone key!");
     return S.hash();
   }
   static bool isEqual(const CachedHashStringRef &LHS,
@@ -77,19 +73,14 @@ class CachedHashString {
   uint32_t Hash;
 
   static char *getEmptyKeyPtr() { return DenseMapInfo<char *>::getEmptyKey(); }
-  static char *getTombstoneKeyPtr() {
-    return DenseMapInfo<char *>::getTombstoneKey();
-  }
 
-  bool isEmptyOrTombstone() const {
-    return P == getEmptyKeyPtr() || P == getTombstoneKeyPtr();
-  }
+  bool isEmpty() const { return P == getEmptyKeyPtr(); }
 
-  struct ConstructEmptyOrTombstoneTy {};
+  struct ConstructEmptyTy {};
 
-  CachedHashString(ConstructEmptyOrTombstoneTy, char *EmptyOrTombstonePtr)
-      : P(EmptyOrTombstonePtr), Size(0), Hash(0) {
-    assert(isEmptyOrTombstone());
+  CachedHashString(ConstructEmptyTy, char *EmptyKeyPtr)
+      : P(EmptyKeyPtr), Size(0), Hash(0) {
+    assert(isEmpty());
   }
 
   // TODO: Use small-string optimization to avoid allocating.
@@ -110,7 +101,7 @@ class CachedHashString {
   // keys, and we want this to be usable there.
   CachedHashString(const CachedHashString &Other)
       : Size(Other.Size), Hash(Other.Hash) {
-    if (Other.isEmptyOrTombstone()) {
+    if (Other.isEmpty()) {
       P = Other.P;
     } else {
       P = new char[Size];
@@ -129,7 +120,7 @@ class CachedHashString {
   }
 
   ~CachedHashString() {
-    if (!isEmptyOrTombstone())
+    if (!isEmpty())
       delete[] P;
   }
 
@@ -152,16 +143,11 @@ class CachedHashString {
 
 template <> struct DenseMapInfo<CachedHashString> {
   static CachedHashString getEmptyKey() {
-    return CachedHashString(CachedHashString::ConstructEmptyOrTombstoneTy(),
+    return CachedHashString(CachedHashString::ConstructEmptyTy(),
                             CachedHashString::getEmptyKeyPtr());
   }
-  static CachedHashString getTombstoneKey() {
-    return CachedHashString(CachedHashString::ConstructEmptyOrTombstoneTy(),
-                            CachedHashString::getTombstoneKeyPtr());
-  }
   static unsigned getHashValue(const CachedHashString &S) {
     assert(!isEqual(S, getEmptyKey()) && "Cannot hash the empty key!");
-    assert(!isEqual(S, getTombstoneKey()) && "Cannot hash the tombstone key!");
     return S.hash();
   }
   static bool isEqual(const CachedHashString &LHS,
@@ -170,11 +156,9 @@ template <> struct DenseMapInfo<CachedHashString> {
       return false;
     if (LHS.P == CachedHashString::getEmptyKeyPtr())
       return RHS.P == CachedHashString::getEmptyKeyPtr();
-    if (LHS.P == CachedHashString::getTombstoneKeyPtr())
-      return RHS.P == CachedHashString::getTombstoneKeyPtr();
 
-    // This is safe because if RHS.P is the empty or tombstone key, it will have
-    // length 0, so we'll never dereference its pointer.
+    // This is safe because if RHS.P is the empty key, it will have length 0, so
+    // we'll never dereference its pointer.
     return LHS.val() == RHS.val();
   }
 };
diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h
index 832c12fc6482c..e8e21e4a15e66 100644
--- a/llvm/include/llvm/ADT/DenseMapInfo.h
+++ b/llvm/include/llvm/ADT/DenseMapInfo.h
@@ -53,7 +53,6 @@ inline unsigned combineHashValue(unsigned a, unsigned b) {
 template<typename T, typename Enable = void>
 struct DenseMapInfo {
   // static constexpr T getEmptyKey();
-  // static constexpr T getTombstoneKey();
   // static unsigned getHashValue(const T &Val);
   // static bool isEqual(const T &LHS, const T &RHS);
 };
@@ -77,12 +76,6 @@ struct DenseMapInfo<T*> {
     return reinterpret_cast<T*>(Val);
   }
 
-  static constexpr T *getTombstoneKey() {
-    uintptr_t Val = static_cast<uintptr_t>(-2);
-    Val <<= Log2MaxAlign;
-    return reinterpret_cast<T*>(Val);
-  }
-
   static unsigned getHashValue(const T *PtrVal) {
     return densemap::detail::mix(reinterpret_cast<uintptr_t>(PtrVal));
   }
@@ -93,7 +86,6 @@ struct DenseMapInfo<T*> {
 // Provide DenseMapInfo for chars.
 template<> struct DenseMapInfo<char> {
   static constexpr char getEmptyKey() { return ~0; }
-  static constexpr char getTombstoneKey() { return ~0 - 1; }
   static unsigned getHashValue(const char& Val) { return Val * 37U; }
 
   static bool isEqual(const char &LHS, const char &RHS) {
@@ -112,13 +104,6 @@ struct DenseMapInfo<
     T, std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, char>>> {
   static constexpr T getEmptyKey() { return std::numeric_limits<T>::max(); }
 
-  static constexpr T getTombstoneKey() {
-    if constexpr (std::is_unsigned_v<T> || std::is_same_v<T, long>)
-      return std::numeric_limits<T>::max() - 1;
-    else
-      return std::numeric_limits<T>::min();
-  }
-
   static unsigned getHashValue(const T &Val) {
     if constexpr (std::is_unsigned_v<T> && sizeof(T) > sizeof(unsigned))
       return densemap::detail::mix(Val);
@@ -141,10 +126,6 @@ struct DenseMapInfo<std::pair<T, U>> {
     return {FirstInfo::getEmptyKey(), SecondInfo::getEmptyKey()};
   }
 
-  static constexpr Pair getTombstoneKey() {
-    return {FirstInfo::getTombstoneKey(), SecondInfo::getTombstoneKey()};
-  }
-
   static unsigned getHashValue(const Pair& PairVal) {
     return detail::combineHashValue(FirstInfo::getHashValue(PairVal.first),
                                     SecondInfo::getHashValue(PairVal.second));
@@ -172,10 +153,6 @@ template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
     return Tuple(DenseMapInfo<Ts>::getEmptyKey()...);
   }
 
-  static constexpr Tuple getTombstoneKey() {
-    return Tuple(DenseMapInfo<Ts>::getTombstoneKey()...);
-  }
-
   template <unsigned I> static unsigned getHashValueImpl(const Tuple &values) {
     if constexpr (I == sizeof...(Ts)) {
       return 0;
@@ -223,11 +200,6 @@ struct DenseMapInfo<Enum, std::enable_if_t<std::is_enum_v<Enum>>> {
     return V;
   }
 
-  static constexpr Enum getTombstoneKey() {
-    constexpr Enum V = static_cast<Enum>(Info::getTombstoneKey());
-    return V;
-  }
-
   static unsigned getHashValue(const Enum &Val) {
     return Info::getHashValue(static_cast<UnderlyingType>(Val));
   }
@@ -241,10 +213,6 @@ template <typename T> struct DenseMapInfo<std::optional<T>> {
 
   static constexpr Optional getEmptyKey() { return {Info::getEmptyKey()}; }
 
-  static constexpr Optional getTombstoneKey() {
-    return {Info::getTombstoneKey()};
-  }
-
   static unsigned getHashValue(const Optional &OptionalVal) {
     return detail::combineHashValue(
         OptionalVal.has_value(),
diff --git a/llvm/include/llvm/ADT/DenseMapInfoVariant.h b/llvm/include/llvm/ADT/DenseMapInfoVariant.h
index a97f9b9566c81..9729f2a300098 100644
--- a/llvm/include/llvm/ADT/DenseMapInfoVariant.h
+++ b/llvm/include/llvm/ADT/DenseMapInfoVariant.h
@@ -29,11 +29,6 @@ template <typename... Ts> struct DenseMapInfo<std::variant<Ts...>> {
     return Variant(std::in_place_index<0>, DenseMapInfo<FirstT>::getEmptyKey());
   }
 
-  static inline Variant getTombstoneKey() {
-    return Variant(std::in_place_index<0>,
-                   DenseMapInfo<FirstT>::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const Variant &Val) {
     return std::visit(
         [&Val](auto &&Alternative) {
diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index 6d679d815a417..5565b09543233 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -392,7 +392,6 @@ template <typename T> hash_code hash_value(const std::optional<T> &arg) {
 
 template <> struct DenseMapInfo<hash_code, void> {
   static constexpr hash_code getEmptyKey() { return hash_code(-1); }
-  static constexpr hash_code getTombstoneKey() { return hash_code(-2); }
   static constexpr unsigned getHashValue(hash_code val) {
     return static_cast<unsigned>(size_t(val));
   }
diff --git a/llvm/include/llvm/ADT/ImmutableList.h b/llvm/include/llvm/ADT/ImmutableList.h
index c9c289ca4dfa1..ef3f8a21db470 100644
--- a/llvm/include/llvm/ADT/ImmutableList.h
+++ b/llvm/include/llvm/ADT/ImmutableList.h
@@ -224,10 +224,6 @@ template <typename T> struct DenseMapInfo<ImmutableList<T>, void> {
     return reinterpret_cast<ImmutableListImpl<T>*>(-1);
   }
 
-  static inline ImmutableList<T> getTombstoneKey() {
-    return reinterpret_cast<ImmutableListImpl<T>*>(-2);
-  }
-
   static unsigned getHashValue(ImmutableList<T> X) {
     uintptr_t PtrVal = reinterpret_cast<uintptr_t>(X.getInternalPointer());
     return (unsigned((uintptr_t)PtrVal) >> 4) ^
diff --git a/llvm/include/llvm/ADT/PointerEmbeddedInt.h b/llvm/include/llvm/ADT/PointerEmbeddedInt.h
index 04a2b7bff78e0..76b03a40a9e27 100644
--- a/llvm/include/llvm/ADT/PointerEmbeddedInt.h
+++ b/llvm/include/llvm/ADT/PointerEmbeddedInt.h
@@ -102,7 +102,6 @@ struct DenseMapInfo<PointerEmbeddedInt<IntT, Bits>> {
   using IntInfo = DenseMapInfo<IntT>;
 
   static inline T getEmptyKey() { return IntInfo::getEmptyKey(); }
-  static inline T getTombstoneKey() { return IntInfo::getTombstoneKey(); }
 
   static unsigned getHashValue(const T &Arg) {
     return IntInfo::getHashValue(Arg);
diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index 75e3a58e7ca61..db6714ffcfe91 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -223,12 +223,6 @@ struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType>, void> {
     return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
   }
 
-  static Ty getTombstoneKey() {
-    uintptr_t Val = static_cast<uintptr_t>(-2);
-    Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
-    return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
-  }
-
   static unsigned getHashValue(Ty V) {
     uintptr_t IV = reinterpret_cast<uintptr_t>(V.getOpaqueValue());
     return unsigned(IV) ^ unsigned(IV >> 9);
diff --git a/llvm/include/llvm/ADT/PointerSumType.h b/llvm/include/llvm/ADT/PointerSumType.h
index c8e6cffd796a6..beaaf49a32b52 100644
--- a/llvm/include/llvm/ADT/PointerSumType.h
+++ b/llvm/include/llvm/ADT/PointerSumType.h
@@ -259,11 +259,6 @@ struct DenseMapInfo<PointerSumType<TagT, MemberTs...>> {
     return SumType::template create<SomeTag>(SomePointerInfo::getEmptyKey());
   }
 
-  static inline SumType getTombstoneKey() {
-    return SumType::template create<SomeTag>(
-        SomePointerInfo::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const SumType &Arg) {
     uintptr_t OpaqueValue = Arg.getOpaqueValue();
     return DenseMapInfo<uintptr_t>::getHashValue(OpaqueValue);
diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index 52cb12168f9b7..15565ee3ff51a 100644
--- a/llvm/include/llvm/ADT/PointerUnion.h
+++ b/llvm/include/llvm/ADT/PointerUnion.h
@@ -428,10 +428,6 @@ template <typename... PTs> struct DenseMapInfo<PointerUnion<PTs...>> {
 
   static inline Union getEmptyKey() { return Union(FirstInfo::getEmptyKey()); }
 
-  static inline Union getTombstoneKey() {
-    return Union(FirstInfo::getTombstoneKey());
-  }
-
   static unsigned getHashValue(const Union &UnionVal) {
     auto Key = reinterpret_cast<uintptr_t>(UnionVal.getOpaqueValue());
     return DenseMapInfo<uintptr_t>::getHashValue(Key);
diff --git a/llvm/include/llvm/ADT/SmallBitVector.h b/llvm/include/llvm/ADT/SmallBitVector.h
index 978dc3f073031..78049cbb44da5 100644
--- a/llvm/include/llvm/ADT/SmallBitVector.h
+++ b/llvm/include/llvm/ADT/SmallBitVector.h
@@ -683,12 +683,6 @@ class SmallBitVector {
       getPointer()->clearBitsNotInMask(Mask, MaskWords);
   }
 
-  void invalid() {
-    assert(empty());
-    X = (uintptr_t)-1;
-  }
-  bool isInvalid() const { return X == (uintptr_t)-1; }
-
   ArrayRef<uintptr_t> getData(uintptr_t &Store) const {
     if (!isSmall())
       return getPointer()->getData();
@@ -735,11 +729,6 @@ operator^(const SmallBitVector &LHS, const SmallBitVector &RHS) {
 
 template <> struct DenseMapInfo<SmallBitVector> {
   static inline SmallBitVector getEmptyKey() { return SmallBitVector(); }
-  static inline SmallBitVector getTombstoneKey() {
-    SmallBitVector V;
-    V.invalid();
-    return V;
-  }
   static unsigned getHashValue(const SmallBitVector &V) {
     uintptr_t Store;
     return DenseMapInfo<
@@ -747,8 +736,6 @@ template <> struct DenseMapInfo<SmallBitVector> {
         getHashValue(std::make_pair(V.size(), V.getData(Store)));
   }
   static bool isEqual(const SmallBitVector &LHS, const SmallBitVector &RHS) {
-    if (LHS.isInvalid() || RHS.isInvalid())
-      return LHS.isInvalid() == RHS.isInvalid();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 3d655daea471b..7e375792df4c0 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -1353,10 +1353,6 @@ template <typename T, unsigned N> struct DenseMapInfo<llvm::SmallVector<T, N>> {
     return {DenseMapInfo<T>::getEmptyKey()};
   }
 
-  static SmallVector<T, N> getTombstoneKey() {
-    return {DenseMapInfo<T>::getTombstoneKey()};
-  }
-
   static unsigned getHashValue(const SmallVector<T, N> &V) {
     return static_cast<unsigned>(hash_combine_range(V));
   }
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 5421224e6a1d3..f15e120451638 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -956,18 +956,11 @@ template <> struct DenseMapInfo<StringRef, void> {
                      0);
   }
 
-  static inline StringRef getTombstoneKey() {
-    return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)),
-                     0);
-  }
-
   LLVM_ABI static unsigned getHashValue(StringRef Val);
 
   static bool isEqual(StringRef LHS, StringRef RHS) {
     if (RHS.data() == getEmptyKey().data())
       return LHS.data() == getEmptyKey().data();
-    if (RHS.data() == getTombstoneKey().data())
-      return LHS.data() == getTombstoneKey().data();
     return LHS == RHS;
   }
 };
diff --git a/llvm/include/llvm/Support/FileSystem/UniqueID.h b/llvm/include/llvm/Support/FileSystem/UniqueID.h
index 0d5367236e8dc..3bfd8b7405505 100644
--- a/llvm/include/llvm/Support/FileSystem/UniqueID.h
+++ b/llvm/include/llvm/Support/FileSystem/UniqueID.h
@@ -58,12 +58,6 @@ template <> struct DenseMapInfo<llvm::sys::fs::UniqueID> {
     return {EmptyKey.first, EmptyKey.second};
   }
 
-  static inline llvm::sys::fs::UniqueID getTombstoneKey() {
-    auto TombstoneKey =
-        DenseMapInfo<std::pair<uint64_t, uint64_t>>::getTombstoneKey();
-    return {TombstoneKey.first, TombstoneKey.second};
-  }
-
   static hash_code getHashValue(const llvm::sys::fs::UniqueID &Tag) {
     return hash_value(std::make_pair(Tag.getDevice(), Tag.getFile()));
   }
diff --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h
index 421d6613bfafc..c60bae2872f92 100644
--- a/llvm/include/llvm/Support/TypeSize.h
+++ b/llvm/include/llvm/Suppo...
[truncated]

Copy link
Copy Markdown
Contributor

@aengelke aengelke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if CI passes.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

🐧 Linux x64 Test Results

  • 196104 tests passed
  • 5296 tests skipped

✅ The build succeeded and all tests passed.

@MaskRay MaskRay merged commit 836bf56 into llvm:main Jun 2, 2026
13 of 14 checks passed
yingopq pushed a commit to yingopq/llvm-project that referenced this pull request Jun 5, 2026
llvm#200595 changed DenseMap to no longer create tombstone buckets, so
DenseMapInfo<T>::getTombstoneKey() is never called. Remove dead
definitions and dead tombstone branches.
@MaskRay MaskRay deleted the pr/drop-tombstone-llvm-adt branch June 5, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants