[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 31 10:49:28 PDT 2024


yonghong-song wrote:

I remembered I mentioned earlier that for __ATOMIC_RELAXED, we should just use plain load/store. But I have the following example,

```
[yhs at devbig309.ftw3 ~/tmp4]$ cat atomic.c
long bar(unsigned char *ptr) {
    return __atomic_load_n(ptr, __ATOMIC_RELAXED);
}
$ llvm-objdump -d atomic.o

atomic.o:       file format elf64-bpf

Disassembly of section .text:

0000000000000000 <bar>:
       0:       d3 10 00 00 12 00 00 00 w0 = load_acquire((u8 *)(r1 + 0x0))
       1:       95 00 00 00 00 00 00 00 exit
$
```

For fetch_and_*() operations if it is __ATOMIC_RELAXED, the code will be different from other atomic flavor.
I think for load_acquire and store_release case, we should not use load_acquire/store_release if it is __ATOMIC_RELAXED, and should just use plain load and store.

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


More information about the cfe-commits mailing list