[InstCombine] Don't replace unused `atomicrmw xchg` with `atomic store`
Following the discussion from https://reviews.llvm.org/D141277 and in particular Ralf Jung's comment at https://reviews.llvm.org/D141277#inline-1365148, replacing an unused `atomicrmw xchg` into an `atomic store` is illegal even for release ordering. Quoting Connor Horman from the rust lang discussion linked in that comment: "An acquire operation A only synchronizes-with a release operation R if it takes its value from R, or any store in the release sequence headed by R, which is R, followed by the longest continuous sequence of read-modify-write operations. A regular store following R in the modification order would break the release sequence, and if an acquire operation reads that store or something later, then it loses any synchronization it might have already had." This fixes https://github.com/llvm/llvm-project/issues/60418 Differential Revision: https://reviews.llvm.org/D142097
Loading
Please sign in to comment