mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 15:41:35 +08:00
[mlir][toy] Use make_early_inc_range when erasing ops during iteration (#146892)
Use `make_early_inc_range` when erasing operations from a block to make sure that the iterator is not invalidated. The previous implementation happened to work on a "normal" dialect conversion because some IR modifications are delayed. It no longer works with a One-Shot Dialect Conversion. The new One-Shot Dialect Conversion API is more similar to the normal rewriter API.
This commit is contained in:
committed by
GitHub
parent
522d743545
commit
34f124b06f
@@ -92,7 +92,7 @@ public:
|
||||
auto step = rewriter.create<arith::ConstantIndexOp>(loc, 1);
|
||||
auto loop =
|
||||
rewriter.create<scf::ForOp>(loc, lowerBound, upperBound, step);
|
||||
for (Operation &nested : *loop.getBody())
|
||||
for (Operation &nested : make_early_inc_range(*loop.getBody()))
|
||||
rewriter.eraseOp(&nested);
|
||||
loopIvs.push_back(loop.getInductionVar());
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
auto step = rewriter.create<arith::ConstantIndexOp>(loc, 1);
|
||||
auto loop =
|
||||
rewriter.create<scf::ForOp>(loc, lowerBound, upperBound, step);
|
||||
for (Operation &nested : *loop.getBody())
|
||||
for (Operation &nested : make_early_inc_range(*loop.getBody()))
|
||||
rewriter.eraseOp(&nested);
|
||||
loopIvs.push_back(loop.getInductionVar());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user