Revital1 Eres
2015-Jul-20 09:32 UTC
[LLVMdev] Help with using LLVM to re-compile hot functions at run-time
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150720/f914e75f/attachment.html>
Lang Hames
2015-Jul-20 17:41 UTC
[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* > <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* <LLVMdev at cs.uiuc.edu> > *http://llvm.cs.uiuc.edu* <http://llvm.cs.uiuc.edu/> > *http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev* > <http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev> > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150720/ab3e4be5/attachment.html>
Revital1 Eres
2015-Jul-27 06:17 UTC
[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? 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150727/39ce254f/attachment.html>
Maybe Matching Threads
- [LLVMdev] Help with using LLVM to re-compile hot functions at run-time
- [LLVMdev] Help with using LLVM to re-compile hot functions at run-time
- [LLVMdev] Help with using LLVM to re-compile hot functions at run-time
- [LLVMdev] Help with using LLVM to re-compile hot functions at run-time
- [PATCH] vhost: Add polling mode