aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2020-05-19 11:46:40 +0200
committerJose E. Marchesi <jose.marchesi@oracle.com>2020-05-19 11:46:40 +0200
commit98456a64b0b5c20eeb8f964c7718072ba9b0e568 (patch)
tree3d36b779e491302a4e2072b5fec294e59c9c1b37 /gcc/doc
parent51e10276d6792f67f1d88d90f299e7ac1b1f1f24 (diff)
downloadgcc-98456a64b0b5c20eeb8f964c7718072ba9b0e568.zip
gcc-98456a64b0b5c20eeb8f964c7718072ba9b0e568.tar.gz
gcc-98456a64b0b5c20eeb8f964c7718072ba9b0e568.tar.bz2
bpf: do not save/restore callee-saved registers in function prolog/epilog
BPF considers that every call to a function allocates a fresh set of registers that are available to the callee, of which the first five may have bee initialized with the function arguments. This is implemented by both interpreter and JIT in the Linux kernel. This is enforced by the kernel BPF verifier, which will reject any code in which non-initialized registers are accessed before being written. Consequently, the spill instructions generated in function prologue were causing the verifier to reject our compiled programs. This patch makes GCC to not save/restore callee-saved registers in function prologue/epilogue, unless xBPF mode is enabled. 2020-05-19 Jose E. Marchesi <jose.marchesi@oracle.com> gcc/ * config/bpf/bpf.c (bpf_compute_frame_layout): Include space for callee saved registers only in xBPF. (bpf_expand_prologue): Save callee saved registers only in xBPF. (bpf_expand_epilogue): Likewise for restoring. * doc/invoke.texi (eBPF Options): Document this is activated by -mxbpf. gcc/testsuite/ * gcc.target/bpf/xbpf-callee-saved-regs-1.c: New test. * gcc.target/bpf/xbpf-callee-saved-regs-2.c: Likewise.
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 0c33deb..7217e27 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -21016,7 +21016,11 @@ Generate code for a little-endian target. This is the default.
@item -mxbpf
Generate code for an expanded version of BPF, which relaxes some of
-the restrictions imposed by the BPF architecture.
+the restrictions imposed by the BPF architecture:
+@itemize @minus
+@item Save and restore callee-saved registers at function entry and
+exit, respectively.
+@end itemize
@end table
@node FR30 Options