[Mlir-commits] [mlir] 91ae1f5 - Improve fatal error message when handling promised interfaces

Mehdi Amini llvmlistbot at llvm.org
Fri Jun 23 19:08:32 PDT 2023


Author: Mehdi Amini
Date: 2023-06-24T03:48:10+02:00
New Revision: 91ae1f5d08d98daae2122b0ab3779b8e1603a045

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

LOG: Improve fatal error message when handling promised interfaces

When initializing DialectInterfaceCollection, we wouldn't have the missing
interface name in the error.

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/DialectInterface.h
    mlir/lib/IR/Dialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h
index d5d36ed0171d2..3a7ad87b161ee 100644
--- a/mlir/include/mlir/IR/DialectInterface.h
+++ b/mlir/include/mlir/IR/DialectInterface.h
@@ -97,7 +97,8 @@ class DialectInterfaceCollectionBase {
   using InterfaceVectorT = std::vector<const DialectInterface *>;
 
 public:
-  DialectInterfaceCollectionBase(MLIRContext *ctx, TypeID interfaceKind);
+  DialectInterfaceCollectionBase(MLIRContext *ctx, TypeID interfaceKind,
+                                 StringRef interfaceName);
   virtual ~DialectInterfaceCollectionBase();
 
 protected:
@@ -159,7 +160,8 @@ class DialectInterfaceCollection
   /// Collect the registered dialect interfaces within the provided context.
   DialectInterfaceCollection(MLIRContext *ctx)
       : detail::DialectInterfaceCollectionBase(
-            ctx, InterfaceType::getInterfaceID()) {}
+            ctx, InterfaceType::getInterfaceID(),
+            llvm::getTypeName<InterfaceType>()) {}
 
   /// Get the interface for a given object, or null if one is not registered.
   /// The object may be a dialect or an operation instance.

diff  --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp
index ebf40a72abfd0..501f52b83e026 100644
--- a/mlir/lib/IR/Dialect.cpp
+++ b/mlir/lib/IR/Dialect.cpp
@@ -122,8 +122,11 @@ MLIRContext *DialectInterface::getContext() const {
 }
 
 DialectInterfaceCollectionBase::DialectInterfaceCollectionBase(
-    MLIRContext *ctx, TypeID interfaceKind) {
+    MLIRContext *ctx, TypeID interfaceKind, StringRef interfaceName) {
   for (auto *dialect : ctx->getLoadedDialects()) {
+#ifndef NDEBUG
+  dialect->handleUseOfUndefinedPromisedInterface(interfaceKind, interfaceName);
+#endif
     if (auto *interface = dialect->getRegisteredInterface(interfaceKind)) {
       interfaces.insert(interface);
       orderedInterfaces.push_back(interface);


        


More information about the Mlir-commits mailing list