diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1443,7 +1443,7 @@ // Structured attribute that wraps a DictionaryAttr and provides both a // validation method and set of accessors for a fixed set of fields. This is // useful when representing data that would normally be in a structure. -class StructAttr attributes> : DictionaryAttrBase()">, "DictionaryAttr with field(s): " # @@ -1459,7 +1459,7 @@ let storageType = name; // The dialect this StructAttr belongs to. - Dialect structDialect = dialect; + Dialect dialect = d; // List of fields that the StructAttr contains. list fields = attributes; diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -126,7 +126,12 @@ } Dialect Attribute::getDialect() const { - return Dialect(def->getValueAsDef("dialect")); + const llvm::RecordVal *record = def->getValue("dialect"); + if (record && record->getValue()) { + if (DefInit *init = dyn_cast(record->getValue())) + return Dialect(init->getDef()); + } + return Dialect(nullptr); } ConstantAttr::ConstantAttr(const DefInit *init) : def(init->getDef()) { @@ -255,7 +260,7 @@ } StringRef StructAttr::getCppNamespace() const { - Dialect dialect(def->getValueAsDef("structDialect")); + Dialect dialect(def->getValueAsDef("dialect")); return dialect.getCppNamespace(); }