summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorAlexey Lapshin <a.v.lapshin@mail.ru>2023-04-18 20:22:55 +0200
committerAlexey Lapshin <a.v.lapshin@mail.ru>2023-04-26 13:52:26 +0200
commitfea8c073561f21ac0fea7f961287bf6b7dcf9f96 (patch)
treec44141287ccb187acd353ed919db02813e4314e4 /lld
parent329bfcc8df47e229d9f0a453a93e3a6040ace454 (diff)
downloadllvm-fea8c073561f21ac0fea7f961287bf6b7dcf9f96.tar.gz
[Support][Parallel] Add sequential mode to TaskGroup::spawn().
This patch allows to specify that some part of tasks should be done in sequential order. It makes it possible to not use condition operator for separating sequential tasks: TaskGroup tg; for () { if(condition) ==> tg.spawn([](){fn();}, condition) fn(); else tg.spawn([](){fn();}); } It also prevents execution on main thread. Which allows adding checks for getThreadIndex() function discussed in D142318. The patch also replaces std::stack with std::deque in the ThreadPoolExecutor to have natural execution order in case (parallel::strategy.ThreadsRequested == 1). Differential Revision: https://reviews.llvm.org/D148728
Diffstat (limited to 'lld')
-rw-r--r--lld/ELF/OutputSections.cpp2
-rw-r--r--lld/ELF/Relocations.cpp7
2 files changed, 3 insertions, 6 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 2251ecc83cde..a1aec83f4ac8 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -534,7 +534,7 @@ void OutputSection::writeTo(uint8_t *buf, parallel::TaskGroup &tg) {
taskSize += sections[i]->getSize();
bool done = ++i == numSections;
if (done || taskSize >= taskSizeLimit) {
- tg.execute([=] { fn(begin, i); });
+ tg.spawn([=] { fn(begin, i); });
if (done)
break;
begin = i;
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 6f2280b678b4..bda979c3066a 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1534,16 +1534,13 @@ template <class ELFT> void elf::scanRelocations() {
scanner.template scanSection<ELFT>(*s);
}
};
- if (serial)
- fn();
- else
- tg.execute(fn);
+ tg.spawn(fn, serial);
}
// Both the main thread and thread pool index 0 use getThreadIndex()==0. Be
// careful that they don't concurrently run scanSections. When serial is
// true, fn() has finished at this point, so running execute is safe.
- tg.execute([] {
+ tg.spawn([] {
RelocationScanner scanner;
for (Partition &part : partitions) {
for (EhInputSection *sec : part.ehFrame->sections)