When I use gcc -O2 to optimize my program, gcc changes the value of register RBP. But I want to keep it as FRAME BASE REGISTER, how to do this?
Not the same question as: GCC: Prohibit use of some registers
When I use gcc -O2 to optimize my program, gcc changes the value of register RBP. But I want to keep it as FRAME BASE REGISTER, how to do this?
Not the same question as: GCC: Prohibit use of some registers
-fomit-frame-pointeris enabled by default at optimization levels -O, -O2, -O3, -OsYou need to use
-fno-omit-frame-pointerHowever there are not much reasons to keep the frame pointer unless you're debugging and need to trace the stack frame. In that case, use
-Oginstead