[flang-commits] [flang] [flang] Remove unused DenseMapInfo::getEmptyKey (PR #201988)
Fangrui Song via flang-commits
flang-commits at lists.llvm.org
Fri Jun 5 19:52:38 PDT 2026
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/201988
After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.
>From 2c6add852e97a4b06a3398159d33faa4bdab60c0 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Fri, 5 Jun 2026 19:08:13 -0700
Subject: [PATCH] [flang] Remove unused DenseMapInfo::getEmptyKey
After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.
---
flang/include/flang/Lower/IterationSpace.h | 3 ---
flang/include/flang/Lower/Support/Utils.h | 6 ------
flang/include/flang/Semantics/symbol.h | 5 -----
flang/lib/Lower/Support/Utils.cpp | 8 --------
4 files changed, 22 deletions(-)
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);
}
More information about the flang-commits
mailing list