[llvm] [Parallel] Revert sequential task changes (PR #109084)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 15:13:37 PDT 2024
================
@@ -1647,30 +1647,44 @@ template <class ELFT> void elf::scanRelocations() {
bool serial = !config->zCombreloc || config->emachine == EM_MIPS ||
config->emachine == EM_PPC64;
parallel::TaskGroup tg;
- for (ELFFileBase *f : ctx.objectFiles) {
- auto fn = [f]() {
+ auto outerFn = [&]() {
+ for (ELFFileBase *f : ctx.objectFiles) {
+ auto fn = [f]() {
+ RelocationScanner scanner;
+ for (InputSectionBase *s : f->getSections()) {
+ if (s && s->kind() == SectionBase::Regular && s->isLive() &&
+ (s->flags & SHF_ALLOC) &&
+ !(s->type == SHT_ARM_EXIDX && config->emachine == EM_ARM))
+ scanner.template scanSection<ELFT>(*s);
+ }
+ };
+ if (serial)
+ fn();
+ else
+ tg.spawn(fn);
+ }
+ auto scanEH = [] {
RelocationScanner scanner;
- for (InputSectionBase *s : f->getSections()) {
- if (s && s->kind() == SectionBase::Regular && s->isLive() &&
- (s->flags & SHF_ALLOC) &&
- !(s->type == SHT_ARM_EXIDX && config->emachine == EM_ARM))
- scanner.template scanSection<ELFT>(*s);
+ for (Partition &part : ctx.partitions) {
+ for (EhInputSection *sec : part.ehFrame->sections)
+ scanner.template scanSection<ELFT>(*sec, /*isEH=*/true);
+ if (part.armExidx && part.armExidx->isLive())
+ for (InputSection *sec : part.armExidx->exidxSections)
+ if (sec->isLive())
+ scanner.template scanSection<ELFT>(*sec);
}
};
- tg.spawn(fn, serial);
- }
-
- tg.spawn([] {
- RelocationScanner scanner;
- for (Partition &part : ctx.partitions) {
- for (EhInputSection *sec : part.ehFrame->sections)
- scanner.template scanSection<ELFT>(*sec, /*isEH=*/true);
- if (part.armExidx && part.armExidx->isLive())
- for (InputSection *sec : part.armExidx->exidxSections)
- if (sec->isLive())
- scanner.template scanSection<ELFT>(*sec);
- }
- });
+ if (serial)
+ scanEH();
+ else
+ tg.spawn(scanEH);
----------------
MaskRay wrote:
We need to run `scanEH` in a worker thread to avoid `UINT_MAX` `threadIndex`.
The `if (serial) scanEH(); else tg.spawn(scanEH);` pattern is similar to `if (serial) fn(); else tg.spawn(fn);` .
`scanEH` scans `.eh_frame` in all input files. `.eh_frame` relocations are smaller than other sections, so the previous code scans all `.eh_frame` in one task.
https://github.com/llvm/llvm-project/pull/109084
More information about the llvm-commits
mailing list