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

Frank Winter fwinter at jlab.org
Tue Oct 29 06:50:44 PDT 2013


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 
to building the function 'func2'?! I cannot even verify 'func1' 
correctly. I get a strange assertion. So, I guess I have to JIT the 
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




More information about the llvm-dev mailing list