提交 87dcae4c 编写于 作者: S Shreedhar Hardikar 提交者: Nikos Armenatzoglou

Capture and print error messages from llvm::verifyFunction

Signed-off-by: NNikos Armenatzoglou <nikos.armenatzoglou@gmail.com>
上级 65137540
......@@ -24,6 +24,7 @@ extern "C" {
#include "llvm/IR/Function.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/raw_ostream.h"
namespace gpcodegen {
......@@ -65,11 +66,15 @@ class BaseCodegen: public CodegenInterface {
if (codegen_validate_functions && valid_generated_functions) {
for (llvm::Function* function : uncompiled_generated_functions_) {
assert(nullptr != function);
std::string func_name = function->getName();
std::string error_message = "";
llvm::raw_string_ostream out(error_message);
// Verify function returns true if there are errors.
valid_generated_functions &= !llvm::verifyFunction(*function);
valid_generated_functions &= !llvm::verifyFunction(*function, &out);
out.flush();
if (!valid_generated_functions) {
std::string func_name = function->getName();
elog(WARNING, "Broken function found '%s'", func_name.c_str());
elog(WARNING, "Broken function found %s: %s",
func_name.c_str(), error_message.c_str());
break;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册