[llvm] [DWARFLinkerParallel] Change more cases of compare_exchange_weak to compare_exchange_strong (PR #138692)
Alexey Lapshin via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 13:07:38 PDT 2025
================
@@ -49,7 +49,7 @@ template <typename T, size_t ItemsGroupSize = 512> class ArrayList {
if (!CurGroup->Next)
allocateNewGroup(CurGroup->Next);
- LastGroup.compare_exchange_weak(CurGroup, CurGroup->Next);
+ LastGroup.compare_exchange_strong(CurGroup, CurGroup->Next);
----------------
avl-llvm wrote:
It looks like using compare_exchange_weak is OK here.
In case spurious wakeup compare_exchange_weak behaves as if LastGroup != CurGroup even if they equal in fact.
Thus, the new iteration started with old value of LastGroup.
Next, it will increase ItemsCount(which is already greater then ItemsGroupSize.
Next it skip allocation since it was allocated on previous iteration.
Next it will try to execute compare_exchange again.
https://github.com/llvm/llvm-project/pull/138692
More information about the llvm-commits
mailing list