Created attachment 31424 [details] The preprocessed file for newlib/libc/stdio/findfp.c Hi, for attached preprocessed code from newlib/libc/stdio/findfp.c, GCC inlines static function `std' even when optimizing for Os. With command line: $ ./arm-none-eabi-gcc -Os -mthumb -mcpu=cortex-m0 -c -xc findfp.E -o findfp.o The dumped symbols are like: 21: 00000009 16 FUNC GLOBAL DEFAULT 1 _cleanup_r ... 29: 00000055 224 FUNC GLOBAL DEFAULT 1 __sinit ... 41: 000001d5 24 FUNC GLOBAL DEFAULT 1 __fp_unlock_all With command line: $ ./arm-none-eabi-gcc -Os -mthumb -mcpu=cortex-m0 -c -xc findfp.E -o findfp.o -fno-inline The dumped symbols are like: 9: 00000018 0 NOTYPE LOCAL DEFAULT 1 $t 10: 00000019 72 FUNC LOCAL DEFAULT 1 std.isra.0 ... 24: 00000009 16 FUNC GLOBAL DEFAULT 1 _cleanup_r ... 36: 0000009d 80 FUNC GLOBAL DEFAULT 1 __sinit This occurs on trunk and 4_8 branch.
I think you likely see a 2nd-order effect. Inlining a once called function should not increase code size. But of course optimization opportunities exposed by it may trigger optimizers that are not well tuned to honor -Os. So, can you narrow down the issue a bit?
I will investigate it later. Just clarifying, the function is called three times by the caller, it would increase code size usually. BTW, could you explain a little about "2nd-order effect"? I am not familiar with the concept. Thanks in advance.
Is there a misunderstanding of what called once means? Does it mean only called from one other function rather than one time? I see std is called three times from __sinit rather than once in that function.