"-fomit-frame-pointer" means the way we don't have to pushq %rbp and move %rsp, %rbp; we need to only change the value of %rsp. As far as i think, stack frame dealing with the base pointer and stack frame without it don't have differences in terms of benefits. Could you explain what benefits "stack-frame without dealing with %ebp" has?
Asked
Active
Viewed 1,042 times
2

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

주혜민
- 67
- 6
-
1The code generator can now use ebp as a general purpose register, improves efficiency of legacy 32-bit code. This doesn't get used often, it makes code very hard to debug since stack traces can now only be generated accurately with debug metadata. – Hans Passant Oct 11 '20 at 11:38
-
1It *does* get used very often since at least gcc enables it with `-O2` automatically. – Jester Oct 11 '20 at 11:50
-
2@HansPassant: It's on by default when optimization is enabled, even for 32-bit code in GCC for several years now; I'd hardly say it "doesn't get used often". It's been on by default since forever in x86-64 code; OP mentions RBP as well. Modern Linux (x86-64 System V ABI) treats the `.eh_frame` metadata as necessary, not as "debug" info: it generates it by default, and doesn't strip it in otherwise stripped binaries, even for C. (It's necessary for C++ exception handling, but not really for C except for backtraces) – Peter Cordes Oct 11 '20 at 11:50
-
[Phoronix tested](https://www.phoronix.com/scan.php?page=article&item=fedora-frame-pointer&num=1) the performance downside of `-O2 -fno-omit-frame-pointer` with x86-64 GCC12.1 on a Zen3 laptop CPU for multiple open-source programs, as proposed for Fedora 37. Most of them had performance regressions, a few of them very serious, although the biggest ones are probably some kind of fluke or other interaction. **Geometric mean 14% faster without frame pointers.** – Peter Cordes Jul 02 '22 at 07:11