[flang-commits] [flang] [flang] Remove unused DenseMapInfo::getTombstoneKey (PR #200632)

Fangrui Song via flang-commits flang-commits at lists.llvm.org
Sat May 30 22:18:05 PDT 2026


https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/200632

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


>From 0d405caaebac6bf04be2fe83a0597f06037c3f8d Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Sat, 30 May 2026 21:41:56 -0700
Subject: [PATCH] [flang] Remove unused DenseMapInfo::getTombstoneKey

#200595 changed DenseMap to no longer create tombstone buckets, so
DenseMapInfo<T>::getTombstoneKey() is never called. Remove dead
definitions and dead tombstone branches.
---
 flang/include/flang/Lower/IterationSpace.h | 3 ---
 flang/include/flang/Lower/Support/Utils.h  | 6 ------
 flang/include/flang/Semantics/symbol.h     | 6 ------
 flang/lib/Lower/Support/Utils.cpp          | 8 ++------
 4 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h
index ab52821432fb6..c7412ae5199bb 100644
--- a/flang/include/flang/Lower/IterationSpace.h
+++ b/flang/include/flang/Lower/IterationSpace.h
@@ -297,9 +297,6 @@ struct DenseMapInfo<Fortran::lower::ExplicitSpaceArrayBases> {
   static inline Fortran::lower::ExplicitSpaceArrayBases getEmptyKey() {
     return reinterpret_cast<Fortran::lower::FrontEndSymbol>(~0);
   }
-  static inline Fortran::lower::ExplicitSpaceArrayBases getTombstoneKey() {
-    return reinterpret_cast<Fortran::lower::FrontEndSymbol>(~0 - 1);
-  }
   static unsigned
   getHashValue(const Fortran::lower::ExplicitSpaceArrayBases &v) {
     return Fortran::lower::getHashValue(v);
diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index 4e83a0e3bfec7..d79cc13b966f0 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -131,9 +131,6 @@ struct DenseMapInfo<const Fortran::lower::SomeExpr *> {
   static inline const Fortran::lower::SomeExpr *getEmptyKey() {
     return reinterpret_cast<Fortran::lower::SomeExpr *>(~0);
   }
-  static inline const Fortran::lower::SomeExpr *getTombstoneKey() {
-    return reinterpret_cast<Fortran::lower::SomeExpr *>(~0 - 1);
-  }
   static unsigned getHashValue(const Fortran::lower::SomeExpr *v) {
     return Fortran::lower::getHashValue(v);
   }
@@ -149,9 +146,6 @@ struct DenseMapInfo<const Fortran::evaluate::Component *> {
   static inline const Fortran::evaluate::Component *getEmptyKey() {
     return reinterpret_cast<Fortran::evaluate::Component *>(~0);
   }
-  static inline const Fortran::evaluate::Component *getTombstoneKey() {
-    return reinterpret_cast<Fortran::evaluate::Component *>(~0 - 1);
-  }
   static unsigned getHashValue(const Fortran::evaluate::Component *v) {
     return Fortran::lower::getHashValue(v);
   }
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 775ac5ca3dcbc..50e5e57eead5d 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -1239,12 +1239,6 @@ template <> struct DenseMapInfo<Fortran::semantics::SymbolRef> {
     return *reinterpret_cast<Fortran::semantics::SymbolRef *>(&ptr);
   }
 
-  static inline Fortran::semantics::SymbolRef getTombstoneKey() {
-    auto ptr =
-        DenseMapInfo<const Fortran::semantics::Symbol *>::getTombstoneKey();
-    return *reinterpret_cast<Fortran::semantics::SymbolRef *>(&ptr);
-  }
-
   static unsigned getHashValue(const Fortran::semantics::SymbolRef &sym) {
     return DenseMapInfo<const Fortran::semantics::Symbol *>::getHashValue(
         &sym.get());
diff --git a/flang/lib/Lower/Support/Utils.cpp b/flang/lib/Lower/Support/Utils.cpp
index 865c614cdc6db..feb5b191874af 100644
--- a/flang/lib/Lower/Support/Utils.cpp
+++ b/flang/lib/Lower/Support/Utils.cpp
@@ -632,9 +632,7 @@ bool isEqual(const Fortran::lower::SomeExpr *x,
              const Fortran::lower::SomeExpr *y) {
   const auto *empty =
       llvm::DenseMapInfo<const Fortran::lower::SomeExpr *>::getEmptyKey();
-  const auto *tombstone =
-      llvm::DenseMapInfo<const Fortran::lower::SomeExpr *>::getTombstoneKey();
-  if (x == empty || y == empty || x == tombstone || y == tombstone)
+  if (x == empty || y == empty)
     return x == y;
   return x == y || IsEqualEvaluateExpr::isEqual(*x, *y);
 }
@@ -663,9 +661,7 @@ bool isEqual(const Fortran::evaluate::Component *x,
              const Fortran::evaluate::Component *y) {
   const auto *empty =
       llvm::DenseMapInfo<const Fortran::evaluate::Component *>::getEmptyKey();
-  const auto *tombstone = llvm::DenseMapInfo<
-      const Fortran::evaluate::Component *>::getTombstoneKey();
-  if (x == empty || y == empty || x == tombstone || y == tombstone)
+  if (x == empty || y == empty)
     return x == y;
   return x == y || IsEqualEvaluateExpr::isEqual(*x, *y);
 }



More information about the flang-commits mailing list