MCPcopy Create free account
hub / github.com/apache/impala / LinkModuleFromLocalFs

Method LinkModuleFromLocalFs

be/src/codegen/llvm-codegen.cc:368–398  ·  view source on GitHub ↗

TODO: Create separate counters/timers (file size, load time) for each module linked

Source from the content-addressed store, hash-verified

366
367// TODO: Create separate counters/timers (file size, load time) for each module linked
368Status LlvmCodeGen::LinkModuleFromLocalFs(const string& file) {
369 unique_ptr<llvm::Module> new_module;
370 RETURN_IF_ERROR(LoadModuleFromFile(file, &new_module));
371
372 // The module data layout must match the one selected by the execution engine.
373 new_module->setDataLayout(execution_engine()->getDataLayout());
374
375 // Parse all functions' names from the new module and find those which also exist in
376 // the main module. They are declarations in the new module or duplicated definitions
377 // of the same function in both modules. For the latter case, it's unclear which one
378 // the linker will choose. Materialize these functions in the main module in case they
379 // are chosen by the linker or referenced by functions in the new module. Note that
380 // linkModules() will materialize functions defined only in the new module.
381 for (llvm::Function& fn : new_module->functions()) {
382 const string& fn_name = fn.getName();
383 if (shared_call_graph_.GetCallees(fn_name) != nullptr) {
384 llvm::Function* local_fn = module_->getFunction(fn_name);
385 RETURN_IF_ERROR(MaterializeFunction(local_fn));
386 }
387 }
388
389 bool error = llvm::Linker::linkModules(*module_, move(new_module));
390 string diagnostic_err = diagnostic_handler_.GetErrorString();
391 if (error) {
392 stringstream ss;
393 ss << "Problem linking " << file << " to main module.";
394 if (!diagnostic_err.empty()) ss << " " << diagnostic_err;
395 return Status(ss.str());
396 }
397 return Status::OK();
398}
399
400Status LlvmCodeGen::LinkModuleFromHdfs(const string& hdfs_location, const time_t mtime) {
401 if (linked_modules_.find(hdfs_location) != linked_modules_.end()) return Status::OK();

Callers

nothing calls this directly

Calls 9

moveFunction · 0.85
OKFunction · 0.85
GetCalleesMethod · 0.80
GetErrorStringMethod · 0.80
getNameMethod · 0.65
getFunctionMethod · 0.65
StatusClass · 0.50
emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected