I'm learning assembly, and I tried compiling the following C code into assembly with GCC with optimization disabled (https://godbolt.org/z/4cz3ocfa5)
void f() {
int x = 1;
int y = 2;
int z = 3;
}
int main() {
f();
return 0;
}
assembly,
f():
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 1
mov DWORD PTR [rbp-8], 2
mov DWORD PTR [rbp-12], 3
nop
pop rbp
ret
main:
push rbp
mov rbp, rsp
call f()
mov eax, 0
pop rbp
ret
I'm confused why where is no mov rsp, rbp before the pop instruction in the epilogue (especially when there are local variables in the stack frame of f).
I thought a complete epilogue should be like
mov rsp, rbp
pop rbp
ret
