Avoiding gcc function prologue overhead?

后端 未结 5 1720
逝去的感伤
逝去的感伤 2021-02-13 21:57

I\'ve lately encountered a lot of functions where gcc generates really bad code on x86. They all fit a pattern of:

if (some_condition) {
    /* do something real         


        
5条回答
  •  梦如初夏
    2021-02-13 22:29

    I would probably refactor the code to encourage inlining of the simple case. That said, you can use -finline-limit to make gcc consider inlining larger functions, or -fomit-frame-pointer -fno-exceptions to minimize the stack frame. (Note that the latter may break debugging and cause C++ exceptions to misbehave badly.)

    Probably you won't be able to get much from tweaking compiler options, though, and will have to refactor.

提交回复
热议问题