Move DenseMapInfo traits to TypeSize.h

Saves 2427 unneeded includes of TypeSize.h, which instantiates
std::tie<uint64_t, bool>, which instantiates std::tuple<uint64_t, bool>,
which is slow.

I'll remove the tie in a follow-up, since it's just for operator==.
This commit is contained in:
Reid Kleckner 2020-01-31 16:44:07 -08:00
parent 5b14abf0c1
commit 4b606b4af5
2 changed files with 17 additions and 16 deletions

View File

@ -17,7 +17,6 @@
#include "llvm/ADT/Hashing.h" #include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/Support/PointerLikeTypeTraits.h" #include "llvm/Support/PointerLikeTypeTraits.h"
#include "llvm/Support/TypeSize.h"
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
@ -280,21 +279,6 @@ template <> struct DenseMapInfo<hash_code> {
static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; } static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
}; };
template <> struct DenseMapInfo<ElementCount> {
static inline ElementCount getEmptyKey() { return {~0U, true}; }
static inline ElementCount getTombstoneKey() { return {~0U - 1, false}; }
static unsigned getHashValue(const ElementCount& EltCnt) {
if (EltCnt.Scalable)
return (EltCnt.Min * 37U) - 1U;
return EltCnt.Min * 37U;
}
static bool isEqual(const ElementCount& LHS, const ElementCount& RHS) {
return LHS == RHS;
}
};
} // end namespace llvm } // end namespace llvm
#endif // LLVM_ADT_DENSEMAPINFO_H #endif // LLVM_ADT_DENSEMAPINFO_H

View File

@ -20,6 +20,8 @@
namespace llvm { namespace llvm {
template <typename T> struct DenseMapInfo;
class ElementCount { class ElementCount {
public: public:
unsigned Min; // Minimum number of vector elements. unsigned Min; // Minimum number of vector elements.
@ -201,6 +203,21 @@ inline TypeSize alignTo(TypeSize Size, uint64_t Align) {
Size.isScalable()}; Size.isScalable()};
} }
template <> struct DenseMapInfo<ElementCount> {
static inline ElementCount getEmptyKey() { return {~0U, true}; }
static inline ElementCount getTombstoneKey() { return {~0U - 1, false}; }
static unsigned getHashValue(const ElementCount& EltCnt) {
if (EltCnt.Scalable)
return (EltCnt.Min * 37U) - 1U;
return EltCnt.Min * 37U;
}
static bool isEqual(const ElementCount& LHS, const ElementCount& RHS) {
return LHS == RHS;
}
};
} // end namespace llvm } // end namespace llvm
#endif // LLVM_SUPPORT_TypeSize_H #endif // LLVM_SUPPORT_TypeSize_H