[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v5 (PR #108636)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 2 23:33:57 PDT 2024
================
@@ -522,6 +526,28 @@ let Predicates = [BPFNoALU32] in {
}
def STD : STOREi64<BPF_DW, "u64", store>;
+class relaxed_store<PatFrag base>
+ : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+ let IsAtomic = 1;
+ let IsAtomicOrderingReleaseOrStronger = 0;
+}
+
+class releasing_store<PatFrag base>
+ : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+ let IsAtomic = 1;
+ let IsAtomicOrderingRelease = 1;
+}
----------------
yonghong-song wrote:
> Eduard [suggested earlier](https://github.com/llvm/llvm-project/pull/108636#discussion_r1765597286) (referencing [Andrii's suggestion](https://github.com/llvm/llvm-project/pull/107343#issuecomment-2334664935) in #107343) that, for now, we "fall back" to `ACQUIRE` or `RELEASE` if user requested `RELAXED`, until we actually support `RELAXED` in the future.
>
> > Is my interpretation correct or __atomic_load_n(ptr, __ATOMIC_RELAXED) could have semantics beyond '*ptr'?
>
> `__ATOMIC_RELAXED` still guarantees atomicity but `*ptr` does not, if i'm understanding correctly?
bpf prog does not support misaligned load/store etc. So for 'int *ptr', 'long *ptr', etc. dereference will have a single load or store and it is atomic.
https://github.com/llvm/llvm-project/pull/108636
More information about the cfe-commits
mailing list