[flang-commits] [flang] 13ead00 - [Flang] Fix PowerPC build failure due to the deprecation of ArrayRef(std::nullopt_t) {}. (#147816)
via flang-commits
flang-commits at lists.llvm.org
Thu Jul 10 06:53:07 PDT 2025
Author: Daniel Chen
Date: 2025-07-10T09:53:03-04:00
New Revision: 13ead00049e2faea57dac2d9a43f2aef5bbe3370
URL: https://github.com/llvm/llvm-project/commit/13ead00049e2faea57dac2d9a43f2aef5bbe3370
DIFF: https://github.com/llvm/llvm-project/commit/13ead00049e2faea57dac2d9a43f2aef5bbe3370.diff
LOG: [Flang] Fix PowerPC build failure due to the deprecation of ArrayRef(std::nullopt_t) {}. (#147816)
Our local Flang build on PowerPC was broken as
```
llvm/flang/../mlir/include/mlir/IR/ValueRange.h:401:20: error: 'ArrayRef' is deprecated: Use {} or ArrayRef<T>() instead [-Werror,-Wdeprecated-declarations]
401 | : ValueRange(ArrayRef<Value>(std::forward<Arg>(arg))) {}
| ^
llvm/flang/lib/Optimizer/CodeGen/CodeGen.cpp:2243:53: note: in instantiation of function template specialization 'mlir::ValueRange::ValueRange<const std::nullopt_t &, void>' requested here
2243 | /*cstInteriorIndices=*/std::nullopt, fieldIndices,
| ^
llvm/include/llvm/ADT/ArrayRef.h:70:18: note: 'ArrayRef' has been explicitly marked deprecated here
70 | /*implicit*/ LLVM_DEPRECATED("Use {} or ArrayRef<T>() instead", "{}")
| ^
llvm/include/llvm/Support/Compiler.h:244:50: note: expanded from macro 'LLVM_DEPRECATED'
244 | #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
| ^
1 error generated.
```
This patch is to fix it.
Added:
Modified:
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 1bc981516e226..3bbc32f23bcfa 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -2239,17 +2239,18 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
getSubcomponentIndices(rebox, rebox.getBox(), operands, fieldIndices);
if (!rebox.getSubstr().empty())
substringOffset = operands[rebox.getSubstrOperandIndex()];
- base = genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero,
- /*cstInteriorIndices=*/std::nullopt, fieldIndices,
- substringOffset);
+ base =
+ genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero,
+ /*cstInteriorIndices=*/llvm::ArrayRef<mlir::Value>(),
+ fieldIndices, substringOffset);
}
if (rebox.getSlice().empty())
// 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,
- rewriter);
+ /*lbounds*/ llvm::ArrayRef<mlir::Value>(),
+ inputExtents, inputStrides, rewriter);
// The slice is of the form array(i:j:k)[%component]. Compute new extents
// and strides.
@@ -2297,8 +2298,8 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
}
}
return finalizeRebox(rebox, adaptor, destBoxTy, dest, base,
- /*lbounds*/ std::nullopt, slicedExtents, slicedStrides,
- rewriter);
+ /*lbounds*/ llvm::ArrayRef<mlir::Value>(),
+ slicedExtents, slicedStrides, rewriter);
}
/// Apply a new shape to the data described by a box given the base address,
@@ -3396,7 +3397,8 @@ static void genBrOp(A caseOp, mlir::Block *dest, std::optional<B> destOps,
if (destOps)
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, *destOps, dest);
else
- rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, std::nullopt, dest);
+ rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(
+ caseOp, llvm::ArrayRef<mlir::Value>(), 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..eca2c7f7c942f 100644
--- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
@@ -107,9 +107,11 @@ class EmboxConversion : public mlir::OpRewritePattern<fir::EmboxOp> {
shapeOpers.push_back(extVal);
}
auto xbox = rewriter.create<fir::cg::XEmboxOp>(
- 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,
+ llvm::ArrayRef<mlir::Value>(), llvm::ArrayRef<mlir::Value>(),
+ llvm::ArrayRef<mlir::Value>(), llvm::ArrayRef<mlir::Value>(),
+ embox.getTypeparams(), embox.getSourceBox(),
+ embox.getAllocatorIdxAttr());
LLVM_DEBUG(llvm::dbgs() << "rewriting " << embox << " to " << xbox << '\n');
rewriter.replaceOp(embox, xbox.getOperation()->getResults());
return mlir::success();
More information about the flang-commits
mailing list