Force a function to be inline in Clang/LLVM

后端 未结 5 1623
醉话见心
醉话见心 2021-02-05 11:39

Is there a way to force an inline function in Clang/LLVM?

AFAIK, the following is just a hint to the compiler but it can ignore the request.

__attribute_         


        
5条回答
  •  臣服心动
    2021-02-05 12:21

    You can start with experimenting with: clang -mllvm -inline-threshold=n

    The greater the parameter n, the more agressive the inlining will be. Default is 225 so set it to something bigger. Expect big code size and long compilation times with very agressive inlining. When you hit the point of diminishing returns you can try profiling the code and looking for frequently called but uninlined functions and try marking them with attribute((always_inline)) for even more inlining.

    If you have functions marked "inline", you can also experiment with -inlinehint-threshold bigger than -inline-threshold and see whether this changes anything.

    Also, are you compiling with link-time optimizations? Without them inlining is limited to individual compilation units.

    **taken from groups.google.com forum

提交回复
热议问题