[all-commits] [llvm/llvm-project] 85c276: [Support][Parallel] Initialize threadIndex and add...
avl-llvm via All-commits
all-commits at lists.llvm.org
Tue May 2 09:56:57 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 85c2768ce9023ae94d2c70951b3f7e3f33fc2105
https://github.com/llvm/llvm-project/commit/85c2768ce9023ae94d2c70951b3f7e3f33fc2105
Author: Alexey Lapshin <a.v.lapshin at mail.ru>
Date: 2023-05-02 (Tue, 02 May 2023)
Changed paths:
M lld/ELF/Relocations.cpp
M llvm/include/llvm/Support/Parallel.h
M llvm/lib/Support/Parallel.cpp
Log Message:
-----------
[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
More information about the All-commits
mailing list