Verify IR produced by TranslateToMLIR functions

TESTED with existing unit tests

PiperOrigin-RevId: 235623059
This commit is contained in:
Smit Hinsu 2019-02-25 16:23:08 -08:00 committed by jpienaar
parent b269481106
commit fd3c2d156f
1 changed files with 3 additions and 2 deletions

View File

@ -59,6 +59,8 @@ static Module *parseMLIRInput(StringRef inputFilename, MLIRContext *context) {
static bool printMLIROutput(const Module &module, static bool printMLIROutput(const Module &module,
llvm::StringRef outputFilename) { llvm::StringRef outputFilename) {
if (module.verify())
return true;
auto file = openOutputFile(outputFilename); auto file = openOutputFile(outputFilename);
if (!file) if (!file)
return true; return true;
@ -88,8 +90,7 @@ struct TranslationParser : public llvm::cl::parser<const TranslateFunction *> {
std::unique_ptr<Module> module = function(inputFilename, context); std::unique_ptr<Module> module = function(inputFilename, context);
if (!module) if (!module)
return true; return true;
printMLIROutput(*module, outputFilename); return printMLIROutput(*module, outputFilename);
return false;
}; };
wrapperStorage.emplace_back(std::move(wrapper)); wrapperStorage.emplace_back(std::move(wrapper));