Also visit memref element type in AsmPrinter
authorGeoffrey Martin-Noble <gcmn@google.com>
Fri, 17 May 2019 22:23:44 +0000 (15:23 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 20 May 2019 20:46:17 +0000 (13:46 -0700)
--

PiperOrigin-RevId: 248797935

mlir/lib/IR/AsmPrinter.cpp

index f99c09f..73c74e7 100644 (file)
@@ -197,12 +197,17 @@ void ModuleState::visitType(Type type) {
       visitType(input);
     for (auto result : funcType.getResults())
       visitType(result);
-  } else if (auto memref = type.dyn_cast<MemRefType>()) {
+    return;
+  }
+  if (auto memref = type.dyn_cast<MemRefType>()) {
     // Visit affine maps in memref type.
     for (auto map : memref.getAffineMaps())
       recordAttributeReference(AffineMapAttr::get(map));
-  } else if (auto vecOrTensor = type.dyn_cast<ShapedType>()) {
-    visitType(vecOrTensor.getElementType());
+    // TODO(b/132735995) Remove this when MemRef is a subclass of ShapedType.
+    visitType(memref.getElementType());
+  }
+  if (auto shapedType = type.dyn_cast<ShapedType>()) {
+    visitType(shapedType.getElementType());
   }
 }