[LLVMdev] Disjoint types after reading several modules
baldrick at free.fr
Thu Feb 2 04:51:15 PST 2012
On 02/02/12 13:30, Clemens Hammacher wrote:
> Hi Chris,
> thanks for your answer!
> On 2/2/12 1:15 AM, Chris Lattner wrote:
>> The linker has to solve the exact same problem (read multiple .bc files and
>> unify types across them). This is the impetus behind TypeMapTy in
>> lib/Linker/LinkModules.cpp. You'll probably need to do something like that.
> I already looked into that. The linker is using the GlobalValues of both modules
> to identify the types to unify.
> This leads to interesting effects in some cases, but I'll write another post
> about this.
> Nevertheless the TypeMapTy is a great piece of code, and we will definitely
> reuse it to remap duplicated types (and composed types) to unique ones (via
> mutateType(), recursively descending to all uses).
>> I have to ask: why are you writing these modules out as separate bc files?
> I knew that someone would ask that ;)
> We need to have separate modules during runtime. One of them contains the code
> that is actually JIT compiled and executed, and simultaneously different
> optimizations are concurrently (in individual threads) building up or
> restructuring new code in their individual "working modules". Eventually some
> code will get copied over to the main module to be executed, and that's why they
> need to use the same types.
what do you mean by "copied over to the main module"? If you want to add
additional IR to the main module then you should link it in using the linker.
More information about the llvm-dev