Skip to content

Commit 6023ba2

Browse files
[mlir] Migrate away from TypeRange(std::nullopt) (NFC) (#145246)
ArrayRef has a constructor that accepts std::nullopt. This constructor dates back to the days when we still had llvm::Optional. Since the use of std::nullopt outside the context of std::optional is kind of abuse and not intuitive to new comers, I would like to move away from the constructor and eventually remove it. One of the uses of std::nullopt is in a the constructors for TypeRange. This patch takes care of the migration where we need TypeRange() to facilitate perfect forwarding. Note that {} would be ambiguous for perfecting forwarding to work.
1 parent a17b5bc commit 6023ba2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void AffineLoopToGpuConverter::createLaunch(AffineForOp rootForOp,
245245
Location terminatorLoc = terminator.getLoc();
246246
terminator.erase();
247247
builder.setInsertionPointToEnd(innermostForOp.getBody());
248-
builder.create<gpu::TerminatorOp>(terminatorLoc, std::nullopt);
248+
builder.create<gpu::TerminatorOp>(terminatorLoc, TypeRange());
249249
launchOp.getBody().front().getOperations().splice(
250250
launchOp.getBody().front().begin(),
251251
innermostForOp.getBody()->getOperations());

mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ class FunctionCallPattern
839839
ConversionPatternRewriter &rewriter) const override {
840840
if (callOp.getNumResults() == 0) {
841841
auto newOp = rewriter.replaceOpWithNewOp<LLVM::CallOp>(
842-
callOp, std::nullopt, adaptor.getOperands(), callOp->getAttrs());
842+
callOp, TypeRange(), adaptor.getOperands(), callOp->getAttrs());
843843
newOp.getProperties().operandSegmentSizes = {
844844
static_cast<int32_t>(adaptor.getOperands().size()), 0};
845845
newOp.getProperties().op_bundle_sizes = rewriter.getDenseI32ArrayAttr({});

mlir/test/lib/Dialect/Test/TestPatterns.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ struct TestPassthroughInvalidOp : public ConversionPattern {
10081008
op->getOperand(it.index()).getType(), range)
10091009
.getResult());
10101010
}
1011-
rewriter.replaceOpWithNewOp<TestValidOp>(op, std::nullopt, flattened,
1011+
rewriter.replaceOpWithNewOp<TestValidOp>(op, TypeRange(), flattened,
10121012
std::nullopt);
10131013
return success();
10141014
}
@@ -1024,7 +1024,7 @@ struct TestDropAndReplaceInvalidOp : public ConversionPattern {
10241024
LogicalResult
10251025
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
10261026
ConversionPatternRewriter &rewriter) const final {
1027-
rewriter.replaceOpWithNewOp<TestValidOp>(op, std::nullopt, ValueRange(),
1027+
rewriter.replaceOpWithNewOp<TestValidOp>(op, TypeRange(), ValueRange(),
10281028
std::nullopt);
10291029
return success();
10301030
}

0 commit comments

Comments
 (0)