[PATCH] D80133: [mlir] Toy tutorial: insert terminators at the end of the loop during rewrite

Alex Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 09:07:39 PDT 2020


ftynse created this revision.
ftynse added reviewers: silvas, nicolasvasilache, mehdi_amini.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, jpienaar, rriddle.
Herald added a project: LLVM.
ftynse added a child revision: D80134: [mlir] DialectConversion: avoid double-free when rolling back op creation.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80133

Files:
  mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
  mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp


Index: mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
===================================================================
--- mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
+++ mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
@@ -73,7 +73,7 @@
       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)
Index: mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
===================================================================
--- mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
+++ mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
@@ -73,7 +73,7 @@
       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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80133.264646.patch
Type: text/x-patch
Size: 1064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/fe783c57/attachment.bin>


More information about the llvm-commits mailing list