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

Method Init

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

Source from the content-addressed store, hash-verified

456}
457
458Status LlvmCodeGen::Init(unique_ptr<llvm::Module> module) {
459 DCHECK(module != nullptr);
460
461 llvm::CodeGenOpt::Level opt_level = llvm::CodeGenOpt::Aggressive;
462#ifndef NDEBUG
463 // For debug builds, don't generate JIT compiled optimized assembly.
464 // This takes a non-neglible amount of time (~.5 ms per function) and
465 // blows up the fe tests (which take ~10-20 ms each).
466 opt_level = llvm::CodeGenOpt::None;
467#endif
468 module_ = module.get();
469 llvm::EngineBuilder builder(move(module));
470 builder.setEngineKind(llvm::EngineKind::JIT);
471 builder.setOptLevel(opt_level);
472 unique_ptr<ImpalaMCJITMemoryManager> memory_manager(new ImpalaMCJITMemoryManager);
473 memory_manager_ = memory_manager.get();
474 builder.setMCJITMemoryManager(move(memory_manager));
475 builder.setMCPU(cpu_name_);
476 builder.setMAttrs(cpu_attrs_);
477 builder.setErrorStr(&error_string_);
478
479 execution_engine_ = unique_ptr<llvm::ExecutionEngine>(builder.create());
480 if (execution_engine_ == nullptr) {
481 module_ = nullptr; // module_ was owned by builder.
482 stringstream ss;
483 ss << "Could not create ExecutionEngine: " << error_string_;
484 return Status(ss.str());
485 }
486
487 // The module data layout must match the one selected by the execution engine.
488 module_->setDataLayout(execution_engine_->getDataLayout());
489
490 void_type_ = llvm::Type::getVoidTy(context());
491 ptr_type_ = llvm::PointerType::get(i8_type(), 0);
492 true_value_ = llvm::ConstantInt::get(context(), llvm::APInt(1, true, true));
493 false_value_ = llvm::ConstantInt::get(context(), llvm::APInt(1, false, true));
494
495 symbol_emitter_ = SetupSymbolEmitter(execution_engine_.get());
496 engine_cache_ = make_shared<CodeGenObjectCache>();
497
498 RETURN_IF_ERROR(LoadIntrinsics());
499
500 return Status::OK();
501}
502
503unique_ptr<CodegenSymbolEmitter> LlvmCodeGen::SetupSymbolEmitter(
504 llvm::ExecutionEngine* execution_engine) {

Callers 12

SetUpMethod · 0.45
TestBasicFunctionMethod · 0.45
TestAtCapacityMethod · 0.45
TestSkipCacheMethod · 0.45
TEST_FFunction · 0.45
InitializeLlvmMethod · 0.45
CreateFromFileMethod · 0.45
CreateFromMemoryMethod · 0.45
SetUpMethod · 0.45
LifetimeTestMethod · 0.45
SetUpMethod · 0.45
EnableCodegenCacheMethod · 0.45

Calls 6

moveFunction · 0.85
OKFunction · 0.85
getMethod · 0.65
createMethod · 0.65
StatusClass · 0.50
strMethod · 0.45

Tested by 9

SetUpMethod · 0.36
TestBasicFunctionMethod · 0.36
TestAtCapacityMethod · 0.36
TestSkipCacheMethod · 0.36
TEST_FFunction · 0.36
SetUpMethod · 0.36
LifetimeTestMethod · 0.36
SetUpMethod · 0.36
EnableCodegenCacheMethod · 0.36