From 410baf67dbec648e95e95ade0131c83f23934f52 Mon Sep 17 00:00:00 2001 From: Joejiong <1004691415@qq.com> Date: Sat, 7 Aug 2021 15:04:57 +0800 Subject: [PATCH 1/3] fix error when compile tvm with latest llvm14git --- src/target/llvm/codegen_llvm.cc | 2 +- src/target/llvm/llvm_module.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index b83748b784b6..f3dd7b91c533 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -861,7 +861,7 @@ 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: " - << llvm::Intrinsic::getName(id, {}); + << llvm::Intrinsic::getName(id, return_type, {}); 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..015b58b2e8c1 100644 --- a/src/target/llvm/llvm_module.cc +++ b/src/target/llvm/llvm_module.cc @@ -98,7 +98,7 @@ 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; - llvm::raw_fd_ostream dest(file_name, ecode, llvm::sys::fs::F_None); + llvm::raw_fd_ostream dest(file_name, ecode, llvm::sys::fs::OF_None); ICHECK_EQ(ecode.value(), 0) << "Cannot open file: " << file_name << " " << ecode.message(); if (fmt == "o" || fmt == "obj") { #if TVM_LLVM_VERSION <= 60 From cec2f525dc8ee9a15d7a95c982277ea2ee8e7b1c Mon Sep 17 00:00:00 2001 From: Joejiong <1004691415@qq.com> Date: Sun, 8 Aug 2021 15:20:05 +0800 Subject: [PATCH 2/3] add llvm version guard --- 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 f3dd7b91c533..04dc2a330ed7 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 015b58b2e8c1..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 From 55d00960e9b49fa0e3baed667f5f4c8c77379c87 Mon Sep 17 00:00:00 2001 From: Joejiong <1004691415@qq.com> Date: Sun, 8 Aug 2021 23:24:01 +0800 Subject: [PATCH 3/3] remove extra white space --- src/target/llvm/codegen_llvm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 04dc2a330ed7..6aabdc1bd804 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -865,7 +865,7 @@ llvm::Value* CodeGenLLVM::CreateIntrinsic(const CallNode* op) { << llvm::Intrinsic::getName(id, {}); #else << llvm::Intrinsic::getName(id, return_type, {}); -#endif +#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]));