[PATCH] D113063: [lld-macho] Cache discovered framework paths
Keith Smiley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 2 15:07:05 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 our large iOS project this took a link from 1 minute 45 seconds to 45
seconds. For reference ld64 does the same link in ~20 seconds.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113063
Files:
lld/MachO/Driver.cpp
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -92,7 +92,13 @@
{".tbd", ".dylib", ".a"});
}
+static DenseMap<CachedHashStringRef, StringRef> resolvedPaths;
static Optional<StringRef> findFramework(StringRef name) {
+ CachedHashStringRef key(name);
+ auto entry = resolvedPaths.find(key);
+ if (entry != resolvedPaths.end())
+ return entry->second;
+
SmallString<260> symlink;
StringRef suffix;
std::tie(name, suffix) = name.split(",");
@@ -107,14 +113,19 @@
if (!fs::real_path(symlink, location)) {
// only append suffix if realpath() succeeds
Twine suffixed = location + suffix;
- if (fs::exists(suffixed))
- return saver.save(suffixed.str());
+ if (fs::exists(suffixed)) {
+ auto saved = saver.save(suffixed.str());
+ resolvedPaths[key] = saved;
+ return saved;
+ }
}
// Suffix lookup failed, fall through to the no-suffix case.
}
- if (Optional<StringRef> path = resolveDylibPath(symlink.str()))
+ if (Optional<StringRef> path = resolveDylibPath(symlink.str())) {
+ resolvedPaths[key] = *path;
return path;
+ }
}
return {};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113063.384253.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211102/18a26839/attachment-0001.bin>
More information about the llvm-commits
mailing list