@@ -648,6 +648,8 @@ void LaunchOp::build(OpBuilder &builder, OperationState &result,
648
648
TypeRange workgroupAttributions,
649
649
TypeRange privateAttributions, Value clusterSizeX,
650
650
Value clusterSizeY, Value clusterSizeZ) {
651
+ OpBuilder::InsertionGuard g (builder);
652
+
651
653
// Add a WorkGroup attribution attribute. This attribute is required to
652
654
// identify private attributions in the list of block argguments.
653
655
result.addAttribute (getNumWorkgroupAttributionsAttrName (),
@@ -674,7 +676,7 @@ void LaunchOp::build(OpBuilder &builder, OperationState &result,
674
676
// attributions, where the first kNumConfigRegionAttributes arguments have
675
677
// `index` type and the rest have the same types as the data operands.
676
678
Region *kernelRegion = result.addRegion ();
677
- Block *body = new Block ( );
679
+ Block *body = builder. createBlock (kernelRegion );
678
680
// TODO: Allow passing in proper locations here.
679
681
for (unsigned i = 0 ; i < kNumConfigRegionAttributes ; ++i)
680
682
body->addArgument (builder.getIndexType (), result.location );
@@ -683,7 +685,6 @@ void LaunchOp::build(OpBuilder &builder, OperationState &result,
683
685
body->addArgument (argTy, result.location );
684
686
for (Type argTy : privateAttributions)
685
687
body->addArgument (argTy, result.location );
686
- kernelRegion->push_back (body);
687
688
// Fill OperandSegmentSize Attribute.
688
689
SmallVector<int32_t , 11 > segmentSizes (11 , 1 );
689
690
segmentSizes.front () = asyncDependencies.size ();
@@ -1325,6 +1326,8 @@ void GPUFuncOp::build(OpBuilder &builder, OperationState &result,
1325
1326
TypeRange workgroupAttributions,
1326
1327
TypeRange privateAttributions,
1327
1328
ArrayRef<NamedAttribute> attrs) {
1329
+ OpBuilder::InsertionGuard g (builder);
1330
+
1328
1331
result.addAttribute (SymbolTable::getSymbolAttrName (),
1329
1332
builder.getStringAttr (name));
1330
1333
result.addAttribute (getFunctionTypeAttrName (result.name ),
@@ -1333,7 +1336,7 @@ void GPUFuncOp::build(OpBuilder &builder, OperationState &result,
1333
1336
builder.getI64IntegerAttr (workgroupAttributions.size ()));
1334
1337
result.addAttributes (attrs);
1335
1338
Region *body = result.addRegion ();
1336
- Block *entryBlock = new Block ;
1339
+ Block *entryBlock = builder. createBlock (body) ;
1337
1340
1338
1341
// TODO: Allow passing in proper locations here.
1339
1342
for (Type argTy : type.getInputs ())
@@ -1342,8 +1345,6 @@ void GPUFuncOp::build(OpBuilder &builder, OperationState &result,
1342
1345
entryBlock->addArgument (argTy, result.location );
1343
1346
for (Type argTy : privateAttributions)
1344
1347
entryBlock->addArgument (argTy, result.location );
1345
-
1346
- body->getBlocks ().push_back (entryBlock);
1347
1348
}
1348
1349
1349
1350
// / Parses a GPU function memory attribution.
0 commit comments