[lld] [ELF] Parallelize input file loading (PR #191690)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 23:47:01 PDT 2026
================
@@ -253,93 +238,59 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
MemoryBufferRef mbref = *buffer;
if (ctx.arg.formatBinary) {
- files.push_back(std::make_unique<BinaryFile>(ctx, mbref));
- if (!isInGroup)
- ++nextGroupId;
- return;
- }
-
- switch (identify_magic(mbref.getBuffer())) {
- case file_magic::unknown:
- readLinkerScript(ctx, mbref);
- return;
- case file_magic::archive: {
- auto members = getArchiveMembers(ctx, mbref);
- if (inWholeArchive) {
- for (const std::pair<MemoryBufferRef, uint64_t> &p : members) {
- if (isBitcode(p.first))
- files.push_back(std::make_unique<BitcodeFile>(ctx, p.first, path,
- p.second, false));
- else if (!tryAddFatLTOFile(p.first, path, p.second, false))
- files.push_back(createObjFile(ctx, p.first, path));
- }
+ loadJobs.push_back({mbref,
+ path,
+ LoadJob::Binary,
+ false,
+ false,
+ false,
+ false,
+ nextGroupId,
+ {},
+ {}});
+ } else {
+ auto magic = identify_magic(mbref.getBuffer());
+ if (magic == file_magic::unknown) {
+ readLinkerScript(ctx, mbref);
return;
}
-
- archiveFiles.emplace_back(path, members.size());
-
- // Handle archives and --start-lib/--end-lib using the same code path. This
- // scans all the ELF relocatable object files and bitcode files in the
- // archive rather than just the index file, with the benefit that the
- // symbols are only loaded once. For many projects archives see high
----------------
MaskRay wrote:
Adopted
https://github.com/llvm/llvm-project/pull/191690
More information about the llvm-commits
mailing list