When dealing with local variables, the normal way is after pushing rbp
and moving rsp
's value to rbp
, we subtract rsp
to reserve space in the head of function, and accessing local variables via rbp
. I wonder why not just push one once meeting a local variable, and we can still access local variables via rbp
.
Asked
Active
Viewed 271 times
1

Peter Cordes
- 328,167
- 45
- 605
- 847

Evian
- 1,035
- 1
- 9
- 22
-
It's faster to subtract once than pushing multiple times. – interjay Jul 02 '19 at 08:48
-
1clang *does* do a dummy push/pop when it needs to move RSP by exactly 8 bytes. – Peter Cordes Jul 02 '19 at 09:10