summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms/Utils
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-12-11 16:26:08 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-11 16:26:45 -0800
commit851a8516d3883088b0c02601f9c1bb269e85051c (patch)
tree7c0485fe353c4d6f10d92e7b36c4be90346c8068 /mlir/lib/Transforms/Utils
parent9dfa84a269e245ebaff032f698a798f71da2c1b5 (diff)
downloadbcm5719-llvm-851a8516d3883088b0c02601f9c1bb269e85051c.tar.gz
bcm5719-llvm-851a8516d3883088b0c02601f9c1bb269e85051c.zip
Make OpBuilder::insert virtual instead of OpBuilder::createOperation.
It is sometimes useful to create operations separately from the builder before insertion as it may be easier to erase them in isolation if necessary. One example use case for this is folding, as we will only want to insert newly generated constant operations on success. This has the added benefit of fixing some silent PatternRewriter failures related to cloning, as the OpBuilder 'clone' methods don't call createOperation. PiperOrigin-RevId: 285086242
Diffstat (limited to 'mlir/lib/Transforms/Utils')
-rw-r--r--mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
index aa4563c96e4..e2ca3f8fc5e 100644
--- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
@@ -86,12 +86,11 @@ public:
// These are hooks implemented for PatternRewriter.
protected:
- // Implement the hook for creating operations, and make sure that newly
- // created ops are added to the worklist for processing.
- Operation *createOperation(const OperationState &state) override {
- auto *result = OpBuilder::createOperation(state);
- addToWorklist(result);
- return result;
+ // Implement the hook for inserting operations, and make sure that newly
+ // inserted ops are added to the worklist for processing.
+ Operation *insert(Operation *op) override {
+ addToWorklist(op);
+ return OpBuilder::insert(op);
}
// If an operation is about to be removed, make sure it is not in our
OpenPOWER on IntegriCloud