[PATCH] D85402: [lld-macho] Avoid unnecessary shared_ptr in DylibFile ctor
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 00:12:12 PDT 2020
int3 created this revision.
int3 added reviewers: lld-macho, compnerd.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
int3 requested review of this revision.
DylibFile doesn't store a pointer to its InterfaceFile
parameter, so there's no need to use a shared_ptr.
Repository:
rG LLVM Github Monorepo
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
@@ -75,7 +75,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
@@ -384,13 +384,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,
@@ -398,7 +397,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;
@@ -423,8 +422,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
@@ -233,7 +233,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.283500.patch
Type: text/x-patch
Size: 2505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/d3b010cc/attachment.bin>
More information about the llvm-commits
mailing list