public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109068] New: bpf: "error: too many function arguments for eBPF" for always_inline function
@ 2023-03-08 19:40 david.faust at oracle dot com
  2023-03-30 18:24 ` [Bug target/109068] " pinskia at gcc dot gnu.org
  2023-08-15 12:48 ` jemarch at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: david.faust at oracle dot com @ 2023-03-08 19:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109068

            Bug ID: 109068
           Summary: bpf: "error: too many function arguments for eBPF" for
                    always_inline function
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.faust at oracle dot com
                CC: cupertino.miranda at oracle dot com, jemarch at gcc dot gnu.org
  Target Milestone: ---
            Target: bpf

BPF calling convention does not support function calls with more than
5 arguments. But if the function is inlined this restriction should be
relaxed.

Many convenience macros for BPF in the kernel make use of always_inline
functions, and the expansion of the macro uses can result in an
always_inline function with >5 args. There are several examples of this
in the BPF selftests, so GCC fails to compile those tests.
e.g. on bpf-next:
    linux/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c
 and corresponding BPF_KSYSCALL macro def in
    linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_tracing.h
 duplicated from
    linux/tools/lib/bpf/bpf_tracing.h

clang compiles these tests without issue.

We should fix the BPF backend check for function arguments to allow
calls to inline functions with >5 args.


$ cat args.c
inline __attribute__((always_inline))
int foo (int a, int b, int c, int d, int e, int f)
{
  return a + b + c + d + e + f;
}

int bar (int x)
{
  return foo (x, x*2, x*3, x*4, x*5, x*6);
}

$ bpf-unknown-none-gcc -c args.c -o args.o
args.c: In function ‘foo’:
args.c:2:5: error: too many function arguments for eBPF
    2 | int foo (int a, int b, int c, int d, int e, int f)
      |     ^~~

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-15 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 19:40 [Bug target/109068] New: bpf: "error: too many function arguments for eBPF" for always_inline function david.faust at oracle dot com
2023-03-30 18:24 ` [Bug target/109068] " pinskia at gcc dot gnu.org
2023-08-15 12:48 ` jemarch at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).