[llvm] BPF: Ensure __sync_fetch_and_add() always generate atomic_fetch_add insn (PR #101428)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 13:18:24 PDT 2024
4ast wrote:
> I think we should report an error when __sync_fetch_and_add is used for cpu v1.
datadog is not the only user of (void)__sync_fetch_and_add(&counter, ...);
cilium has the same pattern and they also support old kernels.
If new llvm errors with -mcpu=v1 the users wouldn't upgrading llvm.
So I think for -mcpu=v1 and (void)__sync_fetch_and_add() llvm should generate old bpf xadd insn,
since that's the only insn it can generate.
For pattern "var = __sync_fetch_and_add()" and -mcpu=v1 llvm should error.
I believe it started doing this already some time back.
For (void)__sync_fetch_and_add() and -mcpu=v3 we should generate fetch_and_add() insn.
https://github.com/llvm/llvm-project/pull/101428
More information about the llvm-commits
mailing list