[llvm] r191030 - llvm-c: Add LLVMGetPointerToFunction

Anders Waldenborg anders at 0x63.nu
Thu Sep 19 23:06:43 PDT 2013


I'll revert it.

Thanks

On Thu, Sep 19, 2013 at 01:57:46PM -0700, Jim Grosbach wrote:
> 
> On Sep 19, 2013, at 1:56 PM, Eric Christopher <echristo at gmail.com> wrote:
> 
> > On Thu, Sep 19, 2013 at 1:54 PM, Filip Pizlo <fpizlo at apple.com> wrote:
> >> 
> >> 
> >> On Sep 19, 2013, at 1:47 PM, Eric Christopher <echristo at gmail.com> wrote:
> >> 
> >> Very curious about RunFunction then?
> >> 
> >> 
> >> What about it? ;-)
> >> 
> 
> I’m in favor of deprecating that interface, personally.
> 
> >> 
> >> When I did the JIT aspect I used getPointerToFunction, what are you
> >> guys using at the moment in webkit-land?
> >> 
> >> 
> >> LLVMGetPointerToGlobal().  We create an MCJIT, give it a module and then
> >> call LLVMGetPointerToGlobal(), passing it a Value that is the function we
> >> want.
> >> 
> >> There's other stuff going on, as well - like having a custom memory manager
> >> so that WebKit can control where/how all sections get allocated by Dyld.
> >> But the basic workflow if you want to launch a local JIT to generate some
> >> code is (1) create the JIT with the module you want to compile, (2) get
> >> pointers to your functions with LLVMGetPointerToGlobal().  The latter also
> >> forces a compile.
> >> 
> >> It's true you can call RunFunction but this is silly for many JIT clients.
> >> You will want to call the generated code directly, either from C or from
> >> other JITed code that you have generated. We don't use RunFunction, and
> >> don't ever intend to.
> >> 
> > 
> > Didn't figure so :)
> > 
> > That said, I think Jim is correct about the way we'd like that
> > function to look externally or how it should work.
> > 
> > -eric
> > 
> >> -Filip
> >> 
> >> 
> >> 
> >> -eric
> >> 
> >> On Thu, Sep 19, 2013 at 1:46 PM, Filip Pizlo <fpizlo at apple.com> wrote:
> >> 
> >> How is that different from LLVMGetPointerToGlobal()?
> >> 
> >> And I agree that this should work.  It's great that the JIT could be used
> >> for remote execution, but some clients will never use the JIT in that
> >> fashion.  They will just want a void*.
> >> 
> >> -Filip
> >> 
> >> 
> >> On Sep 19, 2013, at 1:36 PM, Eric Christopher <echristo at gmail.com> wrote:
> >> 
> >> Hrm. That's a good point and one I hadn't thought about... what's the
> >> best way forward here? There's definitely a useful need in getting a
> >> void * to a function out of the JIT from the C level.
> >> 
> >> -eric
> >> 
> >> On Thu, Sep 19, 2013 at 1:30 PM, Jim Grosbach <grosbach at apple.com> wrote:
> >> 
> >> This isn’t going to work when the execution target isn’t local. The pointer
> >> to the function is in the executing process address space and this returns a
> >> pointer in the compiler’s address space.
> >> 
> >> That’s a fundamental problem with the old JIT, and is semi-baked into the
> >> ExecutionEngine API, unfortunately, and cleaning that up is going to be
> >> painful. We shouldn’t, however, make the problem worse.
> >> 
> >> -Jim
> >> 
> >> On Sep 19, 2013, at 12:55 PM, Anders Waldenborg <anders at 0x63.nu> wrote:
> >> 
> >> Author: andersg
> >> Date: Thu Sep 19 14:55:06 2013
> >> New Revision: 191030
> >> 
> >> URL: http://llvm.org/viewvc/llvm-project?rev=191030&view=rev
> >> Log:
> >> llvm-c: Add LLVMGetPointerToFunction
> >> 
> >> Differential Revision: http://llvm-reviews.chandlerc.com/D1715
> >> 
> >> 
> >> Modified:
> >> llvm/trunk/include/llvm-c/ExecutionEngine.h
> >> llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp
> >> 
> >> Modified: llvm/trunk/include/llvm-c/ExecutionEngine.h
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ExecutionEngine.h?rev=191030&r1=191029&r2=191030&view=diff
> >> ==============================================================================
> >> --- llvm/trunk/include/llvm-c/ExecutionEngine.h (original)
> >> +++ llvm/trunk/include/llvm-c/ExecutionEngine.h Thu Sep 19 14:55:06 2013
> >> @@ -141,6 +141,8 @@ LLVMGenericValueRef LLVMRunFunction(LLVM
> >>                                  unsigned NumArgs,
> >>                                  LLVMGenericValueRef *Args);
> >> 
> >> +void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
> >> +
> >> void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef
> >> F);
> >> 
> >> void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M);
> >> 
> >> Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=191030&r1=191029&r2=191030&view=diff
> >> ==============================================================================
> >> --- llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp (original)
> >> +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Thu Sep 19
> >> 14:55:06 2013
> >> @@ -276,6 +276,10 @@ LLVMGenericValueRef LLVMRunFunction(LLVM
> >> return wrap(Result);
> >> }
> >> 
> >> +void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F) {
> >> +  return unwrap(EE)->getPointerToFunction(unwrap<Function>(F));
> >> +}
> >> +
> >> void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef
> >> F) {
> >> unwrap(EE)->freeMachineCodeForFunction(unwrap<Function>(F));
> >> }
> >> 
> >> 
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >> 
> >> 
> >> 
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >> 
> >> 
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-- 



More information about the llvm-commits mailing list