diff options
author | Jose E. Marchesi <jose.marchesi@oracle.com> | 2024-08-05 16:23:47 +0200 |
---|---|---|
committer | Jose E. Marchesi <jose.marchesi@oracle.com> | 2024-08-05 18:09:07 +0200 |
commit | c26534d21159dd4c5d1472f0050b65e148161691 (patch) | |
tree | 8cab28ce7c4aef153c318bda5b4bdc70d5cefad6 /gcc/dwarf2codeview.cc | |
parent | 70ffc57fd2fdb3c8fa67f11d2e8e6b6275dcc7c0 (diff) | |
download | gcc-c26534d21159dd4c5d1472f0050b65e148161691.zip gcc-c26534d21159dd4c5d1472f0050b65e148161691.tar.gz gcc-c26534d21159dd4c5d1472f0050b65e148161691.tar.bz2 |
bpf: do not emit BPF non-fetching atomic instructions
When GCC finds a call to one of the __atomic_OP_fetch built-ins in
which the return value is not used it optimizes it into the
corresponding non-fetching atomic operation. Up to now we had
definitions in gcc/config/bpf/atomic.md to implement both atomic_OP
and atomic_fetch_OP sets of insns:
atomic_add -> aadd (aka xadd)
atomic_and -> aand
atomic_or -> aor
atomic_xor -> axor
atomic_fetch_add -> afadd
atomic_fetch_and -> afand
atomic_fetch_or -> afor
atomic_fetch_xor -> afxor
This was not correct, because as it happens the non-fetching BPF
atomic instructions imply different memory ordering semantics than the
fetching BPF atomic instructions, and they cannot be used
interchangeably, as it would be expected.
This patch modifies config/bpf/atomic.md in order to not define the
atomic_{add,and,or,xor} insns. This makes GCC to implement them in
terms of the corresponding fetching operations; this is less
efficient, but correct. It also updates the expected results in the
corresponding tests, which are also updated to cover cases where the
value resulting from the __atomic_fetch_* operations is actually used.
Tested in bpf-unknown-none target in x86_64-linux-gnu host.
gcc/ChangeLog
* config/bpf/atomic.md ("atomic_add<AMO:mode>"): Remove insn.
("atomic_and<AMO:mode>"): Likewise
("atomic_or<AMO:mode>"): Likewise.
("atomic_xor<AMO:mode>"): Likewise.
gcc/testsuite/ChangeLog
* gcc.target/bpf/atomic-op-1.c (test_used_atomic_add): New
function.
(test_used_atomic_sub): Likewise.
(test_used_atomic_and): Likewise.
(test_used_atomic_nand): Likewise.
(test_used_atomic_or): Likewise.
(test_used_atomic_xor): Likewise.
* gcc.target/bpf/atomic-op-2.c (test_used_atomic_add): Likewise.
(test_used_atomic_sub): Likewise.
(test_used_atomic_and): Likewise.
(test_used_atomic_nand): Likewise.
(test_used_atomic_or): Likewise.
(test_used_atomic_xor): Likewise.
* gcc.target/bpf/sync-fetch-and-add.c: Expected results updated.
Diffstat (limited to 'gcc/dwarf2codeview.cc')
0 files changed, 0 insertions, 0 deletions