Sharing and re-using Codegen'd LLVM IR


Thanks for all the help provided so in getting upto speed on using LLVM libraries for codegen. I am reading the Getting started with LLVM libraries book and it has been helpful as well.

However, I am not able to find an answer to the following. I would appreicate help on this-

  1. What is the performance of loading pre-generated IR code and attaching it to an existing LLVM module?

  2. Reference manual and book recommend that no 2 threads should share an LLVMContext object. If this recommendation is followed, how do share the code generated by one thread with another thread? Do I have to dump IR to a file and load that IR into another module belonging to another LLVMContext?

  3. If I cross-link 2 LLVM Modules at Compile/JIT does the code from one module get inlined during the optimization phases? If I want to guarantee inlining how should link modules?