[Mlir-commits] [mlir] f549140 - Fix mlir-reduce to explicitly register dialects and disable the global dialect registry by default

Mehdi Amini llvmlistbot at llvm.org
Mon Aug 31 15:55:09 PDT 2020


Author: Mehdi Amini
Date: 2020-08-31T22:54:58Z
New Revision: f54914081fd43fa5aca92df6630723be902adebd

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

LOG: Fix mlir-reduce to explicitly register dialects and disable the global dialect registry by default

Clients who rely on the Context loading dialects from the global
registry can call `mlir::enableGlobalDialectRegistry(true);` before
creating an MLIRContext

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

Added: 
    

Modified: 
    mlir/lib/IR/Dialect.cpp
    mlir/tools/mlir-reduce/CMakeLists.txt
    mlir/tools/mlir-reduce/mlir-reduce.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp
index b3b1c9166d77..f356e8265ecf 100644
--- a/mlir/lib/IR/Dialect.cpp
+++ b/mlir/lib/IR/Dialect.cpp
@@ -31,7 +31,7 @@ static llvm::ManagedStatic<DialectRegistry> dialectRegistry;
 DialectRegistry &mlir::getGlobalDialectRegistry() { return *dialectRegistry; }
 
 // Note: deprecated, will be removed soon.
-static bool isGlobalDialectRegistryEnabledFlag = true;
+static bool isGlobalDialectRegistryEnabledFlag = false;
 void mlir::enableGlobalDialectRegistry(bool enable) {
   isGlobalDialectRegistryEnabledFlag = enable;
 }

diff  --git a/mlir/tools/mlir-reduce/CMakeLists.txt b/mlir/tools/mlir-reduce/CMakeLists.txt
index 8262dc94b6f2..958c2c94cc68 100644
--- a/mlir/tools/mlir-reduce/CMakeLists.txt
+++ b/mlir/tools/mlir-reduce/CMakeLists.txt
@@ -13,6 +13,18 @@ set(LLVM_LINK_COMPONENTS
   TransformUtils
   )
 
+if(MLIR_INCLUDE_TESTS)
+  set(test_libs
+    MLIRAffineTransformsTestPasses
+    MLIRSPIRVTestPasses
+    MLIRTestDialect
+    MLIRTestIR
+    MLIRTestPass
+    MLIRTestReducer
+    MLIRTestTransforms
+    )
+endif()
+
 set(LIBS
   ${dialect_libs}
   ${conversion_libs}

diff  --git a/mlir/tools/mlir-reduce/mlir-reduce.cpp b/mlir/tools/mlir-reduce/mlir-reduce.cpp
index e60aa2f95c59..3397bfc2aaf9 100644
--- a/mlir/tools/mlir-reduce/mlir-reduce.cpp
+++ b/mlir/tools/mlir-reduce/mlir-reduce.cpp
@@ -32,6 +32,10 @@
 
 using namespace mlir;
 
+namespace mlir {
+void registerTestDialect(DialectRegistry &);
+}
+
 static llvm::cl::opt<std::string> inputFilename(llvm::cl::Positional,
                                                 llvm::cl::Required,
                                                 llvm::cl::desc("<input file>"));
@@ -85,9 +89,12 @@ int main(int argc, char **argv) {
     llvm::report_fatal_error(errorMessage);
 
   mlir::MLIRContext context;
-  mlir::OwningModuleRef moduleRef;
-  context.allowUnregisteredDialects(true);
+  registerAllDialects(context.getDialectRegistry());
+#ifdef MLIR_INCLUDE_TESTS
+  mlir::registerTestDialect(context.getDialectRegistry());
+#endif
 
+  mlir::OwningModuleRef moduleRef;
   if (failed(loadModule(context, moduleRef, inputFilename)))
     llvm::report_fatal_error("Input test case can't be parsed");
 


        


More information about the Mlir-commits mailing list