[Mlir-commits] [mlir] 60f1d26 - Revert "[mlir][drr] NFC: avoid SmallVector when collecting substitution values"

Lei Zhang llvmlistbot at llvm.org
Fri Apr 24 12:34:02 PDT 2020


Author: Lei Zhang
Date: 2020-04-24T15:33:03-04:00
New Revision: 60f1d2636626a0b92b6ad2cb86eea78cb1cd7b33

URL: https://github.com/llvm/llvm-project/commit/60f1d2636626a0b92b6ad2cb86eea78cb1cd7b33
DIFF: https://github.com/llvm/llvm-project/commit/60f1d2636626a0b92b6ad2cb86eea78cb1cd7b33.diff

LOG: Revert "[mlir][drr] NFC: avoid SmallVector when collecting substitution values"

This reverts commit 2f8b164ca220f8cd29d70c8359ed91e8fb8d9959, which
causes a breakage on Clang 5.

Added: 
    

Modified: 
    mlir/lib/TableGen/Pattern.cpp
    mlir/tools/mlir-tblgen/RewriterGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp
index 7fb3a96395b5..b04c8e215679 100644
--- a/mlir/lib/TableGen/Pattern.cpp
+++ b/mlir/lib/TableGen/Pattern.cpp
@@ -345,7 +345,7 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getAllRangeUse(
   case Kind::Value: {
     assert(index < 0 && "only allowed for symbol bound to result");
     assert(op == nullptr);
-    auto repl = formatv(fmt, formatv("ValueRange{{{0}}", name));
+    auto repl = formatv(fmt, formatv("{{{0}}", name));
     LLVM_DEBUG(llvm::dbgs() << repl << " (Value)\n");
     return std::string(repl);
   }

diff  --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 8e8decc45506..62638e6c9964 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -612,8 +612,15 @@ void PatternEmitter::emitRewriteLogic() {
       auto val = handleResultPattern(resultTree, offsets[i], 0);
       os.indent(4) << "\n";
       // Resolve each symbol for all range use so that we can loop over them.
+      // We need an explicit cast to `SmallVector` to capture the cases where
+      // `{0}` resolves to an `Operation::result_range` as well as cases that
+      // are not iterable (e.g. vector that gets wrapped in additional braces by
+      // RewriterGen).
+      // TODO(b/147096809): Revisit the need for materializing a vector.
       os << symbolInfoMap.getAllRangeUse(
-          val, "    for (Value v : {0}) {{ tblgen_repl_values.push_back(v); }",
+          val,
+          "    for (auto v : SmallVector<Value, 4>{ {0} }) {{ "
+          "tblgen_repl_values.push_back(v); }",
           "\n");
     }
     os.indent(4) << "\n";


        


More information about the Mlir-commits mailing list