[flang-commits] [flang] [flang] Remove unused DenseMapInfo::getEmptyKey (PR #201988)
via flang-commits
flang-commits at lists.llvm.org
Fri Jun 5 19:53:14 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Fangrui Song (MaskRay)
<details>
<summary>Changes</summary>
After #<!-- -->201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.
---
Full diff: https://github.com/llvm/llvm-project/pull/201988.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 (-5)
- (modified) flang/lib/Lower/Support/Utils.cpp (-8)
``````````diff
diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h
index c7412ae5199bb..b34c07520f8ad 100644
--- a/flang/include/flang/Lower/IterationSpace.h
+++ b/flang/include/flang/Lower/IterationSpace.h
@@ -294,9 +294,6 @@ bool isEqual(const ExplicitSpaceArrayBases &x,
namespace llvm {
template <>
struct DenseMapInfo<Fortran::lower::ExplicitSpaceArrayBases> {
- static inline Fortran::lower::ExplicitSpaceArrayBases getEmptyKey() {
- return reinterpret_cast<Fortran::lower::FrontEndSymbol>(~0);
- }
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 feddf6f773130..025baa5282786 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -129,9 +129,6 @@ void privatizeSymbol(
namespace llvm {
template <>
struct DenseMapInfo<const Fortran::lower::SomeExpr *> {
- static inline const Fortran::lower::SomeExpr *getEmptyKey() {
- return reinterpret_cast<Fortran::lower::SomeExpr *>(~0);
- }
static unsigned getHashValue(const Fortran::lower::SomeExpr *v) {
return Fortran::lower::getHashValue(v);
}
@@ -144,9 +141,6 @@ struct DenseMapInfo<const Fortran::lower::SomeExpr *> {
// DenseMapInfo for pointers to Fortran::evaluate::Component.
template <>
struct DenseMapInfo<const Fortran::evaluate::Component *> {
- static inline const Fortran::evaluate::Component *getEmptyKey() {
- return reinterpret_cast<Fortran::evaluate::Component *>(~0);
- }
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 c794c20abcec5..f4ae9a4775743 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -1256,11 +1256,6 @@ SourceOrderedSymbolSet OrderBySourcePosition(const A &container) {
// Define required info so that SymbolRef can be used inside llvm::DenseMap.
namespace llvm {
template <> struct DenseMapInfo<Fortran::semantics::SymbolRef> {
- static inline Fortran::semantics::SymbolRef getEmptyKey() {
- auto ptr = DenseMapInfo<const Fortran::semantics::Symbol *>::getEmptyKey();
- 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 418bf6377cef9..6d38e1ff550a4 100644
--- a/flang/lib/Lower/Support/Utils.cpp
+++ b/flang/lib/Lower/Support/Utils.cpp
@@ -631,10 +631,6 @@ unsigned getHashValue(const Fortran::evaluate::Component *x) {
bool isEqual(const Fortran::lower::SomeExpr *x,
const Fortran::lower::SomeExpr *y) {
- const auto *empty =
- llvm::DenseMapInfo<const Fortran::lower::SomeExpr *>::getEmptyKey();
- if (x == empty || y == empty)
- return x == y;
return x == y || IsEqualEvaluateExpr::isEqual(*x, *y);
}
@@ -660,10 +656,6 @@ bool isEqual(const Fortran::lower::ExplicitIterSpace::ArrayBases &x,
bool isEqual(const Fortran::evaluate::Component *x,
const Fortran::evaluate::Component *y) {
- const auto *empty =
- llvm::DenseMapInfo<const Fortran::evaluate::Component *>::getEmptyKey();
- if (x == empty || y == empty)
- return x == y;
return x == y || IsEqualEvaluateExpr::isEqual(*x, *y);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/201988
More information about the flang-commits
mailing list