MCPcopy Create free account
hub / github.com/apache/arrow / FinalizeModule

Method FinalizeModule

cpp/src/gandiva/engine.cc:542–576  ·  view source on GitHub ↗

Optimise and compile the module.

Source from the content-addressed store, hash-verified

540
541// Optimise and compile the module.
542Status Engine::FinalizeModule() {
543 if (!cached_) {
544 ARROW_RETURN_NOT_OK(RemoveUnusedFunctions());
545
546 if (optimize_) {
547 auto target_analysis = target_machine_->getTargetIRAnalysis();
548// misc passes to allow for inlining, vectorization, ..
549#if LLVM_VERSION_MAJOR >= 14
550 OptimizeModuleWithNewPassManager(*module_, std::move(target_analysis));
551#else
552 OptimizeModuleWithLegacyPassManager(*module_, std::move(target_analysis));
553#endif
554 }
555
556 ARROW_RETURN_IF(llvm::verifyModule(*module_, &llvm::errs()),
557 Status::CodeGenError("Module verification failed after optimizer"));
558
559 // print the module IR and save it for later use if IR dumping is needed
560 // since the module will be moved to construct LLJIT instance, and it is not
561 // available after LLJIT instance is constructed
562 if (conf_->dump_ir()) {
563 module_ir_ = DumpModuleIR(*module_);
564 }
565
566 llvm::orc::ThreadSafeModule tsm(std::move(module_), std::move(context_));
567 auto error = lljit_->addIRModule(std::move(tsm));
568 if (error) {
569 return Status::CodeGenError("Failed to add IR module to LLJIT: ",
570 llvm::toString(std::move(error)));
571 }
572 }
573 module_finalized_ = true;
574
575 return Status::OK();
576}
577
578Result<void*> Engine::CompiledFunction(const std::string& function) {
579 DCHECK(module_finalized_)

Callers 3

TEST_FFunction · 0.80
BuildMethod · 0.80
TEST_FFunction · 0.80

Calls 5

CodeGenErrorFunction · 0.85
DumpModuleIRFunction · 0.85
OKFunction · 0.50

Tested by 2

TEST_FFunction · 0.64
TEST_FFunction · 0.64