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 {
CHECK_EQ(ecode.value(), 0) << "Cannot open file: " << file_name
<< " " << ecode.message();
if (fmt == "o" || fmt == "obj") {
#if TVM_LLVM_VERSION <= 60
std::unique_ptr<llvm::Module> m = llvm::CloneModule(mptr_);
#else
std::unique_ptr<llvm::Module> m = llvm::CloneModule(*mptr_);
#endif
llvm::legacy::PassManager pass;
CHECK(tm_);
CHECK(tm_->addPassesToEmitFile(
......@@ -76,7 +80,11 @@ class LLVMModuleNode final : public runtime::ModuleNode {
<< "Cannot emit target CGFT_ObjectFile";
pass.run(*m);
} else if (fmt == "s" || fmt == "asm") {
#if TVM_LLVM_VERSION <= 60
std::unique_ptr<llvm::Module> m = llvm::CloneModule(mptr_);
#else
std::unique_ptr<llvm::Module> m = llvm::CloneModule(*mptr_);
#endif
llvm::legacy::PassManager pass;
CHECK(tm_);
CHECK(tm_->addPassesToEmitFile(
......@@ -86,7 +94,11 @@ class LLVMModuleNode final : public runtime::ModuleNode {
} else if (fmt == "ll") {
mptr_->print(dest, nullptr);
} else if (fmt == "bc") {
#if TVM_LLVM_VERSION <= 60
llvm::WriteBitcodeToFile(mptr_, dest);
#else
llvm::WriteBitcodeToFile(*mptr_, dest);
#endif
} else {
LOG(FATAL) << "Do not know how to save file "
<< 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