Skip to content

Commit

Permalink
COFF: Use CachedHashStringRef in the symbol table.
Browse files Browse the repository at this point in the history
This resulted in about a 1% perf improvement linking chrome_child.dll.

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

llvm-svn: 289410
pcc committed Dec 11, 2016
1 parent 8b65e51 commit 3f53093
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lld/COFF/SymbolTable.cpp
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ void SymbolTable::reportRemainingUndefines() {
}

std::pair<Symbol *, bool> SymbolTable::insert(StringRef Name) {
Symbol *&Sym = Symtab[Name];
Symbol *&Sym = Symtab[CachedHashStringRef(Name)];
if (Sym)
return {Sym, false};
Sym = make<Symbol>();
@@ -302,7 +302,7 @@ std::vector<Chunk *> SymbolTable::getChunks() {
}

Symbol *SymbolTable::find(StringRef Name) {
auto It = Symtab.find(Name);
auto It = Symtab.find(CachedHashStringRef(Name));
if (It == Symtab.end())
return nullptr;
return It->second;
@@ -316,7 +316,7 @@ Symbol *SymbolTable::findUnderscore(StringRef Name) {

StringRef SymbolTable::findByPrefix(StringRef Prefix) {
for (auto Pair : Symtab) {
StringRef Name = Pair.first;
StringRef Name = Pair.first.val();
if (Name.startswith(Prefix))
return Name;
}
3 changes: 2 additions & 1 deletion lld/COFF/SymbolTable.h
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
#define LLD_COFF_SYMBOL_TABLE_H

#include "InputFiles.h"
#include "llvm/ADT/CachedHashString.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/Allocator.h"
@@ -120,7 +121,7 @@ class SymbolTable {
void addCombinedLTOObject(ObjectFile *Obj);
std::vector<ObjectFile *> createLTOObjects(llvm::LTOCodeGenerator *CG);

llvm::DenseMap<StringRef, Symbol *> Symtab;
llvm::DenseMap<llvm::CachedHashStringRef, Symbol *> Symtab;

std::vector<BitcodeFile *> BitcodeFiles;
std::vector<SmallString<0>> Objs;

0 comments on commit 3f53093

Please sign in to comment.