[lld] r289915 - COFF: Cache the result of library searches.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 19:45:59 PST 2016
Author: pcc
Date: Thu Dec 15 21:45:59 2016
New Revision: 289915
URL: http://llvm.org/viewvc/llvm-project?rev=289915&view=rev
Log:
COFF: Cache the result of library searches.
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
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Driver.h
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=289915&r1=289914&r2=289915&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Thu Dec 15 21:45:59 2016
@@ -280,11 +280,12 @@ StringRef LinkerDriver::doFindLib(String
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;
}
Modified: lld/trunk/COFF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.h?rev=289915&r1=289914&r2=289915&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.h (original)
+++ lld/trunk/COFF/Driver.h Thu Dec 15 21:45:59 2016
@@ -91,6 +91,7 @@ private:
// 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);
More information about the llvm-commits
mailing list