diff options
author | Nicholas Wilson <nicholas@nicholaswilson.me.uk> | 2018-03-14 15:45:11 +0000 |
---|---|---|
committer | Nicholas Wilson <nicholas@nicholaswilson.me.uk> | 2018-03-14 15:45:11 +0000 |
commit | c4d9aa1b5f9b7cd5982cdd3241a839bef22967ba (patch) | |
tree | 533a254d25aefb214ffb076dbb7e44d81e020f17 /lld/wasm/InputFiles.cpp | |
parent | 027b9357a8f23fdf9b0ab013ff27eaf9ec080961 (diff) | |
download | bcm5719-llvm-c4d9aa1b5f9b7cd5982cdd3241a839bef22967ba.tar.gz bcm5719-llvm-c4d9aa1b5f9b7cd5982cdd3241a839bef22967ba.zip |
[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
Diffstat (limited to 'lld/wasm/InputFiles.cpp')
-rw-r--r-- | lld/wasm/InputFiles.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp index 52be12ac51a..e7436863461 100644 --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -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 { |