From ed048b8aa8d3c1736e3bf66549c5a018b0a1be39 Mon Sep 17 00:00:00 2001 From: joejiong <1004691415@qq.com> Date: Mon, 9 Aug 2021 04:48:04 +0800 Subject: [PATCH] Fix error when compile tvm with latest llvm14git (#8682) --- src/target/llvm/codegen_llvm.cc | 4 ++++ src/target/llvm/llvm_module.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index b83748b784b6..6aabdc1bd804 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -861,7 +861,11 @@ llvm::Value* CodeGenLLVM::CreateIntrinsic(const CallNode* op) { : llvm::Type::getVoidTy(*ctx_); llvm::Function* f = GetIntrinsicDecl(id, return_type, arg_type); ICHECK(f) << "Cannot find intrinsic declaration, possible type mismatch: " +#if TVM_LLVM_VERSION <= 130 << llvm::Intrinsic::getName(id, {}); +#else + << llvm::Intrinsic::getName(id, return_type, {}); +#endif return builder_->CreateCall(f, arg_value); } else if (op->op.same_as(builtin::bitwise_and())) { return builder_->CreateAnd(MakeValue(op->args[0]), MakeValue(op->args[1])); diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc index 15a1493b8585..12c7a3132947 100644 --- a/src/target/llvm/llvm_module.cc +++ b/src/target/llvm/llvm_module.cc @@ -98,7 +98,11 @@ class LLVMModuleNode final : public runtime::ModuleNode { void SaveToFile(const std::string& file_name, const std::string& format) final { std::string fmt = runtime::GetFileFormat(file_name, format); std::error_code ecode; +#if TVM_LLVM_VERSION <= 70 llvm::raw_fd_ostream dest(file_name, ecode, llvm::sys::fs::F_None); +#else + llvm::raw_fd_ostream dest(file_name, ecode, llvm::sys::fs::OF_None); +#endif ICHECK_EQ(ecode.value(), 0) << "Cannot open file: " << file_name << " " << ecode.message(); if (fmt == "o" || fmt == "obj") { #if TVM_LLVM_VERSION <= 60