-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[Flang] Fix PowerPC build failure due to the deprecation of ArrayRef(std::nullopt_t) {}. #147816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…std::nullopt_t) {}.
@llvm/pr-subscribers-flang-fir-hlfir Author: Daniel Chen (DanielCChen) ChangesOur local Flang build was broken as
This patch is to fix it. Full diff: https://github.com/llvm/llvm-project/pull/147816.diff 2 Files Affected:
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();
|
@llvm/pr-subscribers-flang-codegen Author: Daniel Chen (DanielCChen) ChangesOur local Flang build was broken as
This patch is to fix it. Full diff: https://github.com/llvm/llvm-project/pull/147816.diff 2 Files Affected:
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();
|
substringOffset); | ||
base = | ||
genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero, | ||
/*cstInteriorIndices=*/llvm::ArrayRef<mlir::Value>(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer {}
vs llvm::ArrayRef<mlir::Value>()
- do you see any benefit to use more verbose version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more verbose version would provide a bit more typing information
The {}
is more for initialization. That being said, I am OK to change to it if you think it fits better as it indeed more aligns with the original std::nullopt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that we do not have too many entries of ArrayRef<mlir::Value>()
or ArrayRef<mlir::Value>{}
in Flang code, so probably {}
is a more common style, and we should stick to it. But it is not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Will change to it.
substringOffset); | ||
base = | ||
genBoxOffsetGep(rewriter, loc, base, llvmBaseObjectType, zero, | ||
/*cstInteriorIndices=*/llvm::ArrayRef<mlir::Value>(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that we do not have too many entries of ArrayRef<mlir::Value>()
or ArrayRef<mlir::Value>{}
in Flang code, so probably {}
is a more common style, and we should stick to it. But it is not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
@vzakhari It seems
|
I see. Thanks for trying! |
Our local Flang build on PowerPC was broken as
This patch is to fix it.