[Mlir-commits] [mlir] 49f745f - [mlir] run the verifier before translating a module

Alex Zinenko llvmlistbot at llvm.org
Wed Jul 28 09:16:07 PDT 2021


Author: Alex Zinenko
Date: 2021-07-28T18:15:58+02:00
New Revision: 49f745f59cbe1eda4653d917cc7d8d0b586fc6a4

URL: https://github.com/llvm/llvm-project/commit/49f745f59cbe1eda4653d917cc7d8d0b586fc6a4
DIFF: https://github.com/llvm/llvm-project/commit/49f745f59cbe1eda4653d917cc7d8d0b586fc6a4.diff

LOG: [mlir] run the verifier before translating a module

In translation from MLIR to another IR, run the MLIR verifier on the parsed
module to ensure only valid modules are given to the translation. Previously,
we would send any module that could be parsed to the translation, including
semantically invalid modules, leading to surprising errors or lack thereof down
the pipeline.

Depends On D106937

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D106938

Added: 
    

Modified: 
    mlir/lib/Translation/Translation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp
index d357a58ac892b..0dc0e6c5ae66a 100644
--- a/mlir/lib/Translation/Translation.cpp
+++ b/mlir/lib/Translation/Translation.cpp
@@ -102,7 +102,7 @@ TranslateFromMLIRRegistration::TranslateFromMLIRRegistration(
     dialectRegistration(registry);
     context->appendDialectRegistry(registry);
     auto module = OwningModuleRef(parseSourceFile(sourceMgr, context));
-    if (!module)
+    if (!module || failed(verify(*module)))
       return failure();
     return function(module.get(), output);
   });


        


More information about the Mlir-commits mailing list