[lld] 63e65de - [lld-macho] Cache discovered framework paths
Keith Smiley via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 3 11:25:22 PDT 2021
Author: Keith Smiley
Date: 2021-11-03T11:11:54-07:00
New Revision: 63e65de3ffc20eeadcbffe994cbe0ccd6ea4c4ed
URL: https://github.com/llvm/llvm-project/commit/63e65de3ffc20eeadcbffe994cbe0ccd6ea4c4ed
DIFF: https://github.com/llvm/llvm-project/commit/63e65de3ffc20eeadcbffe994cbe0ccd6ea4c4ed.diff
LOG: [lld-macho] Cache discovered framework paths
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.
Reviewed By: #lld-macho, int3
Differential Revision: https://reviews.llvm.org/D113063
Added:
Modified:
lld/MachO/Driver.cpp
Removed:
################################################################################
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 2bcea9ad505d..adfe7166eb59 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -106,7 +106,13 @@ static Optional<StringRef> findLibrary(StringRef name) {
return path;
}
+static DenseMap<CachedHashStringRef, StringRef> resolvedFrameworks;
static Optional<StringRef> findFramework(StringRef name) {
+ CachedHashStringRef key(name);
+ auto entry = resolvedFrameworks.find(key);
+ if (entry != resolvedFrameworks.end())
+ return entry->second;
+
SmallString<260> symlink;
StringRef suffix;
std::tie(name, suffix) = name.split(",");
@@ -122,13 +128,13 @@ static Optional<StringRef> findFramework(StringRef name) {
// only append suffix if realpath() succeeds
Twine suffixed = location + suffix;
if (fs::exists(suffixed))
- return saver.save(suffixed.str());
+ return resolvedFrameworks[key] = saver.save(suffixed.str());
}
// Suffix lookup failed, fall through to the no-suffix case.
}
if (Optional<StringRef> path = resolveDylibPath(symlink.str()))
- return path;
+ return resolvedFrameworks[key] = *path;
}
return {};
}
@@ -1090,6 +1096,7 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
errorHandler().cleanupCallback = []() {
freeArena();
+ resolvedFrameworks.clear();
resolvedLibraries.clear();
concatOutputSections.clear();
inputFiles.clear();
More information about the llvm-commits
mailing list