From: Mehdi Amini Date: Sat, 24 Jun 2023 01:15:47 +0000 (+0200) Subject: Improve fatal error message when handling promised interfaces X-Git-Tag: upstream/17.0.6~3999 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91ae1f5d08d98daae2122b0ab3779b8e1603a045;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h index d5d36ed..3a7ad87 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; public: - DialectInterfaceCollectionBase(MLIRContext *ctx, TypeID interfaceKind); + DialectInterfaceCollectionBase(MLIRContext *ctx, TypeID interfaceKind, + StringRef interfaceName); virtual ~DialectInterfaceCollectionBase(); protected: @@ -159,7 +160,8 @@ public: /// Collect the registered dialect interfaces within the provided context. DialectInterfaceCollection(MLIRContext *ctx) : detail::DialectInterfaceCollectionBase( - ctx, InterfaceType::getInterfaceID()) {} + ctx, InterfaceType::getInterfaceID(), + llvm::getTypeName()) {} /// 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 ebf40a7..501f52b 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);