[llvm] BPF: Ensure __sync_fetch_and_add() always generate atomic_fetch_add insn (PR #101428)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 26 10:11:19 PDT 2024
yonghong-song wrote:
@brycekahle
For the following,
> We also intentionally limit ourselves to v1 of the instruction set. Having the compiler generate v3 instructions, even
> when specifying v1, seems like a bug and a breaking change.
Yes, the new change will generate atomic_fetch_add insn with cpu=v1 instead of 'lock xadd'. We could move generating atomic_fetch_add into -mcpu=v3 but then a lot of bpf programs may fail. Note that atomic_fetch_add in v1 will be okay with >= 5.12. As mentioned in my previous comments, this is a deliberate choice.
You can use inline asm like in
https://lore.kernel.org/bpf/20240803025928.4184433-1-yonghong.song@linux.dev/
'clang -target bpf ...' should work. You do not need to use 'clang + llc'. Let me know if otherwise and I am happy to help.
cc @4ast for more comments.
https://github.com/llvm/llvm-project/pull/101428
More information about the llvm-commits
mailing list