Timothy Baldridge
2014-Jan-06 17:46 UTC
[LLVMdev] Inlining native functions during JIT compilation
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140106/f4784256/attachment.html>
Eric Christopher
2014-Jan-06 20:06 UTC
[LLVMdev] Inlining native functions during JIT compilation
llvm is capable of inlining some of the basic functions like that during some of the optimization passes. How are you compiling? On Mon Jan 06 2014 at 9:49:04 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140106/c2e41152/attachment.html>
Philip Reames
2014-Jan-06 23:25 UTC
[LLVMdev] Inlining native functions during JIT compilation
As long as the JIT knows about the IR for the functions, you should be able to use the standard inlining passes. For standard c routines (memcpy,etc..) this knowledge is built in. For language specific routines, you'll have to provide the IR. Philip On 1/6/14 9:46 AM, Timothy Baldridge 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/4cd70c3c/attachment.html>
Kevin Modzelewski
2014-Jan-06 23:40 UTC
[LLVMdev] Inlining native functions during JIT compilation
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>