[mlir] Do not expose MLIRContext::isDialectLoading
authorMatthias Springer <springerm@google.com>
Mon, 31 Oct 2022 07:59:12 +0000 (08:59 +0100)
committerMatthias Springer <springerm@google.com>
Mon, 31 Oct 2022 08:08:44 +0000 (09:08 +0100)
This addresses post-commit comments and should have been part of D136685.

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

mlir/include/mlir/IR/MLIRContext.h
mlir/lib/IR/MLIRContext.cpp

index b87dd27..7537f0c 100644 (file)
@@ -98,9 +98,6 @@ public:
         }));
   }
 
-  /// Return true if the given dialect is currently loading.
-  bool isDialectLoading(StringRef dialectNamespace);
-
   /// Load a dialect in the context.
   template <typename Dialect>
   void loadDialect() {
@@ -239,6 +236,9 @@ public:
   llvm::hash_code getRegistryHash();
 
 private:
+  /// Return true if the given dialect is currently loading.
+  bool isDialectLoading(StringRef dialectNamespace);
+
   const std::unique_ptr<MLIRContextImpl> impl;
 
   MLIRContext(const MLIRContext &) = delete;
index 896938d..5809794 100644 (file)
@@ -430,10 +430,10 @@ MLIRContext::getOrLoadDialect(StringRef dialectNamespace, TypeID dialectID,
           "the PassManager): this can indicate a "
           "missing `dependentDialects` in a pass for example.");
 #endif // NDEBUG
-    // nullptr indicates that the dialect is currently being loaded.
-    impl.loadedDialects[dialectNamespace] = nullptr;
-    std::unique_ptr<Dialect> &dialect = impl.loadedDialects[dialectNamespace] =
-        ctor();
+    // loadedDialects entry is initialized to nullptr, indicating that the
+    // dialect is currently being loaded.
+    std::unique_ptr<Dialect> &dialect = impl.loadedDialects[dialectNamespace];
+    dialect = ctor();
     assert(dialect && "dialect ctor failed");
 
     // Refresh all the identifiers dialect field, this catches cases where a