[LLVMdev] function inlining

Kenneth Uildriks kennethuil at gmail.com
Tue Feb 2 09:55:25 PST 2010

On Tue, Feb 2, 2010 at 11:40 AM, Jochen Wilhelmy <j.wilhelmy at arcor.de> wrote:
> Hi!
> I have a llvm::Module that references an external function
> and a second mdoule that implements the function.
> The implementation consists of only one instruction.
> How can I explicitly inline this function?
> -Jochen
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

There's the "always inline" function attribute.

However, the function can't be inlined unless its containing module is
linked to the calling module and the result optimized... inlining
requires copying the body of one function into another, and you need
both function bodies for that.  Now if the modules are linked together
and then optimized, a single-instruction function is overwhelmingly
likely to be inlined into its callers under standard inlining
heuristics, so you don't really need to do anything to force this
particular function to be inlined beyond making it possible by linking
the modules together.

More information about the llvm-dev mailing list