[llvm] [RFC][BPF] Do atomic_fetch_*() pattern matching with memory ordering (PR #107343)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 17:03:46 PDT 2024


eddyz87 wrote:

Also note:

```c
$ cat test2.c
long f1(_Atomic long *i) { return __c11_atomic_fetch_add(i, 10, __ATOMIC_RELAXED); }
```
```c
$ clang --target=bpf -mcpu=v3 -O2 test2.c -c -o - | llvm-objdump -Sdr -
test2.c:1:6: error: Invalid usage of the XADD return value
    1 | long f1(_Atomic long *i) { return __c11_atomic_fetch_add(i, 10, __ATOMIC_RELAXED); }
      |      ^
1 error generated.

<stdin>:	file format elf64-bpf

Disassembly of section .text:

0000000000000000 <f1>:
       0:	b7 00 00 00 0a 00 00 00	r0 = 0xa
       1:	db 01 00 00 00 00 00 00	lock *(u64 *)(r1 + 0x0) += r0
       2:	95 00 00 00 00 00 00 00	exit
```

Which seems incorrect.

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


More information about the llvm-commits mailing list