test.c ``` void my_fun(int *arr, int N) { int sum = 0; for (int i = 0; i < N; ++i) { sum += arr[i]; } }
int main(void) { return 0; } ``` clang -c -g test.c ; objdump -S test.o > test.s `my_fun` appears twice in the disassembly code. Excerpt of test.s: ``` void my_fun(int *arr, int N) { 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 89 7d f8 mov %rdi,-0x8(%rbp) 8: 89 75 f4 mov %esi,-0xc(%rbp) int sum = 0; b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%rbp) for (int i = 0; i < N; ++i) { 12: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%rbp) 19: 8b 45 ec mov -0x14(%rbp),%eax 1c: 3b 45 f4 cmp -0xc(%rbp),%eax 1f: 0f 8d 21 00 00 00 jge 46 <my_fun+0x46> sum += arr[i]; 25: 48 63 45 ec movslq -0x14(%rbp),%rax 29: 48 8b 4d f8 mov -0x8(%rbp),%rcx 2d: 8b 14 81 mov (%rcx,%rax,4),%edx 30: 03 55 f0 add -0x10(%rbp),%edx 33: 89 55 f0 mov %edx,-0x10(%rbp) void my_fun(int *arr, int N) { int sum = 0; for (int i = 0; i < N; ++i) { 36: 8b 45 ec mov -0x14(%rbp),%eax 39: 05 01 00 00 00 add $0x1,%eax 3e: 89 45 ec mov %eax,-0x14(%rbp) 41: e9 d3 ff ff ff jmpq 19 <my_fun+0x19> sum += arr[i]; } } ``` clang: Ubuntu clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) Target: x86_64-pc-linux-gnu Thread model: posix objdump: GNU objdump (GNU Binutils for Ubuntu) 2.24 -- Best Regards Yours faithfully Albert Netymk _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils