diff options
| author | Jessica Clarke <jrtc27@jrtc27.com> | 2025-07-30 17:10:46 +0100 |
|---|---|---|
| committer | Jessica Clarke <jrtc27@jrtc27.com> | 2025-07-30 17:10:46 +0100 |
| commit | 66393c8ec645d9121f2b3e53708b0379a113aa02 (patch) | |
| tree | f2a740bc8ada2dde8506ea87bb6014a9b3722433 /mlir/lib/IR/PatternMatch.cpp | |
| parent | 7e3a1d92899336f57a6af737c9641468a1dd19b3 (diff) | |
| parent | 3e93964b896023b1006d3c878effb68203d4d8dd (diff) | |
Created using spr 1.3.5
Diffstat (limited to 'mlir/lib/IR/PatternMatch.cpp')
| -rw-r--r-- | mlir/lib/IR/PatternMatch.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp index 1e6084822a99..9332f55bd939 100644 --- a/mlir/lib/IR/PatternMatch.cpp +++ b/mlir/lib/IR/PatternMatch.cpp @@ -7,8 +7,6 @@ //===----------------------------------------------------------------------===// #include "mlir/IR/PatternMatch.h" -#include "mlir/Config/mlir-config.h" -#include "mlir/IR/IRMapping.h" #include "mlir/IR/Iterators.h" #include "mlir/IR/RegionKindInterface.h" #include "llvm/ADT/SmallPtrSet.h" @@ -158,6 +156,11 @@ void RewriterBase::eraseOp(Operation *op) { assert(op->use_empty() && "expected 'op' to have no uses"); auto *rewriteListener = dyn_cast_if_present<Listener>(listener); + // If the current insertion point is before the erased operation, we adjust + // the insertion point to be after the operation. + if (getInsertionPoint() == op->getIterator()) + setInsertionPointAfter(op); + // Fast path: If no listener is attached, the op can be dropped in one go. if (!rewriteListener) { op->erase(); @@ -322,6 +325,11 @@ void RewriterBase::inlineBlockBefore(Block *source, Block *dest, moveOpBefore(&source->front(), dest, before); } + // If the current insertion point is within the source block, adjust the + // insertion point to the destination block. + if (getInsertionBlock() == source) + setInsertionPoint(dest, getInsertionPoint()); + // Erase the source block. assert(source->empty() && "expected 'source' to be empty"); eraseBlock(source); |
