[lld] [llvm] [LLD] Avoid non-deterministic relocations processing. (PR #107186)
Alexey Lapshin via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 13:37:44 PDT 2024
avl-llvm wrote:
> Shall we revert https://reviews.llvm.org/D148728 but possibly keep the `spawn` helper to allow ` tg.spawn([]{fn();}, condition)`? lld is the only `spawn` caller that may specify the `Sequential` parameter.
>
> The downside is that we need `threadIndex==0` for the main thread in the sequential case. We cannot keep the `threadIndex != UINT_MAX` assertion. I feel that the value of the assertion is low.
>
> If needed, the assertion can be restored using a different mechanism:
>
> * initialize `threadIndex` to UINT_MAX
> * make the sequential mode temporarily set `threadIndex` to 0, run the task, restore `threadIndex`
We can not temporarily set `threadIndex` to 0, run the task, restore `threadIndex`. As it could clash with another running thread using thread_index 0.
The assertion exactly prevent from the situation when we could have thread_index clashed. It seems that assertion has useful value.
The alternative solution might be to have a separate thread and condition variable for the "sequential" tasks. In this way the thread indexes would not be clashed, "sequential" tasks would have the same order and thread index. I uploaded this possible solution, though it still not fully finished.
https://github.com/llvm/llvm-project/pull/107186
More information about the llvm-commits
mailing list