On Fri, Oct 12, 2012 at 2:19 AM, Mischa Baars <mjbaars1977@xxxxxxxxx> wrote: > On 10/12/2012 11:01 AM, Andrew Pinski wrote: >> >> On Fri, Oct 12, 2012 at 1:55 AM, Mischa Baars <mjbaars1977@xxxxxxxxx> >> wrote: >>> >>> Hi, >>> >>> Here's a possible bug in the compiler: >>> >>> As can be seen from the objdump output, 64-bit arguments are passed in >>> 32-bit registers >>> >>> 000000000040049c <main>: >>> 40049c: 55 push rbp >>> 40049d: 48 89 e5 mov rbp,rsp >>> 4004a0: be 44 44 00 00 mov esi,0x4444 >> >> this is the same as >> mov rsi, 0x4444 >> >> As all instructions which act on the lower 32bit part of the register >> are zero extended into the full 64bit register. > > I see, you are completely right! > >> >> >>> 4004a5: bf 33 33 00 00 mov edi,0x3333 >> >> Likewise. >> >> Thanks, >> Andrew Pinski >> >> PS this question is more relevant to the gcc-help mailing list than the >> gcc one. >> >>> 4004aa: e8 05 00 00 00 call 4004b4 <function> >>> 4004af: 90 nop >>> 4004b0: 5d pop rbp >>> 4004b1: c3 ret >>> 4004b2: 66 90 xchg ax,ax >>> >>> also the opcodes on line 4004AF and 4004B2 seem obsolete. > > And what are these lines doing here exactly? The nop is generated by GCC but I have no idea why and since you are compiling at -O0, it does not matter. The xchg is being generated not by the assembler or GCC but rather by the linker for alignment reasons. Thanks, Andrew >> >> >> >>> Best Regards, >>> Mischa. > >