mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-22 18:35:45 +00:00
Make StringTableBuilder to cache hash values.
This change seems to speed up LLD a bit if it has a lot of mergeable sections. The number is below. It's not too bad for a small patch. Time to link Clang (debug build): w/o patch 6.3696 seconds w/patch 6.2746 seconds (-1.5%) Differential Revision: http://reviews.llvm.org/D19933 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268698 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2dd0b894b1
commit
ecc2a1e20c
@ -23,7 +23,7 @@ public:
|
||||
|
||||
private:
|
||||
SmallString<256> StringTable;
|
||||
DenseMap<StringRef, size_t> StringIndexMap;
|
||||
DenseMap<CachedHash<StringRef>, size_t> StringIndexMap;
|
||||
size_t Size = 0;
|
||||
Kind K;
|
||||
unsigned Alignment;
|
||||
@ -57,7 +57,10 @@ public:
|
||||
/// after the table is finalized.
|
||||
size_t getOffset(StringRef S) const;
|
||||
|
||||
const DenseMap<StringRef, size_t> &getMap() const { return StringIndexMap; }
|
||||
const DenseMap<CachedHash<StringRef>, size_t> &getMap() const {
|
||||
return StringIndexMap;
|
||||
}
|
||||
|
||||
size_t getSize() const { return Size; }
|
||||
void clear();
|
||||
|
||||
|
@ -34,11 +34,11 @@ StringTableBuilder::StringTableBuilder(Kind K, unsigned Alignment)
|
||||
}
|
||||
}
|
||||
|
||||
typedef std::pair<StringRef, size_t> StringPair;
|
||||
typedef std::pair<CachedHash<StringRef>, size_t> StringPair;
|
||||
|
||||
// Returns the character at Pos from end of a string.
|
||||
static int charTailAt(StringPair *P, size_t Pos) {
|
||||
StringRef S = P->first;
|
||||
StringRef S = P->first.Val;
|
||||
if (Pos >= S.size())
|
||||
return -1;
|
||||
return (unsigned char)S[S.size() - Pos - 1];
|
||||
@ -86,7 +86,7 @@ void StringTableBuilder::finalizeInOrder() {
|
||||
}
|
||||
|
||||
void StringTableBuilder::finalizeStringTable(bool Optimize) {
|
||||
typedef std::pair<StringRef, size_t> StringOffsetPair;
|
||||
typedef std::pair<CachedHash<StringRef>, size_t> StringOffsetPair;
|
||||
std::vector<StringOffsetPair *> Strings;
|
||||
Strings.reserve(StringIndexMap.size());
|
||||
for (StringOffsetPair &P : StringIndexMap)
|
||||
@ -121,7 +121,7 @@ void StringTableBuilder::finalizeStringTable(bool Optimize) {
|
||||
|
||||
StringRef Previous;
|
||||
for (StringOffsetPair *P : Strings) {
|
||||
StringRef S = P->first;
|
||||
StringRef S = P->first.Val;
|
||||
if (K == WinCOFF)
|
||||
assert(S.size() > COFF::NameSize && "Short string in COFF string table!");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user