Why doesn't gcc assembly substract rsp?

278 views Asked by At

While exploring godbolt, I noticed that gcc almost never substracts from rsp. For example:

square(int):
        push    rbp
        mov     rbp, rsp
        mov     DWORD PTR [rbp-4], edi ; [rbp-4] is not in square(int)'s stack frame
        mov     eax, DWORD PTR [rbp-4]
        imul    eax, eax
        pop     rbp
        ret

Why? Shouldn't there be sub rsp, 4 for allocating an integer on the stack?

0

There are 0 answers