From c1ded7dcef3fcb94fe95fd0105b220b54c515158 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 16 Dec 2016 03:45:59 +0000 Subject: [PATCH] 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 llvm-svn: 289915 --- lld/COFF/Driver.cpp | 5 +++-- lld/COFF/Driver.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 64cc583..e2b5e493 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -280,11 +280,12 @@ StringRef LinkerDriver::doFindLib(StringRef Filename) { Optional 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; } diff --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h index fb1f9a8..e811464 100644 --- a/lld/COFF/Driver.h +++ b/lld/COFF/Driver.h @@ -91,6 +91,7 @@ private: // Library search path. The first element is always "" (current directory). std::vector SearchPaths; std::set VisitedFiles; + std::set VisitedLibs; SymbolBody *addUndefined(StringRef Sym); StringRef mangle(StringRef Sym); -- 2.7.4