Skip to content

Commit 151fffc

Browse files
[flang] Migrate away from ArrayRef(std::nullopt_t) (#149454)
ArrayRef(std::nullopt_t) has been deprecated. This patch replaces std::nullopt with mlir::TypeRange{} or mlir::ValueRange{} as appropriate.
1 parent fdce69a commit 151fffc

File tree

13 files changed

+40
-35
lines changed

13 files changed

+40
-35
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
14661466
assert(falseTarget && "missing conditional branch false block");
14671467
mlir::Location loc = toLocation();
14681468
mlir::Value bcc = builder->createConvert(loc, builder->getI1Type(), cond);
1469-
builder->create<mlir::cf::CondBranchOp>(loc, bcc, trueTarget, std::nullopt,
1470-
falseTarget, std::nullopt);
1469+
builder->create<mlir::cf::CondBranchOp>(loc, bcc, trueTarget,
1470+
mlir::ValueRange{}, falseTarget,
1471+
mlir::ValueRange{});
14711472
}
14721473
void genConditionalBranch(mlir::Value cond,
14731474
Fortran::lower::pft::Evaluation *trueTarget,
@@ -2556,8 +2557,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
25562557
builder->setInsertionPointToEnd(loopWrapperOp.getBody());
25572558
auto loopOp = builder->create<fir::DoConcurrentLoopOp>(
25582559
loc, nestLBs, nestUBs, nestSts, /*loopAnnotation=*/nullptr,
2559-
/*local_vars=*/std::nullopt,
2560-
/*local_syms=*/nullptr, /*reduce_vars=*/std::nullopt,
2560+
/*local_vars=*/mlir::ValueRange{},
2561+
/*local_syms=*/nullptr, /*reduce_vars=*/mlir::ValueRange{},
25612562
/*reduce_byref=*/nullptr, /*reduce_syms=*/nullptr,
25622563
/*reduce_attrs=*/nullptr);
25632564

@@ -3810,9 +3811,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
38103811
mlir::Block *selectCaseBlock = insertBlock(blockList[0]);
38113812
mlir::Block *assumedSizeBlock =
38123813
rankStarBlock ? rankStarBlock : defaultBlock;
3813-
builder->create<mlir::cf::CondBranchOp>(loc, isAssumedSize,
3814-
assumedSizeBlock, std::nullopt,
3815-
selectCaseBlock, std::nullopt);
3814+
builder->create<mlir::cf::CondBranchOp>(
3815+
loc, isAssumedSize, assumedSizeBlock, mlir::ValueRange{},
3816+
selectCaseBlock, mlir::ValueRange{});
38163817
startBlock(selectCaseBlock);
38173818
}
38183819
// Create fir.select_case for the other rank cases.

flang/lib/Lower/ConvertConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ createStringLitOp(fir::FirOpBuilder &builder, mlir::Location loc,
303303
mlir::NamedAttribute sizeAttr(sizeTag, builder.getI64IntegerAttr(len));
304304
llvm::SmallVector<mlir::NamedAttribute> attrs = {dataAttr, sizeAttr};
305305
return builder.create<fir::StringLitOp>(
306-
loc, llvm::ArrayRef<mlir::Type>{type}, std::nullopt, attrs);
306+
loc, llvm::ArrayRef<mlir::Type>{type}, mlir::ValueRange{}, attrs);
307307
}
308308
}
309309

