Push/pop around a call on x86_64 (SysV ABI)

Viewed 39

For

int callee(void);
int caller(void) { return callee()+1; }

gcc and clang generate (https://gcc.godbolt.org/z/R6ZKZA):

clang:

caller:                                 # @caller
        push    rax
        call    callee
        inc     eax
        pop     rcx
        ret

gcc:

caller:                                 # @caller
        push    rax
        call    callee
        inc     eax
        pop     rcx
        ret

Why are the push/pop instructions around the call needed?

0 Answers
Related