Commit 285e8d54 by Andrew Tulloch Committed by Tianqi Chen

Run verifier during LLVM code generation (#2211)

parent cf3f5bce
......@@ -26,6 +26,7 @@
#include <llvm/IR/Type.h>
#include <llvm/IR/Intrinsics.h>
#include <llvm/IR/MDBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Transforms/Utils/Cloning.h>
......
......@@ -168,6 +168,11 @@ class LLVMModuleNode final : public runtime::ModuleNode {
}
cg->AddMainFunction(funcs[0]->name);
module_ = cg->Finish();
std::string verify_errors_storage;
llvm::raw_string_ostream verify_errors(verify_errors_storage);
LOG_IF(FATAL, llvm::verifyModule(*module_, &verify_errors))
<< "LLVM module verification failed with the following errors: \n"
<< verify_errors.str();
module_->addModuleFlag(
llvm::Module::Warning, "tvm_target",
llvm::MDString::get(*ctx_, target));
......
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