Reputation: 9446
I have been writing a small kernel lately based on x86-64 architecture. When taking care of some user space code, I realized I am virtually not using rbp. I then looked up at some other things and found out compilers are getting smarter these days and they really dont use rbp anymore. (I could be wrong here.)
I was wondering if conventional use of rbp/epb is not required anymore in many instances or am I wrong here. If that kind of usage is not required then can it be used like a general purpose register?
Upvotes: 1
Views: 540
Reputation: 16136
It is only needed if you have variable-length arrays in your stack frames (recording the array length would require more memory and more computations). It is no longer needed for unwinding because there is now metadata for that.
It is still useful if you are hand-writing entire assembly functions, but who does that? Assembly should only be used as glue to jump into a C (or whatever) function.
Edit 2025: I have since become aware that many tracing tools that do frequent unwinding benefit from -fno-omit-frame-pointer
. Allegedly this is for performance reasons, but I'm not sure if that's actually true or if it's just laziness and poor implementations.
Upvotes: 3