[LLVMdev] Unit testing with random input using JIT

Reid Kleckner reid.kleckner at gmail.com
Tue Jan 11 14:40:06 PST 2011


On Tue, Jan 11, 2011 at 1:41 PM, Vu Le <vmle at ucdavis.edu> wrote:
> Hi,
> I want to implement a tool that probes a function with several input and
> records all the return output.
> The function might have more than 1 return value (by reference parameters).
>
> Does ExecutionEngine::runFunction() support function call with complex
> argument type?
> If not, I guess that I have to create a wrapper function, prepare all the
> data, and call the original function.
> Am I on the right track?

For functions with complicated parameters and return values,
runFunction will generate a wrapper function that calls the function
with the right arguments.  This is fairly expensive and leaks memory
if called more than once for the same function.  If the type of the
function is known, you can just use getPointerToFunction, cast that,
and call it from C.

If it's not known but you want to call it many times with different
arguments, you could generate a wrapper function responsible for
unpacking your own datastructure describing the arguments and calling
the function you are testing with those arguments.  Seems like you are
on the right track there.

Reid



More information about the llvm-dev mailing list