| 602 | } |
| 603 | |
| 604 | Result<void*> Engine::CompiledFunction(const std::string& function) { |
| 605 | DCHECK(module_finalized_) |
| 606 | << "module must be finalized before getting compiled function"; |
| 607 | auto sym = lljit_->lookup(function); |
| 608 | if (!sym) { |
| 609 | return Status::CodeGenError("Failed to look up function: " + function + |
| 610 | " error: " + llvm::toString(sym.takeError())); |
| 611 | } |
| 612 | // Since LLVM 15, `LLJIT::lookup` returns ExecutorAddrs rather than |
| 613 | // JITEvaluatedSymbols |
| 614 | #if LLVM_VERSION_MAJOR >= 15 |
| 615 | auto fn_addr = sym->getValue(); |
| 616 | #else |
| 617 | auto fn_addr = sym->getAddress(); |
| 618 | #endif |
| 619 | auto fn_ptr = reinterpret_cast<void*>(fn_addr); |
| 620 | if (fn_ptr == nullptr) { |
| 621 | return Status::CodeGenError("Failed to get address for function: " + function); |
| 622 | } |
| 623 | return fn_ptr; |
| 624 | } |
| 625 | |
| 626 | void Engine::AddGlobalMappingForFunc(const std::string& name, llvm::Type* ret_type, |
| 627 | const std::vector<llvm::Type*>& args, void* func) { |
nothing calls this directly
no test coverage detected