Commit 00d3cf11 by HungMingWu Committed by Tianqi Chen

LLVM 7.0 support (#1048)

parent 4b72f293
...@@ -68,7 +68,11 @@ class LLVMModuleNode final : public runtime::ModuleNode { ...@@ -68,7 +68,11 @@ class LLVMModuleNode final : public runtime::ModuleNode {
CHECK_EQ(ecode.value(), 0) << "Cannot open file: " << file_name CHECK_EQ(ecode.value(), 0) << "Cannot open file: " << file_name
<< " " << ecode.message(); << " " << ecode.message();
if (fmt == "o" || fmt == "obj") { if (fmt == "o" || fmt == "obj") {
#if TVM_LLVM_VERSION <= 60
std::unique_ptr<llvm::Module> m = llvm::CloneModule(mptr_); std::unique_ptr<llvm::Module> m = llvm::CloneModule(mptr_);
#else
std::unique_ptr<llvm::Module> m = llvm::CloneModule(*mptr_);
#endif
llvm::legacy::PassManager pass; llvm::legacy::PassManager pass;
CHECK(tm_); CHECK(tm_);
CHECK(tm_->addPassesToEmitFile( CHECK(tm_->addPassesToEmitFile(
...@@ -76,7 +80,11 @@ class LLVMModuleNode final : public runtime::ModuleNode { ...@@ -76,7 +80,11 @@ class LLVMModuleNode final : public runtime::ModuleNode {
<< "Cannot emit target CGFT_ObjectFile"; << "Cannot emit target CGFT_ObjectFile";
pass.run(*m); pass.run(*m);
} else if (fmt == "s" || fmt == "asm") { } else if (fmt == "s" || fmt == "asm") {
#if TVM_LLVM_VERSION <= 60
std::unique_ptr<llvm::Module> m = llvm::CloneModule(mptr_); std::unique_ptr<llvm::Module> m = llvm::CloneModule(mptr_);
#else
std::unique_ptr<llvm::Module> m = llvm::CloneModule(*mptr_);
#endif
llvm::legacy::PassManager pass; llvm::legacy::PassManager pass;
CHECK(tm_); CHECK(tm_);
CHECK(tm_->addPassesToEmitFile( CHECK(tm_->addPassesToEmitFile(
...@@ -86,7 +94,11 @@ class LLVMModuleNode final : public runtime::ModuleNode { ...@@ -86,7 +94,11 @@ class LLVMModuleNode final : public runtime::ModuleNode {
} else if (fmt == "ll") { } else if (fmt == "ll") {
mptr_->print(dest, nullptr); mptr_->print(dest, nullptr);
} else if (fmt == "bc") { } else if (fmt == "bc") {
#if TVM_LLVM_VERSION <= 60
llvm::WriteBitcodeToFile(mptr_, dest); llvm::WriteBitcodeToFile(mptr_, dest);
#else
llvm::WriteBitcodeToFile(*mptr_, dest);
#endif
} else { } else {
LOG(FATAL) << "Do not know how to save file " LOG(FATAL) << "Do not know how to save file "
<< file_name << " with format=\'"<< format << "\'"; << file_name << " with format=\'"<< format << "\'";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment