https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63596
Bug ID: 63596
Summary: Saving of GPR/FPRs for stdarg even though the variable
argument is not used
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target: aarch64
Take a function like:
int f(int a, ...)
{
return a;
}
Currently with the top of the trunk we get:
f:
sub sp, sp, #192
stp x1, x2, [sp, 136]
stp x3, x4, [sp, 152]
stp x5, x6, [sp, 168]
str x7, [sp, 184]
str q0, [sp]
str q1, [sp, 16]
str q2, [sp, 32]
str q3, [sp, 48]
str q4, [sp, 64]
str q5, [sp, 80]
str q6, [sp, 96]
str q7, [sp, 112]
add sp, sp, 192
ret
--- CUT ---
But we can optimize this down to just
f:
ret
--- CUT ---
The .stdarg debug dump says:
f: va_list escapes 0, needs to save 0 GPR units and 0 FPR units.
But nowhere in aarch64.c uses cfun->va_list_gpr_size or cfun->va_list_fpr_size
to figure out how many registers need to be saved.