[PATCH] D62188: Speed up --start-lib and --end-lib.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 05:12:33 PDT 2019
ruiu created this revision.
ruiu added reviewers: MaskRay, grimar, pcc.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
ruiu edited the summary of this revision.
ruiu edited the summary of this revision.
--{start,end}-lib give files grouped by the options the archive file
semantics. That is, each object file between them acts as if it were
in an archive file whose sole member is the file.
Therefore, files between --{start,end}-lib are linked to the final
output only if they are needed to resolve some undefined symbols.
Previously, the feature was implemented this way:
1. We read a symbol table and insert defined symbols to the symbol table as lazy symbols.
2. If an undefind symbol is resolved to a lazy symbol, that lazy symbol instantiate ObjFile class for that symbol, which re-insert all defined symbols to the symbol table.
So, if an ObjFile is instantiated, defined symbols are inserted to the
symbol table twice. Since inserting long symbol names is not cheap,
there's a room to optimize here.
This patch optimzies it. Now, LazyObjFile remembers symbol handles and
passed them over to a new ObjFile instance, so that the ObjFile
doesn't insert the same strings.
Here is a quick benchmark to link clang. "Original" is the original
lld with unmodified command line options. For "With" and "Without", I
extracted all files from archive files and replace .a's in a command
line with .o's wrapped with --{start,end}-lib.
With this patch: 5.674s (+0.0%)
Withtout this patch: 6.087s (+7.2%)
Original: 5.886s (+3.7%)
So, interestingly, --{start,end}-lib are now faster than the regular
linking scheme with archive files. That's perhaps not too surprising,
though, because for regular archive files, we look up the symbol table
with the same string twice.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62188
Files:
lld/ELF/InputFiles.cpp
lld/ELF/InputFiles.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62188.200463.patch
Type: text/x-patch
Size: 7678 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190521/d669622c/attachment.bin>
More information about the llvm-commits
mailing list