]> git.ipfire.org Git - thirdparty/gcc.git/commit
bpf: support `naked' function attributes in BPF targets
authorJose E. Marchesi <jose.marchesi@oracle.com>
Thu, 17 Aug 2023 12:19:15 +0000 (14:19 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Thu, 17 Aug 2023 12:39:46 +0000 (14:39 +0200)
commitb7c50f68f26146e7038e9793b6c623ff4c4895d3
tree2f26cfb119123da68cfc7190dc586364aa1b0ea3
parentd07bce478f9d770de5acb0480a3f0cec2f8b72d8
bpf: support `naked' function attributes in BPF targets

The kernel selftests and other BPF programs make extensive use of the
`naked' function attribute with bodies written using basic inline
assembly.  This patch adds support for the attribute to
bpf-unkonwn-none, makes it to inhibit warnings due to lack of explicit
`return' statement, and updates documentation and testsuite
accordingly.

Tested in x86_64-linux-gnu host and bpf-unknown-none target.

gcc/ChangeLog

PR target/111046
* config/bpf/bpf.cc (bpf_attribute_table): Add entry for the
`naked' function attribute.
(bpf_warn_func_return): New function.
(TARGET_WARN_FUNC_RETURN): Define.
(bpf_expand_prologue): Add preventive comment.
(bpf_expand_epilogue): Likewise.
* doc/extend.texi (BPF Function Attributes): Document the `naked'
function attribute.

gcc/testsuite/ChangeLog

* gcc.target/bpf/naked-1.c: New test.
gcc/config/bpf/bpf.cc
gcc/doc/extend.texi
gcc/testsuite/gcc.target/bpf/naked-1.c [new file with mode: 0644]