This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/70047] Warn on inefficient function parameter passing
- From: "jaak at ristioja dot ee" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 28 Sep 2017 16:42:39 +0000
- Subject: [Bug middle-end/70047] Warn on inefficient function parameter passing
- Auto-submitted: auto-generated
- References: <bug-70047-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70047
--- Comment #2 from Jaak Ristioja <jaak at ristioja dot ee> ---
Perhaps the simplest example for x86_64 would be something like:
void f(long a1, long a2, long a3, long a4, long a5, long a6, long a7);
According to the ABI all seven arguments are classified as INTEGER-s. Arguments
a1 through a6 get passed in %rdi, %rsi, %rdx, %rcx, %r8 and %r9 respectively,
but a7 will be passed on the stack because no other registers are available.
Therefore, in machine code passing/accessing a7 via the stack might be slightly
slower than accessing the rest of the variables via registers. The situation
gets more complicated with floating-point and aggregate values.