On 02.08.2016 06:50, Senthil Kumar Selvaraj wrote:
Denis Chertykov writes:
2016-08-01 15:17 GMT+03:00 Georg-Johann Lay <a...@gjlay.de>:
Problem with -fcaller-saves is that there are situations where it triggers
an expensive frame just to store a variable around a function call even
though there are plenty of call-saved registers.
Example:
typedef __UINT8_TYPE__ uint8_t;
extern uint8_t uart0_getc (void);
void foo (uint8_t *buffer, uint8_t cnt)
{
while (--cnt)
{
*buffer++ = uart0_getc();
}
}
$ avr-gcc -Os -S -dp -mmcu=atmega8 loop-buf.c
$ avr-gcc gcc -B$TV -Os -c -save-temps -dp -mmcu=atmega8 loop-buf.c &&
avr-size loop-buf.o
text data bss dec hex filename
50 0 0 50 32 loop-buf.o
$ avr-gcc -Os -c -save-temps -dp -mmcu=atmega8 loop-buf.c -fno-caller-saves
&& avr-size loop-buf.o
text data bss dec hex filename
32 0 0 32 20 loop-buf.o
I actually came never across a situation where -fcaller-saves improved the
code performance, hence this patch proposes to switch off -fcaller-saved per
default.
Like you mentioned in the bug report, would fixing the costs be a better
way to fix this rather than a blanket disabling of the option?
What costs specifically? Where could the costs of different epilogues /
prologues be described?
Johann
Regards
Senthil