With reference to the following code:
#include <cstdint>
void func() {
return;
}
void funcparent() {
uint64_t h = 99;
func();
}
void funcparent2() {
func();
}
void funcparent3() {
func();
int h = 99;
}
And assembly, from compiling with no optimization with recent clang for a non-Windows calling convention, like on Godbolt:
_Z4funcv: # @_Z4funcv
push rbp
mov rbp, rsp
pop rbp
ret
_Z10funcparentv: # @_Z10funcparentv
push rbp
mov rbp, rsp
sub rsp, 16
mov qword ptr [rbp - 8], 99
call _Z4funcv
add rsp, 16
pop rbp
ret
_Z11funcparent2v: # @_Z11funcparent2v
push rbp
mov rbp, rsp
call _Z4funcv
pop rbp
ret
_Z11funcparent3v: # @_Z11funcparent3v
push rbp
mov rbp, rsp
sub rsp, 16
call _Z4funcv
mov dword ptr [rbp - 4], 99
add rsp, 16
pop rbp
ret
Where is there a sub rsp, 16
(and subsequent add
) in funcparent()
and funcparent3()
? I thought there is something to do with allocating the stack but funcparent2()
makes me think otherwise.