Force a function to be inline in Clang/LLVM

后端 未结 5 1627
醉话见心
醉话见心 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:31

    I am going to treat your question as asking for any tools within the Clang/LLVM framework. Here is my suggestion: compile your code to LLVM bitcode and then run the Always inline pass.

    For example:

    > clang  -emit-llvm -c -o foo.bc foo.c
    > opt -always-inline foo.bc -o foo_inline.bc
    > clang -c -o foo.o foo_inline.bc
    

    I have used this sequence before and it has inlined all of my functions marked "always_inline". In my case, I was already doing other analyses and transforms on the bitcode, so I only had to add the flag to opt.

提交回复
热议问题