[NFC] Move FoldingSetNodeID::AddInteger and FoldingSetNodeID::AddPointer definitions to header
Lack of AddInteger/AddPointer inlining slows down NodeEquals/Profile/:operator== calls. Inlining makes FunctionProtoTypes/PointerTypes/ElaboratedTypes/ParenTypes Profile functions faster but since NodeEquals is still called indirectly through function pointer from FindNodeOrInsertPos there is room for further inlining improvements. Extracted from: https://reviews.llvm.org/D118385 Differential Revision: https://reviews.llvm.org/D118610
This commit is contained in:
parent
d769600776
commit
f5e1ace9b0
|
@ -323,13 +323,33 @@ public:
|
||||||
: Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {}
|
: Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {}
|
||||||
|
|
||||||
/// Add* - Add various data types to Bit data.
|
/// Add* - Add various data types to Bit data.
|
||||||
void AddPointer(const void *Ptr);
|
void AddPointer(const void *Ptr) {
|
||||||
void AddInteger(signed I);
|
// Note: this adds pointers to the hash using sizes and endianness that
|
||||||
void AddInteger(unsigned I);
|
// depend on the host. It doesn't matter, however, because hashing on
|
||||||
void AddInteger(long I);
|
// pointer values is inherently unstable. Nothing should depend on the
|
||||||
void AddInteger(unsigned long I);
|
// ordering of nodes in the folding set.
|
||||||
void AddInteger(long long I);
|
static_assert(sizeof(uintptr_t) <= sizeof(unsigned long long),
|
||||||
void AddInteger(unsigned long long I);
|
"unexpected pointer size");
|
||||||
|
AddInteger(reinterpret_cast<uintptr_t>(Ptr));
|
||||||
|
}
|
||||||
|
void AddInteger(signed I) { Bits.push_back(I); }
|
||||||
|
void AddInteger(unsigned I) { Bits.push_back(I); }
|
||||||
|
void AddInteger(long I) { AddInteger((unsigned long)I); }
|
||||||
|
void AddInteger(unsigned long I) {
|
||||||
|
if (sizeof(long) == sizeof(int))
|
||||||
|
AddInteger(unsigned(I));
|
||||||
|
else if (sizeof(long) == sizeof(long long)) {
|
||||||
|
AddInteger((unsigned long long)I);
|
||||||
|
} else {
|
||||||
|
llvm_unreachable("unexpected sizeof(long)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void AddInteger(long long I) { AddInteger((unsigned long long)I); }
|
||||||
|
void AddInteger(unsigned long long I) {
|
||||||
|
AddInteger(unsigned(I));
|
||||||
|
AddInteger(unsigned(I >> 32));
|
||||||
|
}
|
||||||
|
|
||||||
void AddBoolean(bool B) { AddInteger(B ? 1U : 0U); }
|
void AddBoolean(bool B) { AddInteger(B ? 1U : 0U); }
|
||||||
void AddString(StringRef String);
|
void AddString(StringRef String);
|
||||||
void AddNodeID(const FoldingSetNodeID &ID);
|
void AddNodeID(const FoldingSetNodeID &ID);
|
||||||
|
|
|
@ -49,41 +49,6 @@ bool FoldingSetNodeIDRef::operator<(FoldingSetNodeIDRef RHS) const {
|
||||||
|
|
||||||
/// Add* - Add various data types to Bit data.
|
/// Add* - Add various data types to Bit data.
|
||||||
///
|
///
|
||||||
void FoldingSetNodeID::AddPointer(const void *Ptr) {
|
|
||||||
// Note: this adds pointers to the hash using sizes and endianness that
|
|
||||||
// depend on the host. It doesn't matter, however, because hashing on
|
|
||||||
// pointer values is inherently unstable. Nothing should depend on the
|
|
||||||
// ordering of nodes in the folding set.
|
|
||||||
static_assert(sizeof(uintptr_t) <= sizeof(unsigned long long),
|
|
||||||
"unexpected pointer size");
|
|
||||||
AddInteger(reinterpret_cast<uintptr_t>(Ptr));
|
|
||||||
}
|
|
||||||
void FoldingSetNodeID::AddInteger(signed I) {
|
|
||||||
Bits.push_back(I);
|
|
||||||
}
|
|
||||||
void FoldingSetNodeID::AddInteger(unsigned I) {
|
|
||||||
Bits.push_back(I);
|
|
||||||
}
|
|
||||||
void FoldingSetNodeID::AddInteger(long I) {
|
|
||||||
AddInteger((unsigned long)I);
|
|
||||||
}
|
|
||||||
void FoldingSetNodeID::AddInteger(unsigned long I) {
|
|
||||||
if (sizeof(long) == sizeof(int))
|
|
||||||
AddInteger(unsigned(I));
|
|
||||||
else if (sizeof(long) == sizeof(long long)) {
|
|
||||||
AddInteger((unsigned long long)I);
|
|
||||||
} else {
|
|
||||||
llvm_unreachable("unexpected sizeof(long)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void FoldingSetNodeID::AddInteger(long long I) {
|
|
||||||
AddInteger((unsigned long long)I);
|
|
||||||
}
|
|
||||||
void FoldingSetNodeID::AddInteger(unsigned long long I) {
|
|
||||||
AddInteger(unsigned(I));
|
|
||||||
AddInteger(unsigned(I >> 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FoldingSetNodeID::AddString(StringRef String) {
|
void FoldingSetNodeID::AddString(StringRef String) {
|
||||||
unsigned Size = String.size();
|
unsigned Size = String.size();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue