[LLVMdev] Inlining native functions during JIT compilation

Kevin Modzelewski kmod at dropbox.com
Mon Jan 6 15:40:47 PST 2014


If all your IR is in a single module, and you're willing to reoptimize the
entire module every time you want to do inlining, you can use the existing
machinery pretty easily.

But unless those are both true, the situation is more complicated: my
understanding is the inlining machinery (at least for non-builtins, not
sure how those work) assumes that 1) you're inlining functions from the
same module, and 2) you're optimizing an entire module at a time.  I ended
up writing a custom inlining FunctionPass: I initialize an
InlineCostAnalysis object (which ends up being quite hacky since it expects
to be part of a passmanager even though that's not what we want here), use
that to determine when to inline, call llvm::InlineFunction() when it says
I should, and then use a custom ValueMaterializer to remap references from
objects in the other module (ex global variables, function declarations,
etc) to the correct references in the current module.


On Mon, Jan 6, 2014 at 9:46 AM, Timothy Baldridge <tbaldridge at gmail.com>wrote:

> Let's say I'm using LLVM to JIT compile a function. Inside that function I
> make a call to a runtime method in a currently loaded library. Is there any
> way to get LLVM to inline that function call?
>
> As an example, let's say my jitted function calls memcpy, can I get
> memcpy's body inlined somehow? Or can that only be done via lto and aot
> compilation?
>
> Thanks,
>
> Timothy Baldridge
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140106/b386cdb9/attachment.html>


More information about the llvm-dev mailing list