[Bug target/11824] New: [ARM] Parameter passing via stack could be improved
alga at rgai dot hu
gcc-bugzilla@gcc.gnu.org
Wed Aug 6 08:52:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11824
Summary: [ARM] Parameter passing via stack could be improved
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alga at rgai dot hu
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf
For each function that uses the stack for parameter passing GCC generally
first stores lr and decrements sp, and before returning it increments
sp and loads lr into pc.
If the number of the parameters is not too much, then GCC could perform the
parameter passing in a tricky way (as far as code size is concerned),
i.e. save some arbitrary registers with lr on the stack
(so the sp is modified implicitly).
--- c example ---
// arm-elf-gcc -S -g0 -Os -o param-stack.s param-stack.c
void func (int* a, int* b);
void foo ()
{
int a=6, b=7;
func(&a, &b);
}
--- asm code ---
foo:
mov ip, sp
stmfd sp!, {fp, ip, lr, pc} <- OLD
mov r3, #6
sub fp, ip, #4
sub sp, sp, #8 <- OLD
sub r0, fp, #16
str r3, [fp, #-16]
sub r1, fp, #20
add r3, r3, #1
str r3, [fp, #-20]
bl func
ldmea fp, {fp, sp, pc}
--- possible solution ---
foo:
mov ip, sp
stmfd sp!, {r1, r2, fp, ip, lr, pc} <-NEW
mov r3, #6
sub fp, ip, #4
sub r0, fp, #16
str r3, [fp, #-16]
sub r1, fp, #20
add r3, r3, #1
str r3, [fp, #-20]
bl func
ldmea fp, {fp, sp, pc}
More information about the Gcc-bugs
mailing list