| 561 | } |
| 562 | |
| 563 | bool LLVMToBackendTranslator::linkBitcodeString(llvm::Module &M, const std::string &Bitcode, |
| 564 | const std::string &ForcedTriple, |
| 565 | const std::string &ForcedDataLayout, |
| 566 | bool LinkOnlyNeeded) { |
| 567 | std::unique_ptr<llvm::Module> OtherModule; |
| 568 | auto err = loadModuleFromString(Bitcode, M.getContext(), OtherModule); |
| 569 | |
| 570 | if (err) { |
| 571 | this->registerError("LLVMToBackend: Could not load LLVM module"); |
| 572 | llvm::handleAllErrors(std::move(err), [&](llvm::ErrorInfoBase &EIB) { |
| 573 | this->registerError(EIB.message()); |
| 574 | }); |
| 575 | return false; |
| 576 | } |
| 577 | |
| 578 | llvm::Linker::Flags F = llvm::Linker::None; |
| 579 | if(LinkOnlyNeeded) |
| 580 | F = llvm::Linker::LinkOnlyNeeded; |
| 581 | |
| 582 | if(!linkBitcode(M, std::move(OtherModule), ForcedTriple, ForcedDataLayout, F)) { |
| 583 | this->registerError("LLVMToBackend: Linking module failed"); |
| 584 | return false; |
| 585 | } |
| 586 | |
| 587 | return true; |
| 588 | } |
| 589 | |
| 590 | bool LLVMToBackendTranslator::linkBitcodeFile(llvm::Module &M, const std::string &BitcodeFile, |
| 591 | const std::string &ForcedTriple, |
no test coverage detected