flang/lib/Lower/ConvertExpr.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,9 @@ class ScalarExprLowering {
10031003
},
10041004
[&](const fir::MutableBoxValue &toBox) {
10051005
if (toBox.isPointer()) {
1006-
Fortran::lower::associateMutableBox(converter, loc, toBox, expr,
1007-
/*lbounds=*/std::nullopt,
1008-
stmtCtx);
1006+
Fortran::lower::associateMutableBox(
1007+
converter, loc, toBox, expr,
1008+
/*lbounds=*/mlir::ValueRange{}, stmtCtx);
10091009
return;
10101010
}
10111011
// For allocatable components, a deep copy is needed.
@@ -3604,8 +3604,9 @@ class ArrayExprLowering {
36043604
mlir::Value castTo =
36053605
builder.createConvert(loc, fir::HeapType::get(seqTy), load);
36063606
mlir::Value shapeOp = builder.genShape(loc, shape);
3607-
return builder.create<fir::ArrayLoadOp>(
3608-
loc, seqTy, castTo, shapeOp, /*slice=*/mlir::Value{}, std::nullopt);
3607+
return builder.create<fir::ArrayLoadOp>(loc, seqTy, castTo, shapeOp,
3608+
/*slice=*/mlir::Value{},
3609+
mlir::ValueRange{});
36093610
};
36103611
// Custom lowering of the element store to deal with the extra indirection
36113612
// to the lazy allocated buffer.
@@ -4207,7 +4208,7 @@ class ArrayExprLowering {
42074208
auto addr =
42084209
builder->create<fir::ArrayCoorOp>(loc, eleRefTy, tmp, shape,
42094210
/*slice=*/mlir::Value{}, indices,
4210-
/*typeParams=*/std::nullopt);
4211+
/*typeParams=*/mlir::ValueRange{});
42114212
auto load = builder->create<fir::LoadOp>(loc, addr);
42124213
return builder->createConvert(loc, i1Ty, load);
42134214
};
@@ -4522,17 +4523,18 @@ class ArrayExprLowering {
45224523
fir::isRecordWithAllocatableMember(eleTy))
45234524
TODO(loc, "creating an array temp where the element type has "
45244525
"allocatable members");
4525-
mlir::Value temp = !seqTy.hasDynamicExtents()
4526-
? builder.create<fir::AllocMemOp>(loc, type)
4527-
: builder.create<fir::AllocMemOp>(
4528-
loc, type, ".array.expr", std::nullopt, shape);
4526+
mlir::Value temp =
4527+
!seqTy.hasDynamicExtents()
4528+
? builder.create<fir::AllocMemOp>(loc, type)
4529+
: builder.create<fir::AllocMemOp>(loc, type, ".array.expr",
4530+
mlir::ValueRange{}, shape);
45294531
fir::FirOpBuilder *bldr = &converter.getFirOpBuilder();
45304532
stmtCtx.attachCleanup(
45314533
[bldr, loc, temp]() { bldr->create<fir::FreeMemOp>(loc, temp); });
45324534
mlir::Value shapeOp = genShapeOp(shape);
45334535
return builder.create<fir::ArrayLoadOp>(loc, seqTy, temp, shapeOp,
45344536
/*slice=*/mlir::Value{},
4535-
std::nullopt);
4537+
mlir::ValueRange{});
45364538
}
45374539

45384540
static fir::ShapeOp genShapeOp(mlir::Location loc, fir::FirOpBuilder &builder,
@@ -6483,7 +6485,7 @@ class ArrayExprLowering {
64836485
mlir::Value initBuffSz =
64846486
builder.createIntegerConstant(loc, idxTy, clInitialBufferSize);
64856487
mem = builder.create<fir::AllocMemOp>(
6486-
loc, eleTy, /*typeparams=*/std::nullopt, initBuffSz);
6488+
loc, eleTy, /*typeparams=*/mlir::ValueRange{}, initBuffSz);
64876489
builder.create<fir::StoreOp>(loc, initBuffSz, buffSize);
64886490
}
64896491
} else {

flang/lib/Lower/Runtime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void Fortran::lower::genFailImageStatement(
134134
mlir::Location loc = converter.getCurrentLocation();
135135
mlir::func::FuncOp callee =
136136
fir::runtime::getRuntimeFunc<mkRTKey(FailImageStatement)>(loc, builder);
137-
builder.create<fir::CallOp>(loc, callee, std::nullopt);
137+
builder.create<fir::CallOp>(loc, callee, mlir::ValueRange{});
138138
genUnreachable(builder, loc);
139139
}
140140

@@ -199,7 +199,7 @@ void Fortran::lower::genPauseStatement(
199199
mlir::Location loc = converter.getCurrentLocation();
200200
mlir::func::FuncOp callee =
201201
fir::runtime::getRuntimeFunc<mkRTKey(PauseStatement)>(loc, builder);
202-
builder.create<fir::CallOp>(loc, callee, std::nullopt);
202+
builder.create<fir::CallOp>(loc, callee, mlir::ValueRange{});
203203
}
204204

205205
void Fortran::lower::genPointerAssociate(fir::FirOpBuilder &builder,

flang/lib/Lower/VectorSubscripts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class VectorSubscriptBoxBuilder {
122122
TODO(loc, "threading length parameters in field index op");
123123
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
124124
componentPath.emplace_back(builder.create<fir::FieldIndexOp>(
125-
loc, fldTy, componentName, recTy, /*typeParams*/ std::nullopt));
125+
loc, fldTy, componentName, recTy, /*typeParams=*/mlir::ValueRange{}));
126126
return fir::unwrapSequenceType(recTy.getType(componentName));
127127
}
128128

