target/9841: ARM - appears to always save LR on stack, even with -fomit-frame-pointer
luke@diamand.org
luke@diamand.org
Mon Feb 24 21:46:00 GMT 2003
>Number: 9841
>Category: target
>Synopsis: ARM - appears to always save LR on stack, even with -fomit-frame-pointer
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 24 21:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: luke@diamand.org
>Release: 3.2.2
>Organization:
>Environment:
Linux x86 host
arm-elf target
>Description:
ARM/gcc3.2.2 always appears to save LR on the stack, even when not needed, and regarldess of -fomit-frame-pointer.
>How-To-Repeat:
I seem unable to get -fomit-frame-pointer to do anything on
ARM/gcc3.2.2.
With gcc2.95.2, configured for ARM/AOUT, compiling the following function:
void test(char *buf) {
my_strcpy(buf,"HELLO");
}
with:
% gcc -S -O2 -fomit-frame-pointer -mapcs-32 foo.c
I would get:
_test:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, current_function_anonymous_args = 0
@ I don't think this function clobbers lr
ldr r1, L3
b _my_strcpy
Now the same code, with gcc3.2.2 (configured for ELF this time but I can't see why that should change things) I get:
test:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
str lr, [sp, #-4]!
ldr r1, .L2
@ Sibcall epilogue
ldr lr, [sp], #4
b my_strcpy
So, the compiler carefully stores lr on the stack, for no good reason as far as I can tell (I have no interest in debugging this code, hence the -fomit-frame-pointer). I can't find any combination of options that will make this compile properly (-mapcs-frame, -mapcs-32).
Looking at the code in gcc/config/arm/arm.c, and comparing releases, it looks as though the code for this optimization has been lost.
This adds quite significantly to code size, and probably slows things down as well.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list