diff --git a/mlir/lib/Conversion/ShapeToSCF/ShapeToSCF.cpp b/mlir/lib/Conversion/ShapeToSCF/ShapeToSCF.cpp --- a/mlir/lib/Conversion/ShapeToSCF/ShapeToSCF.cpp +++ b/mlir/lib/Conversion/ShapeToSCF/ShapeToSCF.cpp @@ -104,15 +104,14 @@ // Copy shape extents to stack-allocated memory. auto zeroVal = rewriter.create(loc, 0); auto oneVal = rewriter.create(loc, 1); - auto loop = rewriter.create(loc, zeroVal, rankVal, oneVal); - { - OpBuilder::InsertionGuard guard(rewriter); - rewriter.setInsertionPointToStart(loop.getBody()); - auto iVal = loop.getInductionVar(); - auto dimVal = rewriter.create(loc, tensorVal, iVal); - auto dimIntVal = rewriter.create(loc, dimVal, i64Ty); - rewriter.create(loc, dimIntVal, memVal, ValueRange{iVal}); - } + rewriter.create( + loc, zeroVal, rankVal, oneVal, llvm::None, + [&](OpBuilder &b, Location loc, Value iVal, ValueRange args) { + auto dimVal = rewriter.create(loc, tensorVal, iVal); + auto dimIntVal = rewriter.create(loc, dimVal, i64Ty); + rewriter.create(loc, dimIntVal, memVal, ValueRange{iVal}); + rewriter.create(loc); + }); // Load extents to tensor value. auto shapeIntVal = rewriter.create(loc, memVal);