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