Skip to content

Commit 13ead00

Browse files
authored
[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.
1 parent d801b54 commit 13ead00

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

flang/lib/Optimizer/CodeGen/CodeGen.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,17 +2239,18 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
22392239
getSubcomponentIndices(rebox, rebox.getBox(), operands, fieldIndices);
22402240
if (!rebox.getSubstr().empty())
22412241
substringOffset = operands[rebox.getSubstrOperandIndex()];
2242-
base = genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero,
2243-
/*cstInteriorIndices=*/std::nullopt, fieldIndices,
2244-
substringOffset);
2242+
base =
2243+
genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero,
2244+
/*cstInteriorIndices=*/llvm::ArrayRef<mlir::Value>(),
2245+
fieldIndices, substringOffset);
22452246
}
22462247

22472248
if (rebox.getSlice().empty())
22482249
// The array section is of the form array[%component][substring], keep
22492250
// the input array extents and strides.
22502251
return finalizeRebox(rebox, adaptor, destBoxTy, dest, base,
2251-
/*lbounds*/ std::nullopt, inputExtents, inputStrides,
2252-
rewriter);
2252+
/*lbounds*/ llvm::ArrayRef<mlir::Value>(),
2253+
inputExtents, inputStrides, rewriter);
22532254

22542255
// The slice is of the form array(i:j:k)[%component]. Compute new extents
22552256
// and strides.
@@ -2297,8 +2298,8 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
22972298
}
22982299
}
22992300
return finalizeRebox(rebox, adaptor, destBoxTy, dest, base,
2300-
/*lbounds*/ std::nullopt, slicedExtents, slicedStrides,
2301-
rewriter);
2301+
/*lbounds*/ llvm::ArrayRef<mlir::Value>(),
2302+
slicedExtents, slicedStrides, rewriter);
23022303
}
23032304

23042305
/// 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,
33963397
if (destOps)
33973398
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, *destOps, dest);
33983399
else
3399-
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(caseOp, std::nullopt, dest);
3400+
rewriter.replaceOpWithNewOp<mlir::LLVM::BrOp>(
3401+
caseOp, llvm::ArrayRef<mlir::Value>(), dest);
34003402
}
34013403

34023404
static void genCaseLadderStep(mlir::Location loc, mlir::Value cmp,

flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ class EmboxConversion : public mlir::OpRewritePattern<fir::EmboxOp> {
107107
shapeOpers.push_back(extVal);
108108
}
109109
auto xbox = rewriter.create<fir::cg::XEmboxOp>(
110-
loc, embox.getType(), embox.getMemref(), shapeOpers, std::nullopt,
111-
std::nullopt, std::nullopt, std::nullopt, embox.getTypeparams(),
112-
embox.getSourceBox(), embox.getAllocatorIdxAttr());
110+
loc, embox.getType(), embox.getMemref(), shapeOpers,
111+
llvm::ArrayRef<mlir::Value>(), llvm::ArrayRef<mlir::Value>(),
112+
llvm::ArrayRef<mlir::Value>(), llvm::ArrayRef<mlir::Value>(),
113+
embox.getTypeparams(), embox.getSourceBox(),
114+
embox.getAllocatorIdxAttr());
113115
LLVM_DEBUG(llvm::dbgs() << "rewriting " << embox << " to " << xbox << '\n');
114116
rewriter.replaceOp(embox, xbox.getOperation()->getResults());
115117
return mlir::success();

0 commit comments

Comments
 (0)