[ELF] Change splitSections to objectFiles based parallelForEach. NFC

The work is more balanced.
This commit is contained in:
Fangrui Song 2022-01-30 13:34:27 -08:00
parent 744be8c502
commit 73fd7d2304
1 changed files with 13 additions and 7 deletions

View File

@ -83,8 +83,10 @@ static ArrayRef<uint8_t> getVersion() {
// by "readelf --string-dump .comment <file>".
// The returned object is a mergeable string section.
MergeInputSection *elf::createCommentSection() {
return make<MergeInputSection>(SHF_MERGE | SHF_STRINGS, SHT_PROGBITS, 1,
auto *sec = make<MergeInputSection>(SHF_MERGE | SHF_STRINGS, SHT_PROGBITS, 1,
getVersion(), ".comment");
sec->splitIntoPieces();
return sec;
}
// .MIPS.abiflags section.
@ -3328,11 +3330,15 @@ template <class ELFT> void elf::splitSections() {
llvm::TimeTraceScope timeScope("Split sections");
// splitIntoPieces needs to be called on each MergeInputSection
// before calling finalizeContents().
parallelForEach(inputSections, [](InputSectionBase *sec) {
parallelForEach(objectFiles, [](ELFFileBase *file) {
for (InputSectionBase *sec : file->getSections()) {
if (!sec)
continue;
if (auto *s = dyn_cast<MergeInputSection>(sec))
s->splitIntoPieces();
else if (auto *eh = dyn_cast<EhInputSection>(sec))
eh->split<ELFT>();
}
});
}