Some traps of LLVM Mcjit
Self-handling Baidu space
Recently, the old version of LLVM JIT transformation to Mcjit, encountered some problems
The first is how to start Mcjit,
Original call Initializenativetarget (); Place, add
Initializenativetargetasmprinter ();
Initializenativetargetasmparser ();
Otherwise it will error: Target does not support MC emission!?
When creating execution engine
Enginebuilder EB (M);
EB. Setusemcjit (true);
(If you are on a Windows system) find the Llvm::sys::getprocesstriple function in the LLVM source code,
The last sentence should read
#ifdef LLVM_ON_WIN32
return Pt.str () + "-elf";
#else
return Pt.str ();
#endif
Otherwise error: Incompatible object format!
You must then Theexecutionengine->finalizeobject () after you join the module. Otherwise, address redirection doesn't work.
In the end, Mcjit's execution engine, whether you have addglobalmapping or not, will not find the global symbol error.
You need to specify a memorymanager when you create the engine
Eb.setmcjitmemorymanager (New Helpingmemorymanager (this));
Helpingmemorymanager class please refer to
Https://github.com/llvm-mirror/llvm/blob/master/examples/Kaleidoscope/MCJIT/cached/toy.cpp
The official blog about the use of Mcjit:
? http://project1439.rssing.com/chan-6400099/all_p2.html
The Helpingmemorymanager class is equivalent to providing a link to a symbolic and absolute address, instead of the previous addglobalmapping
It is important to note that in the Helpingmemorymanager code that is given by the authorities, the getpointertonamedfunction is required to be overloaded. Probably a version of the problem, I used the LLVM 3.4.2 need to overload is getsymboladdress, the source code has comments:
This function is deprecated-memory managers to being used with
Mcjit or Runtimedyld. Use Getsymboladdress instead.
2015-03-05
Some traps of LLVM Mcjit