| 342 | } |
| 343 | |
| 344 | Status LlvmCodeGen::LoadModuleFromMemory(unique_ptr<llvm::MemoryBuffer> module_ir_buf, |
| 345 | const string& module_name, unique_ptr<llvm::Module>* module) { |
| 346 | DCHECK(!module_name.empty()); |
| 347 | COUNTER_ADD(module_bitcode_size_, module_ir_buf->getMemBufferRef().getBufferSize()); |
| 348 | llvm::Expected<unique_ptr<llvm::Module>> tmp_module = |
| 349 | getOwningLazyBitcodeModule(move(module_ir_buf), context()); |
| 350 | if (llvm::Error err = tmp_module.takeError()) { |
| 351 | string err_string; |
| 352 | llvm::handleAllErrors( |
| 353 | move(err), [&](llvm::ErrorInfoBase& eib) { err_string = eib.message(); }); |
| 354 | return Status(err_string); |
| 355 | } |
| 356 | |
| 357 | *module = move(tmp_module.get()); |
| 358 | |
| 359 | // We never run global constructors or destructors so let's strip them out for all |
| 360 | // modules when we load them. |
| 361 | StripGlobalCtorsDtors((*module).get()); |
| 362 | |
| 363 | (*module)->setModuleIdentifier(module_name); |
| 364 | return Status::OK(); |
| 365 | } |
| 366 | |
| 367 | // TODO: Create separate counters/timers (file size, load time) for each module linked |
| 368 | Status LlvmCodeGen::LinkModuleFromLocalFs(const string& file) { |