[flang] Remove unused DenseMapInfo::getTombstoneKey#200632
Merged
Merged
Conversation
llvm#200595 changed DenseMap to no longer create tombstone buckets, so DenseMapInfo<T>::getTombstoneKey() is never called. Remove dead definitions and dead tombstone branches.
|
@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 4 Files Affected:
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);
}
|
aengelke
approved these changes
May 31, 2026
Contributor
aengelke
left a comment
There was a problem hiding this comment.
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); | |||
Contributor
There was a problem hiding this comment.
Side note: isn't this dereferencing an invalid pointer, which is UB?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#200595 changed DenseMap to no longer create tombstone buckets, so
DenseMapInfo::getTombstoneKey() is never called. Remove dead
definitions and dead tombstone branches.