------- Comment #4 from jhaberman at gmail dot com 2010-07-10 01:38 ------- This seems to happen even with POD return types:
int foo(); void bar(int a); void func() { bar(foo()); } In 32-bit mode it spills the return value to the stack for no reason. It also seems to overallocate the stack (28 bytes allocated, only 4 used): 00000000 <func>: 0: 83 ec 1c sub esp,0x1c 3: e8 fc ff ff ff call 4 <func+0x4> 4: R_386_PC32 foo 8: 89 04 24 mov DWORD PTR [esp],eax b: e8 fc ff ff ff call c <func+0xc> c: R_386_PC32 bar 10: 83 c4 1c add esp,0x1c 13: c3 ret In 64-bit mode there is no store, but it *does* allocate 8 bytes of stack that it never uses: 0000000000000000 <func>: 0: 48 83 ec 08 sub rsp,0x8 4: 31 c0 xor eax,eax 6: e8 00 00 00 00 call b <func+0xb> 7: R_X86_64_PC32 foo+0xfffffffffffffffc b: 48 83 c4 08 add rsp,0x8 f: 89 c7 mov edi,eax 11: e9 00 00 00 00 jmp 16 <func+0x16> 12: R_X86_64_PC32 bar+0xfffffffffffffffc Any idea how hard this bug is to fix? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44194