[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:11:16 PDT 2025


================
@@ -137,15 +137,15 @@ template <typename T, size_t ItemsGroupSize = 512> class ArrayList {
     NewGroup->Next = nullptr;
 
     // Try to replace current group with allocated one.
-    if (AtomicGroup.compare_exchange_weak(CurGroup, NewGroup))
+    if (AtomicGroup.compare_exchange_strong(CurGroup, NewGroup))
       return true;
 
     // Put allocated group as last group.
     while (CurGroup) {
       ItemsGroup *NextGroup = CurGroup->Next;
 
       if (!NextGroup) {
-        if (CurGroup->Next.compare_exchange_weak(NextGroup, NewGroup))
+        if (CurGroup->Next.compare_exchange_strong(NextGroup, NewGroup))
----------------
avl-llvm wrote:

using compare_exchange_weak in this loop also seems OK.

in case spurious wakeup  the CurGroup->Next would not be changed.
Then NextGroup = CurGroup->Next would be executed again.
Then check for !NextGroup.
Then it would try to do compare_exchange for the same values again.

https://github.com/llvm/llvm-project/pull/138692


More information about the llvm-commits mailing list