diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index c0c881a46c822e..00e15f286ae575 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -2141,8 +2141,9 @@ void AsmPrinter::Impl::printAttributeImpl(Attribute attr, } else if (auto dictAttr = llvm::dyn_cast(attr)) { os << '{'; SmallString<16> separatorBracket = StringRef(""); - bool breakOnNewLine = - printerFlags.getNewlineAfterAttrLimit() && separator.size() > 2; + bool breakOnNewLine = printerFlags.getNewlineAfterAttrLimit() && + separator.size() > 2 && + dictAttr.getValue().vec().size() > 0; if (breakOnNewLine) { separator.reserve(separator.capacity() + 2); separator.append(" ");