PDA

View Full Version : Qt + LLVM's JIT



agarny
23rd November 2011, 15:40
Hi,

I was wondering whether anyone had tried to use LLVM's JIT in their program and, if so, how they went about it?

I have built a shared version of LLVM which I am now able to test in my Qt Qt application. It all works fine on Windows, Linux and Mac OS X, except that whenever I exit my Qt application on Windows (everything is fine on Linux and Mac OS X), I get a message that reads that "this application has requested the Runtime to terminate it in an unusual way".

Just in case, 'my' current LLVM code is a shameless copy/paste of the HowToUseJIT example (in the examples folder). Also, if I comment out line 116 (and 119) of examples/HowToUseJIT/HowToUseJIT.cpp (i.e. GenericValue gv = EE->runFunction(FooF, noargs);), then I don't get that message when I exit my application...

I know it might be a bit far-fetched, but would anyone have any idea of what might be going wrong here?

Cheers, Alan.

PS: note that I am NOT, here, interested in building my Qt application with LLVM/Clang. I want to use LLVM's JIT, nothing more nothing less (so to speak!).

ChrisW67
23rd November 2011, 23:25
If commenting that line out removes the error the the error message is likely the result of EE being an invalid or null pointer... but then we have no idea what your source is doing or exactly which version of "HowToUseJIT.cpp" you are using. You are probably not seeing exactly the same problem on Linux/OSX because they don't pop up a nice dialog to tell you.

agarny
24th November 2011, 06:22
Sorry, I should have been more explicit indeed. You can find my code here (https://github.com/opencor/opencor/blob/master/src/plugins/simulation/CoreSimulation/src/coresimulationplugin.cpp) and the line causing problem is line #154. However, I would expect executionEngine (EE in the original code) to be valid, since I am able to execute the function and that it returns the correct value (and this on all three platforms). It's just that on Windows, I also get that window message. Note that I only get that window message when running my application outside Qt Creator (and whether it's a debug or release version of my application). If I run it from within Qt Creator (debug version of my application), then everything is fine.

I therefore get the feeling that there might still be a problem with executionEngine, but which only shows up at destruction time and, as you said, the problem most certainly exists on Linux and Mac OS X. It's just that those systems don't display any 'nice' message.

agarny
24th November 2011, 12:45
For what it is worth, I have got it to work fine on Windows by commenting out line #67 ( i.e. llvm::InitializeNativeTarget(); ) in my source code (https://github.com/opencor/opencor/blob/master/src/plugins/simulation/CoreSimulation/src/coresimulationplugin.cpp). I find this particularly weird considering that one is expected to make that call...!?