[Mlir-commits] [mlir] 6cd2320 - [MLIR][NFC] Inline lambda to workaround gcc 9.1, 9.2 bug

Kiran Chandramohan llvmlistbot at llvm.org
Tue Jun 16 07:37:26 PDT 2020


Author: Kiran Chandramohan
Date: 2020-06-16T15:31:06+01:00
New Revision: 6cd232056c3cdaf5e9eb85ede8e42d0db97f0f71

URL: https://github.com/llvm/llvm-project/commit/6cd232056c3cdaf5e9eb85ede8e42d0db97f0f71
DIFF: https://github.com/llvm/llvm-project/commit/6cd232056c3cdaf5e9eb85ede8e42d0db97f0f71.diff

LOG: [MLIR][NFC] Inline lambda to workaround gcc 9.1,9.2 bug

gcc 9.1/9.2 has a bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90538)
which leads to an incorrect error when expanding parameter packs multiple
times in a lambda. Inlining this lambda to work around this issue.

Reviewed By: rriddle, CarolineConcatto

Differential Revision: https://reviews.llvm.org/D81828

Added: 
    

Modified: 
    mlir/lib/IR/AsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 111ab4d96ae2..0636ab59ea50 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -1547,24 +1547,30 @@ void ModulePrinter::printDenseIntOrFPElementsAttr(DenseIntOrFPElementsAttr attr,
   }
 
   if (ComplexType complexTy = elementType.dyn_cast<ComplexType>()) {
-    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<IntegerType>()) {
+      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<IntegerType>())
-      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();


        


More information about the Mlir-commits mailing list