I am compiling this program in C and comparing the generated assembler code:
int main(){ return 0; }
GCC provides this core function ( cc hello.c -S ):
_main: LFB2: pushq %rbp LCFI0: movq %rsp, %rbp LCFI1: movl $0, %eax leave ret
LLVM provides this core function ( clang hello.c -S ):
_main: Leh_func_begin0: pushq %rbp Ltmp0: movq %rsp, %rbp Ltmp1: movl $0, %eax movl $0, -4(%rbp) popq %rbp ret Leh_func_end0:
What are movl $0, -4(%rbp) and popq %rbp ? Moving something on the stack and popping it immediately afterwards seems useless to me.
c assembly gcc instructions llvm
user142019
source share