[PATCH] D76415: [mlir] Fix unsafe create operation in GreedyPatternRewriter
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 19 00:30:44 PDT 2020
rriddle accepted this revision.
rriddle added inline comments.
This revision is now accepted and ready to land.
================
Comment at: mlir/include/mlir/Transforms/FoldUtils.h:78
Location location, Args &&... args) {
- Operation *op = builder.create<OpTy>(location, std::forward<Args>(args)...);
- if (failed(tryToFold(op, results)))
+ OperationState state(location, OpTy::getOperationName());
+ OpTy::build(&builder, state, std::forward<Args>(args)...);
----------------
Can you add comments as to why we don't use `builder.create` directly?
================
Comment at: mlir/include/mlir/Transforms/FoldUtils.h:83
+ if (failed(tryToFold(op, results))) {
+ builder.insert(op);
results.assign(op->result_begin(), op->result_end());
----------------
You will also want to insert in the case of successful fold and `getNumResults() == 0`. In that case it is treated as an in-place fold of a zero-result operation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76415/new/
https://reviews.llvm.org/D76415
More information about the llvm-commits
mailing list