| 704 | } |
| 705 | |
| 706 | Status LlvmCodeGen::MaterializeFunction(llvm::Function* fn) { |
| 707 | DCHECK(!is_compiled_); |
| 708 | if (fn->isIntrinsic() || !fn->isMaterializable()) return Status::OK(); |
| 709 | |
| 710 | llvm::Error err = module_->materialize(fn); |
| 711 | if (UNLIKELY(err)) { |
| 712 | string err_string; |
| 713 | llvm::handleAllErrors( |
| 714 | move(err), [&](llvm::ErrorInfoBase& eib) { err_string = eib.message(); }); |
| 715 | return Status(Substitute("Failed to materialize $0: $1", |
| 716 | fn->getName().str(), err_string)); |
| 717 | } |
| 718 | |
| 719 | // Materialized functions are marked as not materializable by LLVM. |
| 720 | DCHECK(!fn->isMaterializable()); |
| 721 | SetCPUAttrs(fn); |
| 722 | const unordered_set<string>* callees = shared_call_graph_.GetCallees(fn->getName()); |
| 723 | if (callees != nullptr) { |
| 724 | for (const string& callee : *callees) { |
| 725 | llvm::Function* callee_fn = module_->getFunction(callee); |
| 726 | DCHECK(callee_fn != nullptr); |
| 727 | RETURN_IF_ERROR(MaterializeFunction(callee_fn)); |
| 728 | } |
| 729 | } |
| 730 | return Status::OK(); |
| 731 | } |
| 732 | |
| 733 | llvm::Function* LlvmCodeGen::GetFunction(const string& symbol, bool clone) { |
| 734 | llvm::Function* fn = module_->getFunction(symbol.c_str()); |
no test coverage detected