https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114136
Bug ID: 114136
Summary: wrong code for c23 fully anonymous arg lists on arm
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: rearnsha at gcc dot gnu.org
Target Milestone: ---
Target: arm
On arm, a fully anonymous c23-style function is called incorrectly. All
arguments are passed on the stack while the receiving function expects r0-r3 to
be used for the initial arguments.
For example,
void f (...);
void g()
{
f (1, 2, 3, 4);
}
With gcc compiles to:
g:
push {lr}
movs r0, #1
movs r1, #2
sub sp, sp, #20
movs r2, #3
movs r3, #4
stm sp, {r0, r1, r2, r3} // Arguments pushed to stack (wrong)
bl f
add sp, sp, #20
ldr pc, [sp], #4
When the correct code (eg, as produced by clang) is something like
g:
mov r0, #1
mov r1, #2
mov r2, #3
mov r3, #4
b f
compile with, eg
arm-non-eabi-gcc -O2 -c23