Inlining native functions during JIT compilation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Inlining native functions during JIT compilation

Timothy Baldridge
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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Inlining native functions during JIT compilation

Eric Christopher
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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Inlining native functions during JIT compilation

Philip Reames-4
In reply to this post by Timothy Baldridge
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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Inlining native functions during JIT compilation

Kevin Modzelewski
In reply to this post by Timothy Baldridge
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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev