[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v5 (PR #108636)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 12:36:28 PDT 2024
================
@@ -621,6 +642,16 @@ let Predicates = [BPFHasLdsx] in {
def LDD : LOADi64<BPF_DW, BPF_MEM, "u64", load>;
+class acquiring_load<PatFrags base>
+ : PatFrag<(ops node:$ptr), (base node:$ptr)> {
+ let IsAtomic = 1;
----------------
eddyz87 wrote:
Note: in #107343 we decided to fallback to more strong orderings if there is no direct instruction available. However, for this pull request I get:
```
$ cat test4.c
char load_acquire_i8(char *p) { return __atomic_load_n(p, __ATOMIC_RELAXED); }
$ clang -O2 -mcpu=v5 --target=bpf test4.c -c -o - | llvm-objdump -d -
fatal error: error in backend: Cannot select: t8: i32,ch = AtomicLoad<(load monotonic (s8) from %ir.p), zext from i8> t0, t2
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t1: i64 = Register %0
In function: load_acquire_i8
...
```
While `consume` appears to work:
```
$ cat test4.c
char load_acquire_i8(char *p) { return __atomic_load_n(p, __ATOMIC_CONSUME); }
$ clang -O2 -mcpu=v5 --target=bpf test4.c -c -o - | llvm-objdump -d -
<stdin>: file format elf64-bpf
Disassembly of section .text:
0000000000000000 <load_acquire_i8>:
0: f1 10 00 00 00 00 00 00 w0 = load_acquire((u8 *)(r1 + 0x0))
1: 95 00 00 00 00 00 00 00 exit
```
(Although, in the light of #107343 I think this should be a `lock ...` instruction).
Also, the error message for `SEQ_CST` should be more user friendly, at the moment it is:
```
$ cat test4.c
char load_acquire_i8(char *p) { return __atomic_load_n(p, __ATOMIC_SEQ_CST); }
$ clang -O2 -mcpu=v5 --target=bpf test4.c -c -o - | llvm-objdump -d -
fatal error: error in backend: Cannot select: t8: i32,ch = AtomicLoad<(load seq_cst (s8) from %ir.p), zext from i8> t0, t2
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t1: i64 = Register %0
In function: load_acquire_i8
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
...
```
https://github.com/llvm/llvm-project/pull/108636
More information about the llvm-commits
mailing list