[MLIR] Fix dialect conversion cancelRootUpdate
authorUday Bondhugula <uday@polymagelabs.com>
Sat, 3 Jul 2021 16:07:00 +0000 (21:37 +0530)
committerUday Bondhugula <uday@polymagelabs.com>
Tue, 6 Jul 2021 09:49:49 +0000 (15:19 +0530)
commit0c29f45ac9e8e67a6481c0810e2e335a12bf3877
tree625f1fa854cd9acb9f58d32b2a692d381052971e
parent17b701c43ca6459db020bff075b119f33a4a8ec5
[MLIR] Fix dialect conversion cancelRootUpdate

Fix dialect conversion ConversionPatternRewriter::cancelRootUpdate: the
erasure of operations here from the list of root update was off by one.
Should have been:
```
rootUpdates.erase(rootUpdates.begin() + (rootUpdates.rend() - it - 1));
```
instead of
```
rootUpdates.erase(rootUpdates.begin() + (rootUpdates.rend() - it));
```

or more directly:
```
rootUpdates.erase(it.base() - 1)
```

While on this, add an assertion to improve dev experience when a cancel is
called on an op on which a root update hasn't been started.

Differential Revision: https://reviews.llvm.org/D105397
mlir/lib/Transforms/Utils/DialectConversion.cpp