<div>Hello!</div><div>I created a new llvm module (<strong>A</strong>) - to create a 'glue' code.</div><div>I want to call some functions from another module (<strong>B</strong>);</div><div>I load module <strong>B</strong> withing the same LLVMContext, and create a function declaration in module A via:</div><div>  Â  auto functionInAnotherModule = ModuleB.getFunction(callableName);</div><div>  Â  auto functionType = functionInAnotherModule->getFunctionType();</div><div>  Â  auto localFunction = llvm::Function::Create(functionType, llvm::GlobalValue::LinkageTypes::ExternalWeakLinkage, callableName, &ModuleA);</div><div> </div><div>  Â  Function seems to be copied, together with complex types its using:</div><div>  Â  ; ModuleID = 'JitModule'</div><div>  Â  source_filename = "JitModule"  Â </div><div>  Â  %struct._EN12RecordStreamE = type { %class.RecordStream }</div><div>  Â  declare extern_weak void @_EN12RecordStream4InitEPTsN18_EN12RecordStreamEEPvv(%struct._EN12RecordStreamE*, i8*)</div><div>  Â </div><div>  Â  ... But later I'm not able to link in ModuleB to ModuleA using linker.linkInModule(std::move(ModuleB));</div><div>  Â  llvm says: Assertion failed: !(Pair.first != Ty && Pair.second == Ty) && "mapping to a source type",...</div><div> </div><div>  Â  Could someone point me what conceptually I did wrong?</div>