[Mlir-commits] [mlir] d0d991c - Improve fatal error message when an Attribute or Type wasn't initialized by a dialect (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Sat Oct 16 13:22:28 PDT 2021
Author: Mehdi Amini
Date: 2021-10-16T20:19:35Z
New Revision: d0d991cd23eff29737aae704d8b9611bd3416ec9
URL: https://github.com/llvm/llvm-project/commit/d0d991cd23eff29737aae704d8b9611bd3416ec9
DIFF: https://github.com/llvm/llvm-project/commit/d0d991cd23eff29737aae704d8b9611bd3416ec9.diff
LOG: Improve fatal error message when an Attribute or Type wasn't initialized by a dialect (NFC)
The existing message hints that the dialect may not be loaded, but there
is also the possibility that the dialect was loaded and the initialize()
method didn't include the Type/Attribute.
Added:
Modified:
mlir/include/mlir/IR/AttributeSupport.h
mlir/include/mlir/IR/TypeSupport.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/AttributeSupport.h b/mlir/include/mlir/IR/AttributeSupport.h
index d18f0ab8aad70..2964246ae2a59 100644
--- a/mlir/include/mlir/IR/AttributeSupport.h
+++ b/mlir/include/mlir/IR/AttributeSupport.h
@@ -179,10 +179,11 @@ class AttributeUniquer {
#ifndef NDEBUG
if (!ctx->getAttributeUniquer().isParametricStorageInitialized(
T::getTypeID()))
- llvm::report_fatal_error(llvm::Twine("can't create Attribute '") +
- llvm::getTypeName<T>() +
- "' because storage uniquer isn't initialized: "
- "the dialect was likely not loaded.");
+ llvm::report_fatal_error(
+ llvm::Twine("can't create Attribute '") + llvm::getTypeName<T>() +
+ "' because storage uniquer isn't initialized: the dialect was likely "
+ "not loaded, or the attribute wasn't added with addAttributes<...>() "
+ "in the Dialect::initialize() method.");
#endif
return ctx->getAttributeUniquer().get<typename T::ImplType>(
[ctx](AttributeStorage *storage) {
@@ -198,10 +199,11 @@ class AttributeUniquer {
#ifndef NDEBUG
if (!ctx->getAttributeUniquer().isSingletonStorageInitialized(
T::getTypeID()))
- llvm::report_fatal_error(llvm::Twine("can't create Attribute '") +
- llvm::getTypeName<T>() +
- "' because storage uniquer isn't initialized: "
- "the dialect was likely not loaded.");
+ llvm::report_fatal_error(
+ llvm::Twine("can't create Attribute '") + llvm::getTypeName<T>() +
+ "' because storage uniquer isn't initialized: the dialect was likely "
+ "not loaded, or the attribute wasn't added with addAttributes<...>() "
+ "in the Dialect::initialize() method.");
#endif
return ctx->getAttributeUniquer().get<typename T::ImplType>(T::getTypeID());
}
diff --git a/mlir/include/mlir/IR/TypeSupport.h b/mlir/include/mlir/IR/TypeSupport.h
index 6a929c6e48e0a..45f8fcbc04684 100644
--- a/mlir/include/mlir/IR/TypeSupport.h
+++ b/mlir/include/mlir/IR/TypeSupport.h
@@ -170,10 +170,11 @@ struct TypeUniquer {
get(MLIRContext *ctx, Args &&...args) {
#ifndef NDEBUG
if (!ctx->getTypeUniquer().isParametricStorageInitialized(T::getTypeID()))
- llvm::report_fatal_error(llvm::Twine("can't create type '") +
- llvm::getTypeName<T>() +
- "' because storage uniquer isn't initialized: "
- "the dialect was likely not loaded.");
+ llvm::report_fatal_error(
+ llvm::Twine("can't create type '") + llvm::getTypeName<T>() +
+ "' because storage uniquer isn't initialized: the dialect was likely "
+ "not loaded, or the type wasn't added with addTypes<...>() "
+ "in the Dialect::initialize() method.");
#endif
return ctx->getTypeUniquer().get<typename T::ImplType>(
[&](TypeStorage *storage) {
@@ -188,10 +189,11 @@ struct TypeUniquer {
get(MLIRContext *ctx) {
#ifndef NDEBUG
if (!ctx->getTypeUniquer().isSingletonStorageInitialized(T::getTypeID()))
- llvm::report_fatal_error(llvm::Twine("can't create type '") +
- llvm::getTypeName<T>() +
- "' because storage uniquer isn't initialized: "
- "the dialect was likely not loaded.");
+ llvm::report_fatal_error(
+ llvm::Twine("can't create type '") + llvm::getTypeName<T>() +
+ "' because storage uniquer isn't initialized: the dialect was likely "
+ "not loaded, or the type wasn't added with addTypes<...>() "
+ "in the Dialect::initialize() method.");
#endif
return ctx->getTypeUniquer().get<typename T::ImplType>(T::getTypeID());
}
More information about the Mlir-commits
mailing list