[PATCH] D77521: Skip the op replacement if the returned results are empty
Feng Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 5 22:56:58 PDT 2020
liufengdb updated this revision to Diff 255222.
liufengdb added a comment.
add the erase op
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77521/new/
https://reviews.llvm.org/D77521
Files:
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
@@ -623,7 +623,13 @@
"\n");
}
os.indent(4) << "\n";
- os.indent(4) << "rewriter.replaceOp(op0, tblgen_repl_values);\n";
+ // Skip the op replacement if the result pattern doesn't return results.
+ // This is a special case where the result pattern by NativeCodeCall with
+ // value returned.
+ os.indent(4) << "if (tblgen_repl_values.empty())\n";
+ os.indent(4) << " rewriter.eraseOp(op0);\n";
+ os.indent(4) << "else\n";
+ os.indent(4) << " rewriter.replaceOp(op0, tblgen_repl_values);\n";
}
LLVM_DEBUG(llvm::dbgs() << "--- done emitting rewrite logic ---\n");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77521.255222.patch
Type: text/x-patch
Size: 817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200406/3e74109f/attachment.bin>
More information about the llvm-commits
mailing list