[PATCH] D85402: [lld-macho] Avoid unnecessary shared_ptr in DylibFile ctor

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 19:51:23 PDT 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7e6d67549980: [lld-macho] Avoid unnecessary shared_ptr in DylibFile ctor (authored by int3).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85402

Files:
  lld/MachO/Driver.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h


Index: lld/MachO/InputFiles.h
===================================================================
--- lld/MachO/InputFiles.h
+++ lld/MachO/InputFiles.h
@@ -84,7 +84,7 @@
 // .dylib file
 class DylibFile : public InputFile {
 public:
-  explicit DylibFile(std::shared_ptr<llvm::MachO::InterfaceFile> interface,
+  explicit DylibFile(const llvm::MachO::InterfaceFile &interface,
                      DylibFile *umbrella = nullptr);
 
   // Mach-O dylibs can re-export other dylibs as sub-libraries, meaning that the
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -396,13 +396,12 @@
   }
 }
 
-DylibFile::DylibFile(std::shared_ptr<llvm::MachO::InterfaceFile> interface,
-                     DylibFile *umbrella)
+DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella)
     : InputFile(DylibKind, MemoryBufferRef()) {
   if (umbrella == nullptr)
     umbrella = this;
 
-  dylibName = saver.save(interface->getInstallName());
+  dylibName = saver.save(interface.getInstallName());
   auto addSymbol = [&](const Twine &name) -> void {
     symbols.push_back(symtab->addDylib(saver.save(name), umbrella,
                                        /*isWeakDef=*/false,
@@ -410,7 +409,7 @@
   };
   // TODO(compnerd) filter out symbols based on the target platform
   // TODO: handle weak defs, thread locals
-  for (const auto symbol : interface->symbols()) {
+  for (const auto symbol : interface.symbols()) {
     if (!symbol->getArchitectures().has(config->arch))
       continue;
 
@@ -435,8 +434,8 @@
   // TODO(compnerd) properly represent the hierarchy of the documents as it is
   // in theory possible to have re-exported dylibs from re-exported dylibs which
   // should be parent'ed to the child.
-  for (auto document : interface->documents())
-    reexported.push_back(make<DylibFile>(document, umbrella));
+  for (const std::shared_ptr<InterfaceFile> &intf : interface.documents())
+    reexported.push_back(make<DylibFile>(*intf, umbrella));
 }
 
 ArchiveFile::ArchiveFile(std::unique_ptr<llvm::object::Archive> &&f)
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -235,7 +235,7 @@
     if (!result)
       return;
 
-    inputFiles.push_back(make<DylibFile>(std::move(*result)));
+    inputFiles.push_back(make<DylibFile>(**result));
     break;
   }
   default:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85402.285242.patch
Type: text/x-patch
Size: 2505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200813/4bc92db0/attachment.bin>


More information about the llvm-commits mailing list