[Mlir-commits] [mlir] [mlir] Use `OpBuilder::createBlock` in op builders and patterns (PR #82770)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Fri Feb 23 06:32:53 PST 2024


================
@@ -275,14 +275,13 @@ GenericOp makeTransposeOp(OpBuilder &b, Location loc, Value inputTensor,
   auto transposeOp =
       b.create<GenericOp>(loc, resultTensorType, inputTensor, outputTensor,
                           indexingMaps, iteratorTypes);
-  Region &body = transposeOp.getRegion();
-  body.push_back(new Block());
-  body.front().addArguments({elementType, elementType}, {loc, loc});
 
   // Create the body of the transpose operation.
   OpBuilder::InsertionGuard g(b);
-  b.setInsertionPointToEnd(&body.front());
-  b.create<YieldOp>(loc, transposeOp.getRegion().front().getArgument(0));
+  Region &body = transposeOp.getRegion();
+  Block *bodyBlock = b.createBlock(&body);
+  bodyBlock->addArguments({elementType, elementType}, {loc, loc});
----------------
ftynse wrote:

Shouldn't this go through the rewriter (IIRC, there is an overload of `createBlock` that takes a list of arguments).

https://github.com/llvm/llvm-project/pull/82770


More information about the Mlir-commits mailing list