[all-commits] [llvm/llvm-project] 583488: [InstCombine] Don't replace unused `atomicrmw xchg...

qcolombet via All-commits all-commits at lists.llvm.org
Wed Feb 1 02:57:07 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 583488e4a787e400b6077b64677d23855a3c9538
      https://github.com/llvm/llvm-project/commit/583488e4a787e400b6077b64677d23855a3c9538
  Author: Quentin Colombet <quentin.colombet at gmail.com>
  Date:   2023-02-01 (Wed, 01 Feb 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
    M llvm/test/Transforms/InstCombine/atomicrmw.ll

  Log Message:
  -----------
  [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




More information about the All-commits mailing list