diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -1556,6 +1556,12 @@ } static void print(OpAsmPrinter &p, AffineForOp op) { + if (op.getRegion().empty()) { + p << " <> "; + p.printGenericOp(op, false); + return; + } + p << ' '; p.printOperand(op.getBody()->getArgument(0)); p << " = "; @@ -3136,6 +3142,12 @@ } static void print(OpAsmPrinter &p, AffineParallelOp op) { + if (op.getRegion().empty()) { + p << " <> "; + p.printGenericOp(op, false); + return; + } + p << " (" << op.getBody()->getArguments() << ") = ("; printMinMaxBound(p, op.lowerBoundsMapAttr(), op.lowerBoundsGroupsAttr(), op.getLowerBoundsOperands(), "max"); diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -341,6 +341,12 @@ } static void print(OpAsmPrinter &p, ForOp op) { + if (op.getRegion().empty()) { + p << " <> "; + p.printGenericOp(op, false); + return; + } + p << " " << op.getInductionVar() << " = " << op.getLowerBound() << " to " << op.getUpperBound() << " step " << op.getStep(); @@ -1843,6 +1849,12 @@ } static void print(OpAsmPrinter &p, ParallelOp op) { + if (op.getRegion().empty()) { + p << " <> "; + p.printGenericOp(op, false); + return; + } + p << " (" << op.getBody()->getArguments() << ") = (" << op.getLowerBound() << ") to (" << op.getUpperBound() << ") step (" << op.getStep() << ")"; if (!op.getInitVals().empty()) @@ -2217,6 +2229,12 @@ /// Prints a `while` op. static void print(OpAsmPrinter &p, scf::WhileOp op) { + if (op.getBefore().empty() || op.getAfter().empty()) { + p << " <> "; + p.printGenericOp(op, false); + return; + } + printInitializationList(p, op.getBefore().front().getArguments(), op.getInits(), " "); p << " : "; diff --git a/mlir/test/Conversion/AffineToStandard/lower-affine.mlir b/mlir/test/Conversion/AffineToStandard/lower-affine.mlir --- a/mlir/test/Conversion/AffineToStandard/lower-affine.mlir +++ b/mlir/test/Conversion/AffineToStandard/lower-affine.mlir @@ -1,4 +1,5 @@ -// RUN: mlir-opt -lower-affine %s | FileCheck %s +// `-debug` is used here to check that we don't crash when it's specified. +// RUN: mlir-opt -lower-affine -debug %s | FileCheck %s // CHECK-LABEL: func @empty() { func @empty() { diff --git a/mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir b/mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir --- a/mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir +++ b/mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir @@ -1,4 +1,5 @@ -// RUN: mlir-opt -allow-unregistered-dialect -convert-scf-to-std %s | FileCheck %s +// `-debug` is used here to check that we don't crash when it's specified. +// RUN: mlir-opt -allow-unregistered-dialect -convert-scf-to-std -debug %s | FileCheck %s // CHECK-LABEL: func @simple_std_for_loop(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index) { // CHECK-NEXT: br ^bb1(%{{.*}} : index)