@@ -1019,8 +1019,8 @@ struct RemoveConstantIfConditionWithRegion : public OpRewritePattern<OpTy> {
10191019// / Returns the init block on success, or nullptr on failure.
10201020// / Sets needsFree to indicate if the allocated memory requires deallocation.
10211021static std::unique_ptr<Block> createInitRegion (OpBuilder &builder, Location loc,
1022- Value var , StringRef varName,
1023- ValueRange bounds, Type varType,
1022+ Type varType , StringRef varName,
1023+ ValueRange bounds,
10241024 bool &needsFree) {
10251025 // Create init block with arguments: original value + bounds
10261026 SmallVector<Type> argTypes{varType};
@@ -1070,8 +1070,8 @@ static std::unique_ptr<Block> createInitRegion(OpBuilder &builder, Location loc,
10701070// / Returns the copy block on success, or nullptr on failure.
10711071// / TODO: Handle MappableType - it does not yet have a copy API.
10721072static std::unique_ptr<Block> createCopyRegion (OpBuilder &builder, Location loc,
1073- ValueRange bounds ,
1074- Type varType ) {
1073+ Type varType ,
1074+ ValueRange bounds ) {
10751075 // Create copy block with arguments: original value + privatized value +
10761076 // bounds
10771077 SmallVector<Type> copyArgTypes{varType, varType};
@@ -1114,9 +1114,9 @@ static std::unique_ptr<Block> createCopyRegion(OpBuilder &builder, Location loc,
11141114// / Create and populate a destroy region for privatization recipes.
11151115// / Returns the destroy block on success, or nullptr if not needed.
11161116static std::unique_ptr<Block> createDestroyRegion (OpBuilder &builder,
1117- Location loc, Value allocRes ,
1118- ValueRange bounds ,
1119- Type varType ) {
1117+ Location loc, Type varType ,
1118+ Value allocRes ,
1119+ ValueRange bounds ) {
11201120 // Create destroy block with arguments: original value + privatized value +
11211121 // bounds
11221122 SmallVector<Type> destroyArgTypes{varType, varType};
@@ -1199,7 +1199,7 @@ LogicalResult acc::PrivateRecipeOp::verifyRegions() {
11991199
12001200std::optional<PrivateRecipeOp>
12011201PrivateRecipeOp::createAndPopulate (OpBuilder &builder, Location loc,
1202- StringRef recipeName, Value var ,
1202+ StringRef recipeName, Type varType ,
12031203 StringRef varName, ValueRange bounds) {
12041204
12051205 // Check if a symbol with this name already exists in the symbol table.
@@ -1210,8 +1210,6 @@ PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
12101210 parentOp, mlir::StringAttr::get (builder.getContext (), varName)))
12111211 return std::nullopt ;
12121212
1213- Type varType = var.getType ();
1214-
12151213 // First, validate that we can handle this variable type
12161214 bool isMappable = isa<MappableType>(varType);
12171215 bool isPointerLike = isa<PointerLikeType>(varType);
@@ -1228,7 +1226,7 @@ PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
12281226
12291227 bool needsFree = false ;
12301228 auto initBlock =
1231- createInitRegion (builder, loc, var , varName, bounds, varType , needsFree);
1229+ createInitRegion (builder, loc, varType , varName, bounds, needsFree);
12321230 if (!initBlock)
12331231 return std::nullopt ;
12341232
@@ -1239,7 +1237,7 @@ PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
12391237 auto yieldOp = cast<acc::YieldOp>(initBlock->getTerminator ());
12401238 Value allocRes = yieldOp.getOperand (0 );
12411239
1242- destroyBlock = createDestroyRegion (builder, loc, allocRes, bounds, varType );
1240+ destroyBlock = createDestroyRegion (builder, loc, varType, allocRes, bounds );
12431241 if (!destroyBlock)
12441242 return std::nullopt ;
12451243 }
@@ -1289,7 +1287,7 @@ LogicalResult acc::FirstprivateRecipeOp::verifyRegions() {
12891287
12901288std::optional<FirstprivateRecipeOp>
12911289FirstprivateRecipeOp::createAndPopulate (OpBuilder &builder, Location loc,
1292- StringRef recipeName, Value var ,
1290+ StringRef recipeName, Type varType ,
12931291 StringRef varName, ValueRange bounds) {
12941292
12951293 // Check if a symbol with this name already exists in the symbol table.
@@ -1300,8 +1298,6 @@ FirstprivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
13001298 parentOp, mlir::StringAttr::get (builder.getContext (), varName)))
13011299 return std::nullopt ;
13021300
1303- Type varType = var.getType ();
1304-
13051301 // First, validate that we can handle this variable type
13061302 bool isMappable = isa<MappableType>(varType);
13071303 bool isPointerLike = isa<PointerLikeType>(varType);
@@ -1318,11 +1314,11 @@ FirstprivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
13181314
13191315 bool needsFree = false ;
13201316 auto initBlock =
1321- createInitRegion (builder, loc, var , varName, bounds, varType , needsFree);
1317+ createInitRegion (builder, loc, varType , varName, bounds, needsFree);
13221318 if (!initBlock)
13231319 return std::nullopt ;
13241320
1325- auto copyBlock = createCopyRegion (builder, loc, bounds, varType );
1321+ auto copyBlock = createCopyRegion (builder, loc, varType, bounds );
13261322 if (!copyBlock)
13271323 return std::nullopt ;
13281324
@@ -1333,7 +1329,7 @@ FirstprivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
13331329 auto yieldOp = cast<acc::YieldOp>(initBlock->getTerminator ());
13341330 Value allocRes = yieldOp.getOperand (0 );
13351331
1336- destroyBlock = createDestroyRegion (builder, loc, allocRes, bounds, varType );
1332+ destroyBlock = createDestroyRegion (builder, loc, varType, allocRes, bounds );
13371333 if (!destroyBlock)
13381334 return std::nullopt ;
13391335 }
0 commit comments