[PATCH] D142317: [Support][LLD] Avoid using uninitialized threadIndex.
Alexey Lapshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 23 07:01:00 PST 2023
avl added a comment.
In D142317#4073423 <https://reviews.llvm.org/D142317#4073423>, @andrewng wrote:
> Perhaps I'm missing something here, but I thought that `thread_local` variables are zero initialized. Therefore, the `threadIndex` for the main thread should already be `0`. However, what is definitely of concern is that `parallelFor` could create contention between the main thread and thread pool thread "0" because they share the index `0`. I definitely missed this in the original review that introduced this change. I spotted the potential for the issue within LLD itself but completely forgot that the parallel support code also makes use of the main thread!
I did not find direct specification of that behavior(`thread_local` variables are zero initialized) thus created a patch which initializes it.
Another thing, as mentioned in above quite, is that main thread with zero index clashes with first thread created by `parallelFor`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142317/new/
https://reviews.llvm.org/D142317
More information about the llvm-commits
mailing list