1

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?

fuz
  • 88,405
  • 25
  • 200
  • 352
gavrilikhin.d
  • 554
  • 1
  • 7
  • 20

0 Answers0