While I could not get the same results on my i5 M520 ( gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 ), I saw differences in the disassembled output.
$ sdiff fS f_cpp.S ... 00000000004004b4 <main>: 00000000004004b4 <main>: 4004b4: 55 push %rbp 4004b4: 55 push %rbp 4004b5: 48 89 e5 mov %rsp,%rbp 4004b5: 48 89 e5 mov %rsp,%rbp 4004b8: 53 push %rbx 4004b8: 53 push %rbx 4004b9: bb 00 00 00 00 mov $0x0,%ebx 4004b9: bb 00 00 00 00 mov $0x0,%ebx 4004be: eb 04 jmp 4004c4 <main+0 4004be: eb 04 jmp 4004c4 <main+0 4004c0: 48 83 c3 01 add $0x1,%rbx 4004c0: 48 83 c3 01 add $0x1,%rbx 4004c4: 48 8b 05 05 01 00 00 mov 0x105(%rip),%r | 4004c4: 48 81 fb ff c9 9a 3b cmp $0x3b9ac9ff,%r 4004cb: 48 39 c3 cmp %rax,%rbx | 4004cb: 0f 96 c0 setbe %al 4004ce: 72 f0 jb 4004c0 <main+0 | 4004ce: 84 c0 test %al,%al 4004d0: b8 00 00 00 00 mov $0x0,%eax | 4004d0: 75 ee jne 4004c0 <main+0 4004d5: 5b pop %rbx | 4004d2: b8 00 00 00 00 mov $0x0,%eax 4004d6: 5d pop %rbp | 4004d7: 5b pop %rbx 4004d7: c3 retq | 4004d8: 5d pop %rbp 4004d8: 90 nop | 4004d9: c3 retq 4004d9: 90 nop < 4004da: 90 nop 4004da: 90 nop 4004db: 90 nop 4004db: 90 nop
And here is how gcc / C went off when profiling:
Percent | Source code & Disassembly of f_c ------------------------------------------------ : : : : Disassembly of section .text: : : 00000000004004b4 <main>: 0.00 : 4004b4: push %rbp 0.00 : 4004b5: mov %rsp,%rbp 0.00 : 4004b8: push %rbx 0.00 : 4004b9: mov $0x0,%ebx 0.00 : 4004be: jmp 4004c4 <main+0x10> 48.97 : 4004c0: add $0x1,%rbx 0.00 : 4004c4: mov 0x105(%rip),%rax
And this is how g ++ went when profiling:
Percent | Source code & Disassembly of g_cpp ------------------------------------------------ : : : : Disassembly of section .text: : : 00000000004004b4 <main>: 0.00 : 4004b4: push %rbp 0.00 : 4004b5: mov %rsp,%rbp 0.00 : 4004b8: push %rbx 0.00 : 4004b9: mov $0x0,%ebx 0.00 : 4004be: jmp 4004c4 <main+0x10> 49.49 : 4004c0: add $0x1,%rbx 0.00 : 4004c4: cmp $0x3b9ac9ff,%rbx 11.24 : 4004cb: setbe %al 39.27 : 4004ce: test %al,%al 0.00 : 4004d0: jne 4004c0 <main+0xc> 0.00 : 4004d2: mov $0x0,%eax 0.00 : 4004d7: pop %rbx 0.00 : 4004d8: pop %rbp
Brian cain
source share