Skip to content

Commit ec2e21a

Browse files
authored
[LangRef] No target-specific size limit for atomics (#136864)
According to the current LangRef, atomics of sizes larger than a target-dependent limit are non-conformant IR. Presumably, that size limit is `TargetLoweringBase::getMaxAtomicSizeInBitsSupported()`. As a consequence, one would not even know whether IR is valid without instantiating the Target backend. To get around this, Clang's CGAtomic uses a constant "16 bytes" for the maximally supported atomic. The verifier only checks the power-of-two requirement. In a discussion with jyknight, the intention is rather that the AtomicExpandPass will just lower everything larger than the target-supported atomic sizes to libcall (such as `__atomic_load`). According to this interpretation, the size limit needs only be known by the lowering and does not affect the IR specification. The original "target-specific size limit" had been added in 59b6688. The LangRef change is needed for #134455 because otherwise frontends need to pass a TargetLowering object to the helper functions just to know what the target-specific limit is. This also changes the LangRef for atomicrmw. Are there libatomic fallbacks for these? If not, LLVM-IR validity still depends on instantiating the actual backend. There are also some intrinsics such as `llvm.memcpy.element.unordered.atomic` that have this constraint but do not change in this PR.
1 parent 7615503 commit ec2e21a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/docs/LangRef.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11281,7 +11281,7 @@ If the ``load`` is marked as ``atomic``, it takes an extra :ref:`ordering
1128111281
Atomic loads produce :ref:`defined <memmodel>` results when they may see
1128211282
multiple atomic stores. The type of the pointee must be an integer, pointer, or
1128311283
floating-point type whose bit width is a power of two greater than or equal to
11284-
eight and less than or equal to a target-specific size limit. ``align`` must be
11284+
eight. ``align`` must be
1128511285
explicitly specified on atomic loads. Note: if the alignment is not greater or
1128611286
equal to the size of the `<value>` type, the atomic operation is likely to
1128711287
require a lock and have poor performance. ``!nontemporal`` does not have any
@@ -11422,7 +11422,7 @@ If the ``store`` is marked as ``atomic``, it takes an extra :ref:`ordering
1142211422
Atomic loads produce :ref:`defined <memmodel>` results when they may see
1142311423
multiple atomic stores. The type of the pointee must be an integer, pointer, or
1142411424
floating-point type whose bit width is a power of two greater than or equal to
11425-
eight and less than or equal to a target-specific size limit. ``align`` must be
11425+
eight. ``align`` must be
1142611426
explicitly specified on atomic stores. Note: if the alignment is not greater or
1142711427
equal to the size of the `<value>` type, the atomic operation is likely to
1142811428
require a lock and have poor performance. ``!nontemporal`` does not have any
@@ -11567,8 +11567,8 @@ There are three arguments to the '``cmpxchg``' instruction: an address
1156711567
to operate on, a value to compare to the value currently be at that
1156811568
address, and a new value to place at that address if the compared values
1156911569
are equal. The type of '<cmp>' must be an integer or pointer type whose
11570-
bit width is a power of two greater than or equal to eight and less
11571-
than or equal to a target-specific size limit. '<cmp>' and '<new>' must
11570+
bit width is a power of two greater than or equal to eight.
11571+
'<cmp>' and '<new>' must
1157211572
have the same type, and the type of '<pointer>' must be a pointer to
1157311573
that type. If the ``cmpxchg`` is marked as ``volatile``, then the
1157411574
optimizer is not allowed to modify the number or order of execution of
@@ -11681,8 +11681,8 @@ operation. The operation must be one of the following keywords:
1168111681
- usub_sat
1168211682

1168311683
For most of these operations, the type of '<value>' must be an integer
11684-
type whose bit width is a power of two greater than or equal to eight
11685-
and less than or equal to a target-specific size limit. For xchg, this
11684+
type whose bit width is a power of two greater than or equal to eight.
11685+
For xchg, this
1168611686
may also be a floating point or a pointer type with the same size constraints
1168711687
as integers. For fadd/fsub/fmax/fmin/fmaximum/fminimum, this must be a floating-point
1168811688
or fixed vector of floating-point type. The type of the '``<pointer>``'

0 commit comments

Comments
 (0)