The following 3 equvalent variants of the same primitive program should lead to the same code, but they don't:
1. C source: static inline int f1(); static inline int f2(); int main() { f1(); } static inline int f1() { f2(); } static inline int f2() { return 1; } Its assembler output: .file "main_1.c" .version "01.01" gcc2_compiled.: .text .align 4 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp pushl %eax pushl %eax leave jmp f1 .Lfe1: .size main,.Lfe1-main .align 4 .type f1,@function f1: pushl %ebp movl %esp, %ebp pushl %edx pushl %edx leave jmp f2 .Lfe2: .size f1,.Lfe2-f1 .align 4 .type f2,@function f2: pushl %ebp movl $1, %eax movl %esp, %ebp popl %ebp ret .Lfe3: .size f2,.Lfe3-f2 .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)" 2. C source: static inline int f1(); static inline int f2(); int main() { f1(); } static inline int f2() { return 1; } static inline int f1() { f2(); } Its assembler output: .file "main_2.c" .version "01.01" gcc2_compiled.: .text .align 4 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp pushl %eax pushl %eax leave jmp f1 .Lfe1: .size main,.Lfe1-main .align 4 .type f1,@function f1: pushl %ebp movl %esp, %ebp popl %ebp ret .Lfe2: .size f1,.Lfe2-f1 .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)" 3. C source: static inline int f1(); static inline int f2(); static inline int f2() { return 1; } static inline int f1() { f2(); } int main() { f1(); } Its assembler output: .file "main_3.c" .version "01.01" gcc2_compiled.: .text .align 4 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp popl %ebp ret .Lfe1: .size main,.Lfe1-main .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)" In the C code automatically generated by the nesC compiler such a situation leads to significant missing of optimization for size. -- Summary: asm code depends on position of function in the source Product: gcc Version: 2.96 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: inline-asm AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: y_s_r at list dot ru CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20712