Llvm: c interface getPointerToFunction equivalent

LLVM offers a function to access the address of a JIT-compiled function getPointerToFunction(see, for example, http://llvm.org/docs/tutorial/LangImpl4.html#adding-a-jit-compiler ).

Since I prefer OCaml over C ++ for the codegen part, I am pretty much limited to the llvm C interface (which, in turn, is the base for the OCaml interface).

When I look at the code http://llvm.org/docs/tutorial/OCamlLangImpl4.html , all I see is that it run_functionseems to recompile the function every time it is called. This results in a slower 2000x code.

Is something like getPointerToFunctionaccessible for the C interface, or do I need to crash somehow?

If it is not available, my idea would be to create a second llvm function that gives a pointer to the compiled one. Is there any convenient way to do this, i.e. Get the address of the llvm function through the instructions?

+3
source share

All Articles