[WebAssembly] Avoid COMDAT hashmap lookup for each symbol. NFC

This reduces the number of lookups to one per COMDAT group, rather than
one per symbol in a COMDAT group.

Differential Revision: https://reviews.llvm.org/D44344

llvm-svn: 327523
This commit is contained in:
Nicholas Wilson
2018-03-14 15:45:11 +00:00
parent 027b9357a8
commit c4d9aa1b5f
7 changed files with 29 additions and 15 deletions

View File

@@ -158,6 +158,11 @@ void ObjFile::parse() {
TypeMap.resize(getWasmObj()->types().size());
TypeIsUsed.resize(getWasmObj()->types().size(), false);
ArrayRef<StringRef> Comdats = WasmObj->linkingData().Comdats;
UsedComdats.resize(Comdats.size());
for (unsigned I = 0; I < Comdats.size(); ++I)
UsedComdats[I] = Symtab->addComdat(Comdats[I]);
// Populate `Segments`.
for (const WasmSegment &S : WasmObj->dataSegments()) {
InputSegment *Seg = make<InputSegment>(S, this);
@@ -194,10 +199,10 @@ void ObjFile::parse() {
}
bool ObjFile::isExcludedByComdat(InputChunk *Chunk) const {
StringRef S = Chunk->getComdat();
if (S.empty())
uint32_t C = Chunk->getComdat();
if (C == UINT32_MAX)
return false;
return !Symtab->addComdat(S, this);
return !UsedComdats[C];
}
FunctionSymbol *ObjFile::getFunctionSymbol(uint32_t Index) const {