Skip to content

Commit

Permalink
COFF: Cache the result of library searches.
Browse files Browse the repository at this point in the history
File system operations were still dominating the profile on Windows. In this
case we were spending a significant amount of our time repeatedly searching
for libraries as a result of processing linker directives. Address this
by caching whether we have already found a library with a given name. For
chrome_child.dll:

Before: 10.53s
After: 6.88s

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

llvm-svn: 289915
  • Loading branch information
pcc committed Dec 16, 2016
1 parent d644e02 commit c1ded7d
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lld/COFF/Driver.cpp
Original file line number Diff line number Diff line change
@@ -280,11 +280,12 @@ StringRef LinkerDriver::doFindLib(StringRef Filename) {
Optional<StringRef> LinkerDriver::findLib(StringRef Filename) {
if (Config->NoDefaultLibAll)
return None;
if (!VisitedLibs.insert(Filename.lower()).second)
return None;
StringRef Path = doFindLib(Filename);
if (Config->NoDefaultLibs.count(Path))
return None;
bool Seen = !VisitedFiles.insert(Path.lower()).second;
if (Seen)
if (!VisitedFiles.insert(Path.lower()).second)
return None;
return Path;
}
1 change: 1 addition & 0 deletions lld/COFF/Driver.h
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ class LinkerDriver {
// Library search path. The first element is always "" (current directory).
std::vector<StringRef> SearchPaths;
std::set<std::string> VisitedFiles;
std::set<std::string> VisitedLibs;

SymbolBody *addUndefined(StringRef Sym);
StringRef mangle(StringRef Sym);

0 comments on commit c1ded7d

Please sign in to comment.