That patch adds a check for threadIndex being used with only threads
created by ThreadPoolExecutor. This helps catch two types of errors:
- 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.
- 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).
This patch is a followup of discussion from D142318
Depends on D148728
I think this can be moved within the #if LLVM_ENABLE_THREADS just below.
Perhaps the -> a in the assert string.