[mlir] Fix alias printing for dialect attribute self types
authorRiver Riddle <riddleriver@gmail.com>
Mon, 5 Dec 2022 19:12:54 +0000 (11:12 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Mon, 5 Dec 2022 19:31:50 +0000 (11:31 -0800)
This was donked up in the last patch that only considered
aliases for things actually getting printed.

mlir/lib/IR/AsmPrinter.cpp
mlir/test/IR/print-attr-type-aliases.mlir

index b528d82..8fa7b3e 100644 (file)
@@ -787,14 +787,14 @@ private:
   /// 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());
index b1631b2..a3db1f0 100644 (file)
 
 // -----
 
+// 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