[LLVMdev] JIT'ing 2 functions with inter-dependencies

Michael Muller mmuller at enduden.com
Tue Oct 29 07:37:22 PDT 2013


Frank Winter wrote:
> I am having problems JIT'ing 2 functions where one of them calls the 
> other. (I am using the old JIT interface).
> 
> Here is the setup:
> 
> define void @func1() {
> entrypoint:
>    call void @func2(void)
>    ret void
> }
> 
> define void @func2(void) {
> entrypoint:
>    ret void
> }
> 
> (I omit the arguments and function bodies for simplicity.)
> 
> It's 'func1' that would be called from host code, 'func2' gets only 
> called from 'func1'.
> 
> The time I have finished building 'func1' (and not yet 'func2') and and 
> ask the execution engine for the function pointer the call to 'func2' is 
> undefined. Thus, even when calling 'func1' after having finshed building 
> 'func2' this results in undef behavior.
> 
> When I instead postpone JIT'ing 'func1' and finish building 'func2' 
> first and then ask for the pointer to 'func1' the function pointer 
> returned is somehow corrupt. I guess this is because I already switched 

If both functions are correctly defined in the same module, you should be able
to get the pointer to either of them.

> to building the function 'func2'?! I cannot even verify 'func1' 
> correctly. I get a strange assertion. So, I guess I have to JIT the 

The strange assertion suggests that you have another problem, here :-)

> function right away after building it .. If this is true, it seems I am 
> out of options here.
> 
> What is the correct order to do things here? Is it even possible with 
> the old JIT interface or do I need the new interface?
> 
> Frank
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 


=============================================================================
michaelMuller = mmuller at enduden.com | http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
We are explorers in the further reaches of experience: demons to some, angels
to others.  - "Pinhead" from "Hellraiser"
=============================================================================



More information about the llvm-dev mailing list