From: Alex Zinenko Date: Wed, 20 May 2020 13:59:44 +0000 (+0200) Subject: [mlir] Toy tutorial: insert terminators at the end of the loop during rewrite X-Git-Tag: llvmorg-12-init~5543 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a655144f57f8b6a9d5f4ab42b425b1f284353487;p=platform%2Fupstream%2Fllvm.git [mlir] Toy tutorial: insert terminators at the end of the loop during rewrite When creating temporary `scf.for` loops in `toy.print` lowering, the block insertion point was erronously set up to the beginning of the block rather than to its end, contradicting the comment just above the insertion point change. The code was nevertheless operational because `scf.for` was setting up its `scf.yield` terminator in an opaque to the pattern rewriting infrastructure way. Now that it is about to change, the problem would have been exposed and lead to conversion failures. Differential Revision: https://reviews.llvm.org/D80133 --- diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index 58458ff..c6c49ec 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -73,7 +73,7 @@ public: loopIvs.push_back(loop.getInductionVar()); // Terminate the loop body. - rewriter.setInsertionPointToStart(loop.getBody()); + rewriter.setInsertionPointToEnd(loop.getBody()); // Insert a newline after each of the inner dimensions of the shape. if (i != e - 1) diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index 58458ff..c6c49ec 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -73,7 +73,7 @@ public: loopIvs.push_back(loop.getInductionVar()); // Terminate the loop body. - rewriter.setInsertionPointToStart(loop.getBody()); + rewriter.setInsertionPointToEnd(loop.getBody()); // Insert a newline after each of the inner dimensions of the shape. if (i != e - 1)