[LLVMdev] Help with using LLVM to re-compile hot functions at run-time (original) (raw)

Hal Finkel hfinkel at anl.gov
Sun Jul 26 23:35:41 PDT 2015


----- Original Message -----

From: "Revital1 Eres" <ERES at il.ibm.com> To: "Lang Hames" <lhames at gmail.com> Cc: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> Sent: Monday, July 27, 2015 1:17:52 AM Subject: Re: [LLVMdev] Help with using LLVM to re-compile hot functions at run-time

Hi Again, I'm a little confused regarding what is the exact Orc's functions I should use in order to save the functions code in a code cache so it could be later replaced with different versions of it and I appreciate your help. Just a reminder I want to dynamically recompile the program based on profile collected at the run-time. I would like to start executing the program from the code-cache and at some point be able to replace a function body with it's new compiled version; this can be done by replacing the entry in the function code with a trampoline to It's new version so that future calls to it will call the new version code. Does the CompileOnDemandLayer executes the program from a code cache and holds pointers to the code of the functions it executes? I am compiling for Power machine. Is there a target specific pieces that I should implement for making Orc work on Power?

There is code in lib/ExecutionEngine/Orc/OrcTargetSupport.cpp that is currently only implemented for x86_64 that is necessary in order to make the lazy compilation work (triggering compilation only when a function is first called, etc.). I'll let someone else comment on the rest of the details...

-Hal

Thanks again, Revital

From: Lang Hames <lhames at gmail.com> To: Revital1 Eres/Haifa/IBM at IBMIL Cc: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu> Date: 20/07/2015 08:41 PM Subject: Re: [LLVMdev] Help with using LLVM to re-compile hot functions at run-time Hi Revital, The CompileOnDemand layer is used by the lazy bitcode JIT in the lli tool. You can find the code in llvm/tools/lli/OrcLazyJIT.* . Cheers, Lang. On Mon, Jul 20, 2015 at 2:32 AM, Revital1 Eres < ERES at il.ibm.com > wrote: Hello Lang , Thanks for your answer. I am now looking for an example of the usage of CompileOnDemandLayer. Is there an example available for that (could not find one in llvm/examples)? Thanks, Revital From: Lang Hames < lhames at gmail.com > To: Revital1 Eres/Haifa/IBM at IBMIL Cc: LLVM Developers Mailing List < llvmdev at cs.uiuc.edu > Date: 10/07/2015 12:10 AM Subject: Re: [LLVMdev] Help with using LLVM to re-compile hot functions at run-time Hi Revital, LLVM does have an IR interpreter, but I don't think it's maintained well (or possibly at all). The interpreter is also not designed to interact with the LLVM JITs. We generally encourage people to just JIT LLVM IR, rather than interpreting it. For the use-case you have described, you could JIT IR with no optimizations to begin with, then re-JIT hot functions at a higher level. The Orc JIT APIs (LLVM's newer JIT APIs) were written with this kind of use-case in mind, and are probably a better fit for this than MCJIT. There is no built-in hot-function detection or recompilation yet, but I think this would be fairly easy to write in terms of Orc's callback API. Cheers, Lang. On Thu, Jul 9, 2015 at 4:19 AM, Revital1 Eres < ERES at il.ibm.com > wrote: Hello, I am new to LLVM and a I appreciate your help with the following: I want to run the LLVM IR through virtual machine (LLVM interpreter?) and jit compile the hot functions (using MCJIT). This task will require amongst other identifying the hot functions and having a code cache that should be patched with the native code of the functions after they are jitted. I've read so far about MCJIT and lli however I have not seen that the LLVM interpreter can be used as a VM the way I was looking for; meaning execute the code one instruction at a time; have a profiling mode to identify hot functions and call jit to compile the hot functions. I appreciate any advice/starting points for this project. Thanks, Revital


LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory



More information about the llvm-dev mailing list