summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorAlexey Lapshin <a.v.lapshin@mail.ru>2023-04-20 23:03:21 +0200
committerAlexey Lapshin <a.v.lapshin@mail.ru>2023-05-02 18:44:15 +0200
commit85c2768ce9023ae94d2c70951b3f7e3f33fc2105 (patch)
tree47e0484165a6be268adfe37e63ccbe850c370577 /lld
parent5437a4c5e90886c6688da90eaf70617d50e64895 (diff)
downloadllvm-85c2768ce9023ae94d2c70951b3f7e3f33fc2105.tar.gz
[Support][Parallel] Initialize threadIndex and add assertion checking its usage.
That patch adds a check for threadIndex being used with only threads created by ThreadPoolExecutor. This helps catch two types of errors: 1. If a thread is created not by ThreadPoolExecutor its index may clash with the index of another thread. Using threadIndex, in that case, may lead to a data race. 2. Index of the main thread(threadIndex == 0) currently clashes with the index of thread0 in ThreadPoolExecutor threads. That may lead to a data race if main thread and thread0 are executed concurrently. This patch allows execution tasks on the main thread only in case parallel::strategy.ThreadsRequested == 1. In all other cases, assertions check that threadIndex != UINT_MAX(i.e. that task is executed on a thread created by ThreadPoolExecutor). Differential Revision: https://reviews.llvm.org/D148916
Diffstat (limited to 'lld')
-rw-r--r--lld/ELF/Relocations.cpp3
1 files changed, 0 insertions, 3 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index bda979c3066a..2f7fcd664c6a 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1537,9 +1537,6 @@ template <class ELFT> void elf::scanRelocations() {
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.spawn([] {
RelocationScanner scanner;
for (Partition &part : partitions) {