[lld] r314090 - Compute string hashes early and cache them.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 24 18:42:57 PDT 2017
Author: ruiu
Date: Sun Sep 24 18:42:57 2017
New Revision: 314090
URL: http://llvm.org/viewvc/llvm-project?rev=314090&view=rev
Log:
Compute string hashes early and cache them.
This change alone speeds up linking of Clang debug build with -gdb-index
by 1.2 seconds, from 12.5 seconds to 11.3 seconds. (Without -gdb-index,
lld takes 8.5 seconds to link the same input files.)
Modified:
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=314090&r1=314089&r2=314090&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Sun Sep 24 18:42:57 2017
@@ -1756,9 +1756,12 @@ readPubNamesAndTypes(DWARFContext &Dwarf
std::vector<GdbIndexChunk::NameTypeEntry> Ret;
for (StringRef Sec : {Sec1, Sec2}) {
DWARFDebugPubTable Table(Sec, Config->IsLE, true);
- for (const DWARFDebugPubTable::Set &Set : Table.getData())
- for (const DWARFDebugPubTable::Entry &Ent : Set.Entries)
- Ret.push_back({Ent.Name, Ent.Descriptor.toBits()});
+ for (const DWARFDebugPubTable::Set &Set : Table.getData()) {
+ for (const DWARFDebugPubTable::Entry &Ent : Set.Entries) {
+ CachedHashStringRef S(Ent.Name, computeGdbHash(Ent.Name));
+ Ret.push_back({S, Ent.Descriptor.toBits()});
+ }
+ }
}
return Ret;
}
@@ -1787,12 +1790,10 @@ std::vector<std::set<uint32_t>> GdbIndex
for (GdbIndexChunk &Chunk : Chunks) {
for (GdbIndexChunk::NameTypeEntry &Ent : Chunk.NamesAndTypes) {
- uint32_t Hash = computeGdbHash(Ent.Name);
size_t Offset = StringPool.add(Ent.Name);
-
GdbSymbol *&Sym = SymbolMap[Offset];
if (!Sym) {
- Sym = make<GdbSymbol>(GdbSymbol{Hash, Offset, Ret.size()});
+ Sym = make<GdbSymbol>(GdbSymbol{Ent.Name.hash(), Offset, Ret.size()});
Ret.resize(Ret.size() + 1);
}
Ret[Sym->CuVectorIndex].insert((Ent.Type << 24) | Idx);
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=314090&r1=314089&r2=314090&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Sun Sep 24 18:42:57 2017
@@ -510,7 +510,7 @@ struct GdbIndexChunk {
};
struct NameTypeEntry {
- StringRef Name;
+ llvm::CachedHashStringRef Name;
uint8_t Type;
};
More information about the llvm-commits
mailing list