[PATCH] D113063: [lld-macho] Cache discovered framework paths

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 2 21:18:57 PDT 2021


keith updated this revision to Diff 384325.
keith marked 3 inline comments as done.
keith added a comment.

Update format and add cleanup clear


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113063/new/

https://reviews.llvm.org/D113063

Files:
  lld/MachO/Driver.cpp


Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -106,7 +106,13 @@
   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(",");
@@ -121,14 +127,18 @@
       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)) {
+          StringRef saved = saver.save(suffixed.str());
+          return resolvedFrameworks[key] = 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())) {
+      resolvedFrameworks[key] = *path;
       return path;
+    }
   }
   return {};
 }
@@ -1098,6 +1108,7 @@
     loadedArchives.clear();
     syntheticSections.clear();
     thunkMap.clear();
+    resolvedFrameworks.clear();
 
     firstTLVDataSection = nullptr;
     tar = nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113063.384325.patch
Type: text/x-patch
Size: 1481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211103/026c9a9e/attachment.bin>


More information about the llvm-commits mailing list