Atomic CMPXCHG Retry Loop: Can LLVM Optimizer Hoist the Compare‑and‑Swap Instruction?
The goal is to implement a lock‑free retry pattern using LLVM's CMPXCHG atomic instruction so that a single store is attempted repeatedly without creating extra copies of the value. However, the optimizer may reorder or hoist the CMPXCHG instruction out of the loop, potentially eliminating the retry guarantee unless appropriate IR attributes are applied; old