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?