@@ -1809,8 +1809,6 @@ void AffineForOp::build(OpBuilder &builder, OperationState &result,
18091809 " upper bound operand count does not match the affine map" );
18101810 assert (step > 0 && " step has to be a positive integer constant" );
18111811
1812- OpBuilder::InsertionGuard guard (builder);
1813-
18141812 // Set variadic segment sizes.
18151813 result.addAttribute (
18161814 getOperandSegmentSizeAttr (),
@@ -1839,11 +1837,12 @@ void AffineForOp::build(OpBuilder &builder, OperationState &result,
18391837 // Create a region and a block for the body. The argument of the region is
18401838 // the loop induction variable.
18411839 Region *bodyRegion = result.addRegion ();
1842- Block *bodyBlock = builder.createBlock (bodyRegion);
1840+ bodyRegion->push_back (new Block);
1841+ Block &bodyBlock = bodyRegion->front ();
18431842 Value inductionVar =
1844- bodyBlock-> addArgument (builder.getIndexType (), result.location );
1843+ bodyBlock. addArgument (builder.getIndexType (), result.location );
18451844 for (Value val : iterArgs)
1846- bodyBlock-> addArgument (val.getType (), val.getLoc ());
1845+ bodyBlock. addArgument (val.getType (), val.getLoc ());
18471846
18481847 // Create the default terminator if the builder is not provided and if the
18491848 // iteration arguments are not provided. Otherwise, leave this to the caller
@@ -1852,9 +1851,9 @@ void AffineForOp::build(OpBuilder &builder, OperationState &result,
18521851 ensureTerminator (*bodyRegion, builder, result.location );
18531852 } else if (bodyBuilder) {
18541853 OpBuilder::InsertionGuard guard (builder);
1855- builder.setInsertionPointToStart (bodyBlock);
1854+ builder.setInsertionPointToStart (& bodyBlock);
18561855 bodyBuilder (builder, result.location , inductionVar,
1857- bodyBlock-> getArguments ().drop_front ());
1856+ bodyBlock. getArguments ().drop_front ());
18581857 }
18591858}
18601859
@@ -2891,20 +2890,18 @@ void AffineIfOp::build(OpBuilder &builder, OperationState &result,
28912890 TypeRange resultTypes, IntegerSet set, ValueRange args,
28922891 bool withElseRegion) {
28932892 assert (resultTypes.empty () || withElseRegion);
2894- OpBuilder::InsertionGuard guard (builder);
2895-
28962893 result.addTypes (resultTypes);
28972894 result.addOperands (args);
28982895 result.addAttribute (getConditionAttrStrName (), IntegerSetAttr::get (set));
28992896
29002897 Region *thenRegion = result.addRegion ();
2901- builder. createBlock ( thenRegion);
2898+ thenRegion-> push_back ( new Block () );
29022899 if (resultTypes.empty ())
29032900 AffineIfOp::ensureTerminator (*thenRegion, builder, result.location );
29042901
29052902 Region *elseRegion = result.addRegion ();
29062903 if (withElseRegion) {
2907- builder. createBlock ( elseRegion);
2904+ elseRegion-> push_back ( new Block () );
29082905 if (resultTypes.empty ())
29092906 AffineIfOp::ensureTerminator (*elseRegion, builder, result.location );
29102907 }
@@ -3691,7 +3688,6 @@ void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
36913688 " expected upper bound maps to have as many inputs as upper bound "
36923689 " operands" );
36933690
3694- OpBuilder::InsertionGuard guard (builder);
36953691 result.addTypes (resultTypes);
36963692
36973693 // Convert the reductions to integer attributes.
@@ -3737,11 +3733,11 @@ void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
37373733
37383734 // Create a region and a block for the body.
37393735 auto *bodyRegion = result.addRegion ();
3740- Block *body = builder.createBlock (bodyRegion);
3741-
3736+ auto *body = new Block ();
37423737 // Add all the block arguments.
37433738 for (unsigned i = 0 , e = steps.size (); i < e; ++i)
37443739 body->addArgument (IndexType::get (builder.getContext ()), result.location );
3740+ bodyRegion->push_back (body);
37453741 if (resultTypes.empty ())
37463742 ensureTerminator (*bodyRegion, builder, result.location );
37473743}
0 commit comments