>Number: 9967 >Category: middle-end >Synopsis: Some standard C function calls should not be replaced when optimizing for size >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: pessimizes-code >Submitter-Id: net >Arrival-Date: Wed Mar 05 14:26:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Árpád Beszédes >Release: gcc version 3.3 20030224 (prerelease) >Organization: >Environment: BUILD & HOST: Linux 2.4.20 i686 unknown TARGET: arm-unknown-elf >Description: GCC replaces calls with special parameters to some standard C functions to equivalent ones in order to increase performance. E.g. fputs with string parameter -> fwrite. However, some of these calls take more instructions, which is not good if we optimize for size. These replacements should be avoided depending on the optimization switches. (See example below.) >How-To-Repeat: This simple program demonstrates that fprintf is replaced by calling fwrite in the assembly output (arm-elf target with newlib library): #include void foo () { fprintf(stderr, "Comment"); // fprintf->fwrite } ldr r3, .L2 ldr r3, [r3, #0] ldr r0, .L2+4 ldr r3, [r3, #12] mov r1, #1 mov r2, #7 b fwrite However, calling fprintf would require two instructions less: ldr r3, .L2 ldr r3, [r3, #0] ldr r1, .L2+4 ldr r0, [r3, #12] b fprintf >Fix: >Release-Note: >Audit-Trail: >Unformatted: