@@ -150,44 +150,16 @@ void RewriterBase::replaceOp(Operation *op, Operation *newOp) {
150
150
eraseOp (op);
151
151
}
152
152
153
- // / Returns the given block iterator if it lies within the block `b`.
154
- // / Otherwise, otherwise finds the ancestor of the given block iterator that
155
- // / lies within `b`. Returns and "empty" iterator if the latter fails.
156
- // /
157
- // / Note: This is a variant of Block::findAncestorOpInBlock that operates on
158
- // / block iterators instead of ops.
159
- static std::pair<Block *, Block::iterator>
160
- findAncestorIteratorInBlock (Block *b, Block *itBlock, Block::iterator it) {
161
- // Case 1: The iterator lies within the block.
162
- if (itBlock == b)
163
- return std::make_pair (itBlock, it);
164
-
165
- // Otherwise: Find ancestor iterator. Bail if we run out of parent ops.
166
- Operation *parentOp = itBlock->getParentOp ();
167
- if (!parentOp)
168
- return std::make_pair (static_cast <Block *>(nullptr ), Block::iterator ());
169
- Operation *op = b->findAncestorOpInBlock (*parentOp);
170
- if (!op)
171
- return std::make_pair (static_cast <Block *>(nullptr ), Block::iterator ());
172
- return std::make_pair (op->getBlock (), op->getIterator ());
173
- }
174
-
175
153
// / This method erases an operation that is known to have no uses. The uses of
176
154
// / the given operation *must* be known to be dead.
177
155
void RewriterBase::eraseOp (Operation *op) {
178
156
assert (op->use_empty () && " expected 'op' to have no uses" );
179
157
auto *rewriteListener = dyn_cast_if_present<Listener>(listener);
180
158
181
- // If the current insertion point is before/within the erased operation, we
182
- // need to adjust the insertion point to be after the operation.
183
- if (getInsertionBlock ()) {
184
- Block *insertionBlock;
185
- Block::iterator insertionPoint;
186
- std::tie (insertionBlock, insertionPoint) = findAncestorIteratorInBlock (
187
- op->getBlock (), getInsertionBlock (), getInsertionPoint ());
188
- if (insertionBlock && insertionPoint == op->getIterator ())
189
- setInsertionPointAfter (op);
190
- }
159
+ // If the current insertion point is before the erased operation, we adjust
160
+ // the insertion point to be after the operation.
161
+ if (getInsertionPoint () == op->getIterator ())
162
+ setInsertionPointAfter (op);
191
163
192
164
// Fast path: If no listener is attached, the op can be dropped in one go.
193
165
if (!rewriteListener) {
0 commit comments