thank you for your quick responce, finally i got to my PC at home.
Attached are three files: "valery.cpp" which contains your original, "reid.cpp" which contains corrections to most of the FIXME items and "diffs" which shows the differences between them. The differences should be instructive on what to do. You were really, really close .. just a few details changing. The code in "reid.cpp" compiles but I haven't tested it. I'll leave that to you.
hm, were the linkage requisites the problem by your side too?..
this is the magic string:
g++ -L/usr/local/lib -L/usr/local/lib -o reid reid.o /usr/local/lib/lli-interpreter.o /usr/local/lib/lli-jit.o /usr/local/lib/codegen.o /usr/local/lib/executionengine.o /usr/local/lib/x86.o /usr/local/lib/selectiondag.o /usr/local/lib/scalaropts.o -lanalysis -ltransformutils /usr/local/lib/bcreader.o /usr/local/lib/vmcore.o /usr/local/lib/support.o -ltarget -export-dynamic -ldl
(don't ask me why some modules are left as .o)
Well. Compiled. Tested. Infinite loop in:
GenericValue gv = EE->runFunction(FooF, noargs);
you were really, really close, Reid, just a one mistake:
< CallInst * Add1CallRes = new CallInst(FooF, Params, "foo", BB);
> CallInst * Add1CallRes = new CallInst(Add1F, Params, "add1", BB);
There is only one remaining item that I don't know how to do. After ExecutionEngine::runFunction, you want to extract the result int value from the function. The runFunction method returns a GenericValue but I don't see an obvious way to get an actual value from this class.
Misha: can you help out with "GenericValue" ?
I got advice from Chris, thx.
AND NOW IT WORKSSSSSS!!!
HowToUseJIT.cpp is attached as finall version.
...well could anyone tell me whether JIT was really invoked in this code?
What kind of optimization were applied by default (if any)?
oh, and great thanks to Reid of course!
HowToUseJIT.cpp (4.43 KB)