From fd3c2d156f301ce31015afa704eada57b238cf7a Mon Sep 17 00:00:00 2001 From: Smit Hinsu Date: Mon, 25 Feb 2019 16:23:08 -0800 Subject: [PATCH] Verify IR produced by TranslateToMLIR functions TESTED with existing unit tests PiperOrigin-RevId: 235623059 --- mlir/tools/mlir-translate/mlir-translate.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mlir/tools/mlir-translate/mlir-translate.cpp b/mlir/tools/mlir-translate/mlir-translate.cpp index f514a2258099..9cb2533f67bc 100644 --- a/mlir/tools/mlir-translate/mlir-translate.cpp +++ b/mlir/tools/mlir-translate/mlir-translate.cpp @@ -59,6 +59,8 @@ static Module *parseMLIRInput(StringRef inputFilename, MLIRContext *context) { static bool printMLIROutput(const Module &module, llvm::StringRef outputFilename) { + if (module.verify()) + return true; auto file = openOutputFile(outputFilename); if (!file) return true; @@ -88,8 +90,7 @@ struct TranslationParser : public llvm::cl::parser { std::unique_ptr module = function(inputFilename, context); if (!module) return true; - printMLIROutput(*module, outputFilename); - return false; + return printMLIROutput(*module, outputFilename); }; wrapperStorage.emplace_back(std::move(wrapper));