@@ -341,14 +341,24 @@ llvm::Value* CodeGenCPU::CreateCallExtern(const CallNode* op) {
341341 gv_func_map_[op->name ] = InitContextPtr (ftype->getPointerTo (), " __" + op->name );
342342 it = gv_func_map_.find (op->name );
343343 }
344- return builder_->CreateCall (GetContextPtr (it->second ), arg_values);
344+ #if TVM_LLVM_VERSION >= 90
345+ auto ext_callee = llvm::FunctionCallee (ftype, GetContextPtr (it->second ));
346+ #else
347+ auto ext_callee = GetContextPtr (it->second );
348+ #endif
349+ return builder_->CreateCall (ext_callee, arg_values);
345350 } else {
346351 llvm::Function* f = module_->getFunction (op->name );
347352 if (f == nullptr ) {
348353 f = llvm::Function::Create (
349354 ftype, llvm::Function::ExternalLinkage, op->name , module_.get ());
350355 }
351- return builder_->CreateCall (f, arg_values);
356+ #if TVM_LLVM_VERSION >= 90
357+ auto ext_callee = llvm::FunctionCallee (f);
358+ #else
359+ auto ext_callee = f;
360+ #endif
361+ return builder_->CreateCall (ext_callee, arg_values);
352362 }
353363}
354364
@@ -524,9 +534,15 @@ void CodeGenCPU::CreateParallelLaunch(const Stmt& body, int num_task) {
524534 Array<Var> vfields = tir::UndefinedVars (body, {});
525535 uint64_t nbytes;
526536 llvm::Value* cdata = PackClosureData (vfields, &nbytes);
537+ #if TVM_LLVM_VERSION >= 90
538+ auto launch_callee = llvm::FunctionCallee (
539+ ftype_tvm_parallel_launch_, RuntimeTVMParallelLaunch ());
540+ #else
541+ auto launch_callee = RuntimeTVMParallelLaunch ();
542+ #endif
527543 BasicBlock* par_launch_end = CheckCallSuccess (
528544 builder_->CreateCall (
529- RuntimeTVMParallelLaunch () ,
545+ launch_callee ,
530546 {f, builder_->CreatePointerCast (cdata, t_void_p_), ConstInt32 (num_task)}));
531547 // Setup the closure function.
532548 BasicBlock *lambda_entry = BasicBlock::Create (*ctx_, " entry" , f);
@@ -670,8 +686,14 @@ llvm::Value* CodeGenCPU::GetPackedFuncHandle(const std::string& fname) {
670686 ctx->setMetadata (
671687 " tbaa" ,
672688 md_builder_->createTBAAStructTagNode (md_tbaa_ctx_ptr_, md_tbaa_ctx_ptr_, 0 ));
689+ #if TVM_LLVM_VERSION >= 90
690+ auto env_callee = llvm::FunctionCallee (
691+ ftype_tvm_get_func_from_env_, RuntimeTVMGetFuncFromEnv ());
692+ #else
693+ auto env_callee = RuntimeTVMGetFuncFromEnv ();
694+ #endif
673695 llvm::Value* retcode = builder_->CreateCall (
674- RuntimeTVMGetFuncFromEnv () , {ctx, GetConstString (fname), out});
696+ env_callee , {ctx, GetConstString (fname), out});
675697 init_block = CheckCallSuccess (retcode);
676698#if TVM_LLVM_VERSION >= 110
677699 llvm::Value* loaded_handle = builder_->CreateAlignedLoad (out, llvm::Align (align));
@@ -710,9 +732,14 @@ CodeGenCPU::MakeCallPacked(const Array<PrimExpr> &args, llvm::Value **rvalue,
710732 builder_->CreatePointerCast (stack_value, t_tvm_value_->getPointerTo ()),
711733 ConstInt32 (end));
712734 *ret_tcode = CreateBufferPtr (DataType::Int (32 ), stack_tcode, ConstInt32 (end));
735+ #if TVM_LLVM_VERSION >= 90
736+ auto call_callee = llvm::FunctionCallee (ftype_tvm_func_call_, RuntimeTVMFuncCall ());
737+ #else
738+ auto call_callee = RuntimeTVMFuncCall ();
739+ #endif
713740 BasicBlock *end_block = CheckCallSuccess (builder_->CreateCall (
714- RuntimeTVMFuncCall () , {handle, arg_value, arg_tcode, ConstInt32 (nargs),
715- ret_value, *ret_tcode}));
741+ call_callee , {handle, arg_value, arg_tcode, ConstInt32 (nargs),
742+ ret_value, *ret_tcode}));
716743 DataType r_api_type = tir::APIType (r_type);
717744 llvm::Value* load_ptr = builder_->CreatePointerCast (
718745 ret_value, DTypeToLLVMType (r_api_type)->getPointerTo ());
@@ -890,7 +917,13 @@ void CodeGenCPU::VisitStmt_(const AssertStmtNode* op) {
890917 builder_->CreateCondBr (cond, end_block, fail_block, md_very_likely_branch_);
891918 // fail condition.
892919 builder_->SetInsertPoint (fail_block);
893- builder_->CreateCall (RuntimeTVMAPISetLastError (), {msg});
920+ #if TVM_LLVM_VERSION >= 90
921+ auto err_callee = llvm::FunctionCallee (
922+ ftype_tvm_api_set_last_error_, RuntimeTVMAPISetLastError ());
923+ #else
924+ auto err_callee = RuntimeTVMAPISetLastError ();
925+ #endif
926+ builder_->CreateCall (err_callee, {msg});
894927 builder_->CreateRet (ConstInt32 (-1 ));
895928 // otherwise set it to be new end.
896929 builder_->SetInsertPoint (end_block);
@@ -917,9 +950,14 @@ void CodeGenCPU::VisitStmt_(const AttrStmtNode* op) {
917950 << " Cannot not place within parallel loop as the workload may differ, "
918951 << " place it between parallel and parallel_launch_point" ;
919952 this ->VisitStmt (op->body );
953+ #if TVM_LLVM_VERSION >= 90
954+ auto bar_callee = llvm::FunctionCallee (
955+ ftype_tvm_parallel_barrier_, RuntimeTVMParallelBarrier ());
956+ #else
957+ auto bar_callee = RuntimeTVMParallelBarrier ();
958+ #endif
920959 builder_->CreateCall (
921- RuntimeTVMParallelBarrier (),
922- {MakeValue (parallel_env_.task_id ), parallel_env_.penv });
960+ bar_callee, {MakeValue (parallel_env_.task_id ), parallel_env_.penv });
923961 } else if (op->attr_key == tir::attr::pragma_import_llvm) {
924962 const StringImmNode* value = op->value .as <StringImmNode>();
925963 CHECK (value != nullptr );
0 commit comments