When should I omit the frame pointer?

后端 未结 4 880
悲哀的现实
悲哀的现实 2020-12-14 00:56

Is there any substantial optimization when omitting the frame pointer? If I have understood correctly by reading this page, -fomit-frame-pointer is used when we

4条回答
  •  情歌与酒
    2020-12-14 01:34

    -fomit-frame-pointer allows one extra register to be available for general-purpose use. I would assume this is really only a big deal on 32-bit x86, which is a bit starved for registers.*

    One would expect to see EBP no longer saved and adjusted on every function call, and probably some additional use of EBP in normal code, and fewer stack operations on occasions where EBP gets used as a general-purpose register.

    Your code is far too simple to see any benefit from this sort of optimization-- you're not using enough registers. Also, you haven't turned on the optimizer, which might be necessary to see some of these effects.

    * ISA registers, not micro-architecture registers.

提交回复
热议问题