From 86b7f2f9668b88b675e6f195b7d1933fc7aef874 Mon Sep 17 00:00:00 2001 From: Tom Eccles Date: Thu, 10 Jul 2025 10:13:06 +0000 Subject: [PATCH 1/2] [flang] Fix deprecation warning I started getting deprecation warnings from operations constructors which seem to be doing implicit construction of mlir::ValueRange from a std::nullopt by relying on implicit conversion from std::nullopt into llvm::ArrayRef. ArrayRef{std::nullopt} is what has been deprecated. --- flang/lib/Optimizer/CodeGen/CodeGen.cpp | 8 ++++---- flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp index 1bc981516e226..2fe726cbb00e8 100644 --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -2240,7 +2240,7 @@ struct XReboxOpConversion : public EmboxCommonConversion { if (!rebox.getSubstr().empty()) substringOffset = operands[rebox.getSubstrOperandIndex()]; base = genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero, - /*cstInteriorIndices=*/std::nullopt, fieldIndices, + /*cstInteriorIndices=*/{}, fieldIndices, substringOffset); } @@ -2248,7 +2248,7 @@ struct XReboxOpConversion : public EmboxCommonConversion { // The array section is of the form array[%component][substring], keep // the input array extents and strides. return finalizeRebox(rebox, adaptor, destBoxTy, dest, base, - /*lbounds*/ std::nullopt, inputExtents, inputStrides, + /*lbounds*/ {}, inputExtents, inputStrides, rewriter); // The slice is of the form array(i:j:k)[%component]. Compute new extents @@ -2297,7 +2297,7 @@ struct XReboxOpConversion : public EmboxCommonConversion { } } return finalizeRebox(rebox, adaptor, destBoxTy, dest, base, - /*lbounds*/ std::nullopt, slicedExtents, slicedStrides, + /*lbounds*/ {}, slicedExtents, slicedStrides, rewriter); } @@ -3396,7 +3396,7 @@ static void genBrOp(A caseOp, mlir::Block *dest, std::optional destOps, if (destOps) rewriter.replaceOpWithNewOp(caseOp, *destOps, dest); else - rewriter.replaceOpWithNewOp(caseOp, std::nullopt, dest); + rewriter.replaceOpWithNewOp(caseOp, B{}, dest); } static void genCaseLadderStep(mlir::Location loc, mlir::Value cmp, diff --git a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp index d09d7d397e8b7..b60ac11c7795a 100644 --- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp @@ -107,9 +107,10 @@ class EmboxConversion : public mlir::OpRewritePattern { shapeOpers.push_back(extVal); } auto xbox = rewriter.create( - loc, embox.getType(), embox.getMemref(), shapeOpers, std::nullopt, - std::nullopt, std::nullopt, std::nullopt, embox.getTypeparams(), - embox.getSourceBox(), embox.getAllocatorIdxAttr()); + loc, embox.getType(), embox.getMemref(), shapeOpers, mlir::ValueRange{}, + mlir::ValueRange{}, mlir::ValueRange{}, mlir::ValueRange{}, + embox.getTypeparams(), embox.getSourceBox(), + embox.getAllocatorIdxAttr()); LLVM_DEBUG(llvm::dbgs() << "rewriting " << embox << " to " << xbox << '\n'); rewriter.replaceOp(embox, xbox.getOperation()->getResults()); return mlir::success(); From ef8ca4aafc6905efc85fa19edd3d806dfa4a0eaa Mon Sep 17 00:00:00 2001 From: Tom Eccles Date: Thu, 10 Jul 2025 14:51:00 +0000 Subject: [PATCH 2/2] Clang format This is what I get for trying to use the web interface for the merge conflicts. --- flang/lib/Optimizer/CodeGen/CodeGen.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp index e860632d325f0..2fe726cbb00e8 100644 --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -2299,7 +2299,6 @@ struct XReboxOpConversion : public EmboxCommonConversion { return finalizeRebox(rebox, adaptor, destBoxTy, dest, base, /*lbounds*/ {}, slicedExtents, slicedStrides, rewriter); - } /// Apply a new shape to the data described by a box given the base address,