forked from OSchip/llvm-project
COFF: Use a bit in SymbolBody to track which symbols are written to the symbol table.
Using a set here caused us to take about 1 second longer to write the symbol table when linking chrome_child.dll. With this I consistently get better performance on Windows with the new symbol table. Before r289280 and with r289183 reverted (median of 5 runs): 17.65s After this change: 17.33s On Linux things look even better: Before: 10.700480444s After: 5.735681610s Differential Revision: https://reviews.llvm.org/D27648 llvm-svn: 289408
This commit is contained in:
parent
831435cb14
commit
99111287fc
|
@ -80,7 +80,7 @@ protected:
|
||||||
friend SymbolTable;
|
friend SymbolTable;
|
||||||
explicit SymbolBody(Kind K, StringRef N = "")
|
explicit SymbolBody(Kind K, StringRef N = "")
|
||||||
: SymbolKind(K), IsExternal(true), IsCOMDAT(false),
|
: SymbolKind(K), IsExternal(true), IsCOMDAT(false),
|
||||||
IsReplaceable(false), Name(N) {}
|
IsReplaceable(false), WrittenToSymtab(false), Name(N) {}
|
||||||
|
|
||||||
const unsigned SymbolKind : 8;
|
const unsigned SymbolKind : 8;
|
||||||
unsigned IsExternal : 1;
|
unsigned IsExternal : 1;
|
||||||
|
@ -91,6 +91,11 @@ protected:
|
||||||
// This bit is used by the \c DefinedBitcode subclass.
|
// This bit is used by the \c DefinedBitcode subclass.
|
||||||
unsigned IsReplaceable : 1;
|
unsigned IsReplaceable : 1;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// This bit is used by Writer::createSymbolAndStringTable().
|
||||||
|
unsigned WrittenToSymtab : 1;
|
||||||
|
|
||||||
|
protected:
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -533,13 +533,14 @@ void Writer::createSymbolAndStringTable() {
|
||||||
Sec->setStringTableOff(addEntryToStringTable(Name));
|
Sec->setStringTableOff(addEntryToStringTable(Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<SymbolBody *> SeenSymbols;
|
|
||||||
for (lld::coff::ObjectFile *File : Symtab->ObjectFiles)
|
for (lld::coff::ObjectFile *File : Symtab->ObjectFiles)
|
||||||
for (SymbolBody *B : File->getSymbols())
|
for (SymbolBody *B : File->getSymbols())
|
||||||
if (auto *D = dyn_cast<Defined>(B))
|
if (auto *D = dyn_cast<Defined>(B))
|
||||||
if (SeenSymbols.insert(D).second)
|
if (!D->WrittenToSymtab) {
|
||||||
|
D->WrittenToSymtab = true;
|
||||||
if (Optional<coff_symbol16> Sym = createSymbol(D))
|
if (Optional<coff_symbol16> Sym = createSymbol(D))
|
||||||
OutputSymtab.push_back(*Sym);
|
OutputSymtab.push_back(*Sym);
|
||||||
|
}
|
||||||
|
|
||||||
OutputSection *LastSection = OutputSections.back();
|
OutputSection *LastSection = OutputSections.back();
|
||||||
// We position the symbol table to be adjacent to the end of the last section.
|
// We position the symbol table to be adjacent to the end of the last section.
|
||||||
|
|
Loading…
Reference in New Issue