Some traps of LLVM Mcjit

Source: Internet
Author: User

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

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.