Skip to content

[flang] Remove unused DenseMapInfo::getTombstoneKey#200632

Merged
MaskRay merged 1 commit into
llvm:mainfrom
MaskRay:pr/drop-tombstone-flang
Jun 1, 2026
Merged

[flang] Remove unused DenseMapInfo::getTombstoneKey#200632
MaskRay merged 1 commit into
llvm:mainfrom
MaskRay:pr/drop-tombstone-flang

Conversation

@MaskRay
Copy link
Copy Markdown
Member

@MaskRay MaskRay commented May 31, 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.
@MaskRay MaskRay requested a review from aengelke May 31, 2026 05:17
@llvmorg-github-actions llvmorg-github-actions Bot added flang Flang issues not falling into any other category flang:fir-hlfir flang:semantics labels May 31, 2026
@llvmorg-github-actions
Copy link
Copy Markdown

llvmorg-github-actions Bot commented May 31, 2026

@llvm/pr-subscribers-flang-fir-hlfir

@llvm/pr-subscribers-flang-semantics

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.


Full diff: https://github.com/llvm/llvm-project/pull/200632.diff

4 Files Affected:

  • (modified) flang/include/flang/Lower/IterationSpace.h (-3)
  • (modified) flang/include/flang/Lower/Support/Utils.h (-6)
  • (modified) flang/include/flang/Semantics/symbol.h (-6)
  • (modified) flang/lib/Lower/Support/Utils.cpp (+2-6)
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);
 }

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. But please wait for 1-2 days in case we have to revert the DenseMap change again.

@@ -1239,12 +1239,6 @@ template <> struct DenseMapInfo<Fortran::semantics::SymbolRef> {
return *reinterpret_cast<Fortran::semantics::SymbolRef *>(&ptr);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Side note: isn't this dereferencing an invalid pointer, which is UB?

@MaskRay MaskRay merged commit 67139a2 into llvm:main Jun 1, 2026
14 checks passed
@MaskRay MaskRay deleted the pr/drop-tombstone-flang branch June 1, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants