diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1547,24 +1547,30 @@ } if (ComplexType complexTy = elementType.dyn_cast()) { - auto printComplexValue = [&](auto complexValues, auto printFn, - raw_ostream &os, auto &&... params) { + Type complexElementType = complexTy.getElementType(); + // Note: The if and else below had a common lambda function which invoked + // printDenseElementsAttrImpl. This lambda was hitting a bug in gcc 9.1,9.2 + // and hence was replaced. + if (complexElementType.isa()) { + bool isSigned = !complexElementType.isUnsignedInteger(); printDenseElementsAttrImpl(attr.isSplat(), type, os, [&](unsigned index) { - auto complexValue = *(complexValues.begin() + index); + auto complexValue = *(attr.getComplexIntValues().begin() + index); os << "("; - printFn(complexValue.real(), os, params...); + printDenseIntElement(complexValue.real(), os, isSigned); os << ","; - printFn(complexValue.imag(), os, params...); + printDenseIntElement(complexValue.imag(), os, isSigned); os << ")"; }); - }; - - Type complexElementType = complexTy.getElementType(); - if (complexElementType.isa()) - printComplexValue(attr.getComplexIntValues(), printDenseIntElement, os, - /*isSigned=*/!complexElementType.isUnsignedInteger()); - else - printComplexValue(attr.getComplexFloatValues(), printFloatValue, os); + } else { + printDenseElementsAttrImpl(attr.isSplat(), type, os, [&](unsigned index) { + auto complexValue = *(attr.getComplexFloatValues().begin() + index); + os << "("; + printFloatValue(complexValue.real(), os); + os << ","; + printFloatValue(complexValue.imag(), os); + os << ")"; + }); + } } else if (elementType.isIntOrIndex()) { bool isSigned = !elementType.isUnsignedInteger(); auto intValues = attr.getIntValues();