[llvm] [docs] Reflect C++'s read-write and write-read coherence rules in the LLVM memory model (PR #217849)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 23:29:26 PDT 2026


================
@@ -4170,10 +4170,23 @@ happens-before must be perfectly overlapping to act atomically.
     read-modify-write operation M ({ref}`cmpxchg <i_cmpxchg>` and
     {ref}`atomicrmw <i_atomicrmw>`) reads from a perfectly overlapping
     `monotonic` (or stronger) write W, W must be immediately before M in
-    the relevant modification order. If one atomic read happens before
-    another perfectly overlapping atomic read and both are at least
-    `monotonic`, the later read must not see an earlier value in the
-    address's modification order. This disallows reordering of perfectly
+    the relevant modification order.
+
+    Atomic accesses that are `monotonic` (or stronger) satisfy coherence rules:
+    - read-read coherence: If one atomic read happens before another
+        perfectly overlapping atomic read and both are at least
+        `monotonic`, the later read must not see an earlier value in the
+        address's modification order.
----------------
ssahasra wrote:

```suggestion
        `monotonic`, the later read must read from a write that was earlier in the
        address's modification order than the write that the earlier read read from.
```
I really couldn't resist the "read read". 😄 I guess naming them will make the sentence more accessible.

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


More information about the llvm-commits mailing list