[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 14:12:06 PDT 2024


eddyz87 wrote:

@brycekahle,

> @eddyz87 You are still using `clang --target=bpf`, you have to use the default target.

Well, that is a very strange arrangement, I'm not sure there is a documentation stating that this is a supported use-case. I remember several architecture-specific checks in the clang front-end. Anyways, simple example still works:

```
$ clang -O2 -S -emit-llvm -o - test3.c | llc -march=bpf -mcpu=v1 -o - -filetype=asm
	.text
	.file	"test3.c"
	.globl	foo                             # -- Begin function foo
	.p2align	3
	.type	foo, at function
foo:                                    # @foo
.Lfoo$local:
	.type	.Lfoo$local, at function
	.cfi_startproc
# %bb.0:
	#APP
	lock *(u64 *)(r1 + 0) += r2

	#NO_APP
	exit
.Lfunc_end0:
	.size	foo, .Lfunc_end0-foo
	.size	.Lfoo$local, .Lfunc_end0-foo
	.cfi_endproc
                                        # -- End function
```

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


More information about the llvm-commits mailing list