This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc -S vs clang -S


Hi,

Clang 3.7 generated the following code:

$ clang -S -O0 -fno-unwind-tables -fno-asynchronous-unwind-tables
add.c -o add_att_x64.s

add:
         pushq   %rbp
         movq    %rsp, %rbp
         movl    %edi, -4(%rbp)
         movl    %esi, -8(%rbp)
         movl    -4(%rbp), %esi
         addl    -8(%rbp), %esi
         movl    %esi, %eax
         popq    %rbp
         retq

While gcc 4.8 generated the following:

$ gcc -S -O0 -fno-unwind-tables -fno-asynchronous-unwind-tables add.c
-o add_att_x64.s

add:
        pushq   %rbp
        movq    %rsp, %rbp
        movl    %edi, -4(%rbp)
        movl    %esi, -8(%rbp)
        movl    -8(%rbp), %eax
        movl    -4(%rbp), %edx
        addl    %edx, %eax
        popq    %rbp
        ret

$ cat add.c
int add(int a, int b) {
        return a + b;
}

Is the clang version better?

-- 
Thiago Farina


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]