diff options
author | David Faust <david.faust@oracle.com> | 2024-02-20 14:48:33 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2024-02-21 08:36:07 -0800 |
commit | 5772ea772d1dce5bd9a3be99bf095f6f67810db2 (patch) | |
tree | 69aabfd7057f0931628a42e8e7f840087503e2d8 /libcpp | |
parent | 161a67b2bee84d8fd5ab7711e411f76221c1ea52 (diff) | |
download | gcc-5772ea772d1dce5bd9a3be99bf095f6f67810db2.zip gcc-5772ea772d1dce5bd9a3be99bf095f6f67810db2.tar.gz gcc-5772ea772d1dce5bd9a3be99bf095f6f67810db2.tar.bz2 |
bpf: add inline memmove and memcpy expansion
BPF programs are not typically linked, which means we cannot fall back
on library calls to implement __builtin_{memmove,memcpy} and should
always expand them inline if possible.
GCC already successfully expands these builtins inline in many cases,
but failed to do so for a few for simple cases involving overlapping
memmove in the kernel BPF selftests and was instead emitting a libcall.
This patch implements a simple inline expansion of memcpy and memmove in
the BPF backend in a verifier-friendly way, with the caveat that the
size must be an integer constant, which is also required by clang.
gcc/
* config/bpf/bpf-protos.h (bpf_expand_cpymem): New.
* config/bpf/bpf.cc: (emit_move_loop, bpf_expand_cpymem): New.
* config/bpf/bpf.md: (cpymemdi, movmemdi): New define_expands.
gcc/testsuite/
* gcc.target/bpf/memcpy-1.c: New test.
* gcc.target/bpf/memmove-1.c: New test.
* gcc.target/bpf/memmove-2.c: New test.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions