[llvm] [LangRef] Specify that syncscopes can affect the monotonic modification order (PR #189017)

Fabian Ritter via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 01:15:30 PDT 2026


https://github.com/ritter-x2a updated https://github.com/llvm/llvm-project/pull/189017

>From 1b02cda093819cfc6db4c7546e476f934ac0593e Mon Sep 17 00:00:00 2001
From: Fabian Ritter <fabian.ritter at amd.com>
Date: Fri, 27 Mar 2026 10:45:52 -0400
Subject: [PATCH 1/2] [LangRef] Specify that syncscopes can affect the
 monotonic modification order

If a target specifies that atomics with mismatching syncscopes appear
non-atomic to each other, there is no point in requiring them to be ordered in
the monotonic modification order. Notably, the [AMDGPU target user
guide](https://llvm.org/docs/AMDGPUUsage.html#memory-scopes) has specified
syncscopes to relax the modification order for years.

So far, I haven't found an example where this less constrained ordering would
be observable (at least with the AMDGPU inclusive scope rules). Whenever a load
would be able to see two monotonic stores with non-inclusive scope, that's
considered a data race (i.e., the load would return `undef`), so it cannot be
used to observe the order of the stores.
---
 llvm/docs/LangRef.rst | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 44b0b626d7c30..4cd54df2c8f55 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -4055,18 +4055,22 @@ For a simpler introduction to the ordering constraints, see the
 .. _syncscope:
 
 If an atomic operation is marked ``syncscope("singlethread")``, it only
-*synchronizes with* and only participates in the seq\_cst total orderings of
-other operations running in the same thread (for example, in signal handlers).
+*synchronizes with* other operations running in the same thread (for
+example, in signal handlers) and the constraints on its position
+relative to other operations in the seq\_cst order and the monotonic
+modification order only apply to operations in the same thread.
 
 If an atomic operation is marked ``syncscope("<target-scope>")``, where
-``<target-scope>`` is a target-specific synchronization scope, then it is target
-dependent if it *synchronizes with* and participates in the seq\_cst total
-orderings of other operations.
-
-Otherwise, an atomic operation that is not marked ``syncscope("singlethread")``
-or ``syncscope("<target-scope>")`` *synchronizes with* and participates in the
-seq\_cst total orderings of other operations that are not marked
-``syncscope("singlethread")`` or ``syncscope("<target-scope>")``.
+``<target-scope>`` is a target-specific synchronization scope, then it
+is target-dependent if it *synchronizes with* other operations and
+relative to which operations the constraints on its position in the
+seq\_cst order and the monotonic modification order apply.
+
+Otherwise, an atomic operation that is not marked
+``syncscope("singlethread")`` or ``syncscope("<target-scope>")`` at
+least *synchronizes with* and is ordered in the seq\_cst order and the
+monotonic modification order relative to other operations that are not
+marked ``syncscope("singlethread")`` or ``syncscope("<target-scope>")``.
 
 .. _floatenv:
 

>From ae33c4563b54795b75c6a691ce979f2ae99a32cb Mon Sep 17 00:00:00 2001
From: Fabian Ritter <fabian.ritter at amd.com>
Date: Tue, 28 Apr 2026 03:52:10 -0400
Subject: [PATCH 2/2] Apply reviewer suggestions

Co-authored-by: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
---
 llvm/docs/LangRef.rst | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 4cd54df2c8f55..74c90d1f06532 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -4056,21 +4056,21 @@ For a simpler introduction to the ordering constraints, see the
 
 If an atomic operation is marked ``syncscope("singlethread")``, it only
 *synchronizes with* other operations running in the same thread (for
-example, in signal handlers) and the constraints on its position
-relative to other operations in the seq\_cst order and the monotonic
-modification order only apply to operations in the same thread.
+example, in signal handlers) and it is related in the seq\_cst order and
+the monotonic modification order with other operations in the same
+thread.
 
 If an atomic operation is marked ``syncscope("<target-scope>")``, where
 ``<target-scope>`` is a target-specific synchronization scope, then it
 is target-dependent if it *synchronizes with* other operations and
-relative to which operations the constraints on its position in the
-seq\_cst order and the monotonic modification order apply.
+if it is related with other operations in the seq\_cst order and the
+monotonic modification order.
 
 Otherwise, an atomic operation that is not marked
-``syncscope("singlethread")`` or ``syncscope("<target-scope>")`` at
-least *synchronizes with* and is ordered in the seq\_cst order and the
-monotonic modification order relative to other operations that are not
-marked ``syncscope("singlethread")`` or ``syncscope("<target-scope>")``.
+``syncscope("singlethread")`` or ``syncscope("<target-scope>")``
+*synchronizes with* and is related in the seq\_cst order and the
+monotonic modification order with other operations that are not marked
+``syncscope("singlethread")`` or ``syncscope("<target-scope>")``.
 
 .. _floatenv:
 



More information about the llvm-commits mailing list