Dear LLVMers, Can the LLVM JIT, at run-time, take a function for which it has already generated native code, re-optimize it at the LLVM level, and then re-generate its native code, replacing calls of the old function with calls to the new function? I seem to recall that it could, but I need to make sure. Thanks in advance. -- John T.
On Oct 27, 2009, at 9:18 AM, John Criswell wrote:> Dear LLVMers, > > Can the LLVM JIT, at run-time, take a function for which it has > already > generated native code, re-optimize it at the LLVM level, and then > re-generate its native code, replacing calls of the old function with > calls to the new function? > > I seem to recall that it could, but I need to make sure.Sure, ExecutionEngine::recompileAndRelinkFunction is your API. -Chris
On Tue, Oct 27, 2009 at 9:24 AM, Chris Lattner <clattner at apple.com> wrote:> > On Oct 27, 2009, at 9:18 AM, John Criswell wrote: > >> Dear LLVMers, >> >> Can the LLVM JIT, at run-time, take a function for which it has >> already >> generated native code, re-optimize it at the LLVM level, and then >> re-generate its native code, replacing calls of the old function with >> calls to the new function? >> >> I seem to recall that it could, but I need to make sure. > > Sure, ExecutionEngine::recompileAndRelinkFunction is your API.But since that overwrites the beginning of the old version of the function with a jump to the new version, be sure no threads are inside there when you call it.