[PATCH] D113073: [lld-macho] Cache library paths from findLibrary
Keith Smiley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 2 17:23:04 PDT 2021
keith created this revision.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
keith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
On top of https://reviews.llvm.org/D113063 this took another 10 seconds
off our overall link time.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113073
Files:
lld/MachO/Driver.cpp
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -80,16 +80,29 @@
}
}
+static DenseMap<CachedHashStringRef, StringRef> resolvedLibraries;
static Optional<StringRef> findLibrary(StringRef name) {
+ CachedHashStringRef key(name);
+ auto entry = resolvedLibraries.find(key);
+ if (entry != resolvedLibraries.end())
+ return entry->second;
+
if (config->searchDylibsFirst) {
if (Optional<StringRef> path = findPathCombination(
- "lib" + name, config->librarySearchPaths, {".tbd", ".dylib"}))
+ "lib" + name, config->librarySearchPaths, {".tbd", ".dylib"})) {
+ resolvedLibraries[key] = *path;
return path;
- return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+ }
+ auto path =
+ findPathCombination("lib" + name, config->librarySearchPaths, {".a"});
+ if (path)
+ resolvedLibraries[key] = *path;
+ return path;
}
- return findPathCombination("lib" + name, config->librarySearchPaths,
- {".tbd", ".dylib", ".a"});
+ auto path = findPathCombination("lib" + name, config->librarySearchPaths,
+ {".tbd", ".dylib", ".a"});
+ resolvedLibraries[key] = *path;
+ return path;
}
static DenseMap<CachedHashStringRef, StringRef> resolvedPaths;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113073.384285.patch
Type: text/x-patch
Size: 1441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211103/7c632840/attachment.bin>
More information about the llvm-commits
mailing list