diff options
| author | River Riddle <riverriddle@google.com> | 2019-12-23 13:05:38 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-23 16:26:15 -0800 |
| commit | 5d5bd2e1da29d976cb125dbb3cd097a5e42b2be4 (patch) | |
| tree | 7df1c8e31616dc8e59025def2de12c4327637428 /mlir/lib/IR | |
| parent | a5d5d2912506322b224eff0428de796a5ef7c1a4 (diff) | |
| download | bcm5719-llvm-5d5bd2e1da29d976cb125dbb3cd097a5e42b2be4.tar.gz bcm5719-llvm-5d5bd2e1da29d976cb125dbb3cd097a5e42b2be4.zip | |
Change the `notifyRootUpdated` API to be transaction based.
This means that in-place, or root, updates need to use explicit calls to `startRootUpdate`, `finalizeRootUpdate`, and `cancelRootUpdate`. The major benefit of this change is that it enables in-place updates in DialectConversion, which simplifies the FuncOp pattern for example. The major downside to this is that the cases that *may* modify an operation in-place will need an explicit cancel on the failure branches(assuming that they started an update before attempting the transformation).
PiperOrigin-RevId: 286933674
Diffstat (limited to 'mlir/lib/IR')
| -rw-r--r-- | mlir/lib/IR/Block.cpp | 5 | ||||
| -rw-r--r-- | mlir/lib/IR/PatternMatch.cpp | 17 |
2 files changed, 5 insertions, 17 deletions
diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 3abbe1027ce..751ceb1bfb4 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -267,3 +267,8 @@ SuccessorRange::SuccessorRange(Block *block) : SuccessorRange(nullptr, 0) { if ((count = term->getNumSuccessors())) base = term->getBlockOperands().data(); } + +SuccessorRange::SuccessorRange(Operation *term) : SuccessorRange(nullptr, 0) { + if ((count = term->getNumSuccessors())) + base = term->getBlockOperands().data(); +} diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp index d5749fabc07..50e6eeec982 100644 --- a/mlir/lib/IR/PatternMatch.cpp +++ b/mlir/lib/IR/PatternMatch.cpp @@ -170,23 +170,6 @@ void PatternRewriter::cloneRegionBefore(Region ®ion, Block *before) { cloneRegionBefore(region, *before->getParent(), before->getIterator()); } -/// This method is used as the final notification hook for patterns that end -/// up modifying the pattern root in place, by changing its operands. This is -/// a minor efficiency win (it avoids creating a new operation and removing -/// the old one) but also often allows simpler code in the client. -/// -/// The opsToRemoveIfDead list is an optional list of nodes that the rewriter -/// should remove if they are dead at this point. -/// -void PatternRewriter::updatedRootInPlace(Operation *op, - ValueRange valuesToRemoveIfDead) { - // Notify the rewriter subclass that we're about to replace this root. - notifyRootUpdated(op); - - // TODO: Process the valuesToRemoveIfDead list, removing things and calling - // the notifyOperationRemoved hook in the process. -} - //===----------------------------------------------------------------------===// // PatternMatcher implementation //===----------------------------------------------------------------------===// |