flang/lib/Optimizer/Builder/FIRBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ fir::StringLitOp fir::FirOpBuilder::createStringLitOp(mlir::Location loc,
620620
mlir::NamedAttribute sizeAttr(sizeTag, getI64IntegerAttr(data.size()));
621621
llvm::SmallVector<mlir::NamedAttribute> attrs{dataAttr, sizeAttr};
622622
return create<fir::StringLitOp>(loc, llvm::ArrayRef<mlir::Type>{type},
623-
std::nullopt, attrs);
623+
mlir::ValueRange{}, attrs);
624624
}
625625

626626
mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,

flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ mlir::Value fir::runtime::genCpuTime(fir::FirOpBuilder &builder,
5959
mlir::Location loc) {
6060
mlir::func::FuncOp func =
6161
fir::runtime::getRuntimeFunc<mkRTKey(CpuTime)>(loc, builder);
62-
return builder.create<fir::CallOp>(loc, func, std::nullopt).getResult(0);
62+
return builder.create<fir::CallOp>(loc, func, mlir::ValueRange{})
63+
.getResult(0);
6364
}
6465

6566
void fir::runtime::genDateAndTime(fir::FirOpBuilder &builder,
@@ -280,7 +281,8 @@ void fir::runtime::genRename(fir::FirOpBuilder &builder, mlir::Location loc,
280281
mlir::Value fir::runtime::genTime(fir::FirOpBuilder &builder,
281282
mlir::Location loc) {
282283
auto func = fir::runtime::getRuntimeFunc<mkRTKey(time)>(loc, builder);
283-
return builder.create<fir::CallOp>(loc, func, std::nullopt).getResult(0);
284+
return builder.create<fir::CallOp>(loc, func, mlir::ValueRange{})
285+
.getResult(0);
284286
}
285287

286288
/// generate runtime call to transfer intrinsic with no size argument

flang/lib/Optimizer/Builder/Runtime/Stop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void fir::runtime::genExit(fir::FirOpBuilder &builder, mlir::Location loc,
2525
void fir::runtime::genAbort(fir::FirOpBuilder &builder, mlir::Location loc) {
2626
mlir::func::FuncOp abortFunc =
2727
fir::runtime::getRuntimeFunc<mkRTKey(Abort)>(loc, builder);
28-
builder.create<fir::CallOp>(loc, abortFunc, std::nullopt);
28+
builder.create<fir::CallOp>(loc, abortFunc, mlir::ValueRange{});
2929
}
3030

3131
void fir::runtime::genReportFatalUserError(fir::FirOpBuilder &builder,

flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void OrderedAssignmentRewriter::pre(hlfir::ForallMaskOp forallMaskOp) {
405405
mlir::Location loc = forallMaskOp.getLoc();
406406
mlir::Value mask = generateYieldedScalarValue(forallMaskOp.getMaskRegion(),
407407
builder.getI1Type());
408-
auto ifOp = builder.create<fir::IfOp>(loc, std::nullopt, mask, false);
408+
auto ifOp = builder.create<fir::IfOp>(loc, mlir::TypeRange{}, mask, false);
409409
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
410410
constructStack.push_back(ifOp);
411411
}
@@ -530,7 +530,7 @@ void OrderedAssignmentRewriter::generateMaskIfOp(mlir::Value cdt) {
530530
mlir::Location loc = cdt.getLoc();
531531
cdt = hlfir::loadTrivialScalar(loc, builder, hlfir::Entity{cdt});
532532
cdt = builder.createConvert(loc, builder.getI1Type(), cdt);
533-
auto ifOp = builder.create<fir::IfOp>(cdt.getLoc(), std::nullopt, cdt,
533+
auto ifOp = builder.create<fir::IfOp>(cdt.getLoc(), mlir::TypeRange{}, cdt,
534534
/*withElseRegion=*/false);
535535
constructStack.push_back(ifOp.getOperation());
536536
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());

flang/lib/Optimizer/Transforms/MemoryUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void AllocaReplaceImpl::genIndirectDeallocation(
222222
rewriter.create<fir::ConvertOp>(loc, intPtrTy, ptrVal);
223223
mlir::Value isAllocated = rewriter.create<mlir::arith::CmpIOp>(
224224
loc, mlir::arith::CmpIPredicate::ne, ptrToInt, c0);
225-
auto ifOp = rewriter.create<fir::IfOp>(loc, std::nullopt, isAllocated,
225+
auto ifOp = rewriter.create<fir::IfOp>(loc, mlir::TypeRange{}, isAllocated,
226226
/*withElseRegion=*/false);
227227
rewriter.setInsertionPointToStart(&ifOp.getThenRegion().front());
228228
mlir::Value cast = fir::factory::createConvert(

0 commit comments

Comments
 (0)