[Mlir-commits] [mlir] 031ff67 - [mlir] Fix alias printing for dialect attribute self types
River Riddle
llvmlistbot at llvm.org
Mon Dec 5 11:32:03 PST 2022
Author: River Riddle
Date: 2022-12-05T11:31:50-08:00
New Revision: 031ff673d814901a0ec27af705710abdad1b1b1a
URL: https://github.com/llvm/llvm-project/commit/031ff673d814901a0ec27af705710abdad1b1b1a
DIFF: https://github.com/llvm/llvm-project/commit/031ff673d814901a0ec27af705710abdad1b1b1a.diff
LOG: [mlir] Fix alias printing for dialect attribute self types
This was donked up in the last patch that only considered
aliases for things actually getting printed.
Added:
Modified:
mlir/lib/IR/AsmPrinter.cpp
mlir/test/IR/print-attr-type-aliases.mlir
Removed:
################################################################################
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index b528d826fe068..8fa7b3ec1243c 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -787,14 +787,14 @@ class DummyAliasDialectAsmPrinter : public DialectAsmPrinter {
/// Print the given attribute/type, visiting any nested aliases that would be
/// generated as part of printing.
void printAndVisitNestedAliasesImpl(Attribute attr, bool elideType) {
- if (!isa<BuiltinDialect>(attr.getDialect()))
- return attr.getDialect().printAttribute(attr, *this);
+ if (!isa<BuiltinDialect>(attr.getDialect())) {
+ attr.getDialect().printAttribute(attr, *this);
- // Process the builtin attributes.
- if (attr.isa<AffineMapAttr, DenseArrayAttr, FloatAttr, IntegerAttr,
- IntegerSetAttr, UnitAttr>())
+ // Process the builtin attributes.
+ } else if (attr.isa<AffineMapAttr, DenseArrayAttr, FloatAttr, IntegerAttr,
+ IntegerSetAttr, UnitAttr>()) {
return;
- if (auto dictAttr = dyn_cast<DictionaryAttr>(attr)) {
+ } else if (auto dictAttr = dyn_cast<DictionaryAttr>(attr)) {
for (const NamedAttribute &nestedAttr : dictAttr.getValue()) {
printAttribute(nestedAttr.getName());
printAttribute(nestedAttr.getValue());
diff --git a/mlir/test/IR/print-attr-type-aliases.mlir b/mlir/test/IR/print-attr-type-aliases.mlir
index b1631b2ead397..a3db1f06009d8 100644
--- a/mlir/test/IR/print-attr-type-aliases.mlir
+++ b/mlir/test/IR/print-attr-type-aliases.mlir
@@ -43,6 +43,13 @@
// -----
+// Ensure self type parameters get considered for aliases.
+// CHECK: !test_ui8_ = !test.int<unsigned, 8>
+// CHECK: #test.attr_with_self_type_param : !test_ui8_
+"test.op"() {alias_test = #test.attr_with_self_type_param : !test.int<unsigned, 8> } : () -> ()
+
+// -----
+
// Check that we don't print aliases for things that aren't printed.
// CHECK: #loc1 = loc(fused<memref<1xi32>
// CHECK-NOT: #map
More information about the Mlir-commits
mailing list