[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 21:22:27 PDT 2021
keith updated this revision to Diff 384326.
keith marked 2 inline comments as done.
keith added a comment.
Add cleaning logic
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113073/new/
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,30 @@
}
}
+static DenseMap<CachedHashStringRef, StringRef> resolvedLibraries;
static Optional<StringRef> findLibrary(StringRef name) {
- if (config->searchDylibsFirst) {
- if (Optional<StringRef> path = findPathCombination(
- "lib" + name, config->librarySearchPaths, {".tbd", ".dylib"}))
- return path;
+ CachedHashStringRef key(name);
+ auto entry = resolvedLibraries.find(key);
+ if (entry != resolvedLibraries.end())
+ return entry->second;
+
+ auto doFind = [&] {
+ if (config->searchDylibsFirst) {
+ if (Optional<StringRef> path = findPathCombination(
+ "lib" + name, config->librarySearchPaths, {".tbd", ".dylib"}))
+ return path;
+ return findPathCombination("lib" + name, config->librarySearchPaths,
+ {".a"});
+ }
return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
- }
- return findPathCombination("lib" + name, config->librarySearchPaths,
- {".tbd", ".dylib", ".a"});
+ {".tbd", ".dylib", ".a"});
+ };
+
+ Optional<StringRef> path = doFind();
+ if (path)
+ resolvedLibraries[key] = *path;
+
+ return path;
}
static DenseMap<CachedHashStringRef, StringRef> resolvedFrameworks;
@@ -1088,6 +1102,7 @@
errorHandler().cleanupCallback = []() {
freeArena();
+ resolvedLibraries.clear();
concatOutputSections.clear();
inputFiles.clear();
inputSections.clear();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113073.384326.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211103/1e83550e/attachment.bin>
More information about the llvm-commits
mailing list