[PATCH] D78766: [mlir][drr] NFC: avoid SmallVector when collecting substitution values

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 07:00:02 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f8b164ca220: [mlir][drr] NFC: avoid SmallVector when collecting substitution values (authored by antiagainst).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78766/new/

https://reviews.llvm.org/D78766

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


Index: mlir/tools/mlir-tblgen/RewriterGen.cpp
===================================================================
--- mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -612,15 +612,8 @@
       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 (auto v : SmallVector<Value, 4>{ {0} }) {{ "
-          "tblgen_repl_values.push_back(v); }",
+          val, "    for (Value v : {0}) {{ tblgen_repl_values.push_back(v); }",
           "\n");
     }
     os.indent(4) << "\n";
Index: mlir/lib/TableGen/Pattern.cpp
===================================================================
--- mlir/lib/TableGen/Pattern.cpp
+++ mlir/lib/TableGen/Pattern.cpp
@@ -345,7 +345,7 @@
   case Kind::Value: {
     assert(index < 0 && "only allowed for symbol bound to result");
     assert(op == nullptr);
-    auto repl = formatv(fmt, formatv("{{{0}}", name));
+    auto repl = formatv(fmt, formatv("ValueRange{{{0}}", name));
     LLVM_DEBUG(llvm::dbgs() << repl << " (Value)\n");
     return std::string(repl);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78766.259878.patch
Type: text/x-patch
Size: 1565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200424/d0abc1cf/attachment.bin>


More information about the llvm-commits mailing list