[LLVMdev] Linking modules across contexts crashes

Yuri yuri at rawbw.com
Tue Jun 2 12:37:22 PDT 2015


On 06/01/2015 11:43, Duncan P. N. Exon Smith wrote:
> You can round-trip to bitcode, reading the module into the
> destination context.  The following pseudo-code gives the idea:
>
>      bool linkModuleFromDifferentContext(Module &D, const Module &S) {
>        SmallVector<char, 256> Buffer;
>        writeBitcodeToBuffer(S, Buffer);
>
>        std::unique_ptr<Module> M = readBitcodeFromBuffer(D.getContext());
>        return Linker::LinkModules(&D, M.get());
>      }

Duncan,

Thanks for this workaround, i works. However, going to binary and back 
causes the significant bump in the process user time (14s->16s), while 
the wall clock time still lower due to parallelization.

There should be the function llvm::MergeContexts, similar to 
llvm::Linker::LinkModules. It should merge contexts as containers, with 
an error when this isn't possible, without changing most of the objects 
at all. It should cause the source context to disappear.

Yuri



More information about the llvm-dev mailing list