[PATCH] D94643: [llvm-link] Improve link time for bitcode archives [NFC]
Sergey Dmitriev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 13 18:22:38 PST 2021
sdmitriev created this revision.
sdmitriev added reviewers: tra, jdoerfert, RaviNarayanaswamy.
sdmitriev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Linking large bitcode archives currently takes a lot of time with llvm-link,
this patch adds couple improvements which reduce link time for archives
- Use one Linker instance for archive instead of recreating it for each member
- Lazy load archive members
https://reviews.llvm.org/D94643
Files:
llvm/tools/llvm-link/llvm-link.cpp
Index: llvm/tools/llvm-link/llvm-link.cpp
===================================================================
--- llvm/tools/llvm-link/llvm-link.cpp
+++ llvm/tools/llvm-link/llvm-link.cpp
@@ -146,6 +146,7 @@
std::unique_ptr<MemoryBuffer> Buffer,
LLVMContext &Context) {
std::unique_ptr<Module> Result(new Module("ArchiveModule", Context));
+ Linker L(*Result);
StringRef ArchiveName = Buffer->getBufferIdentifier();
if (Verbose)
errs() << "Reading library archive file '" << ArchiveName
@@ -186,7 +187,12 @@
return nullptr;
}
- std::unique_ptr<Module> M = parseIR(MemBuf.get(), ParseErr, Context);
+ std::unique_ptr<Module> M;
+ if (DisableLazyLoad)
+ M = parseIR(MemBuf.get(), ParseErr, Context);
+ else
+ M = getLazyIRModule(MemoryBuffer::getMemBuffer(MemBuf.get(), false),
+ ParseErr, Context);
if (!M.get()) {
errs() << Argv0 << ": ";
@@ -197,7 +203,7 @@
}
if (Verbose)
errs() << "Linking member '" << ChildName << "' of archive library.\n";
- if (Linker::linkModules(*Result, std::move(M)))
+ if (L.linkInModule(std::move(M)))
return nullptr;
} // end for each child
ExitOnErr(std::move(Err));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94643.316544.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210114/3f4f744e/attachment.bin>
More information about the llvm-commits
mailing list