-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang] fix some FIR verifiers that did not return expected failure #158686
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
Conversation
@llvm/pr-subscribers-flang-fir-hlfir Author: None (jeanPerier) ChangesSome Full diff: https://github.com/llvm/llvm-project/pull/158686.diff 2 Files Affected:
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 87f9899aa7879..31dacaee23fb0 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -1774,12 +1774,13 @@ llvm::LogicalResult fir::CoordinateOp::verify() {
return emitOpError("too many operands for len_param_index case");
}
if (eleTy != index.getOnType())
- emitOpError(
+ return emitOpError(
"len_param_index type not compatible with reference type");
return mlir::success();
} else if (auto index = mlir::dyn_cast<fir::FieldIndexOp>(defOp)) {
if (eleTy != index.getOnType())
- emitOpError("field_index type not compatible with reference type");
+ return emitOpError(
+ "field_index type not compatible with reference type");
if (auto recTy = mlir::dyn_cast<fir::RecordType>(eleTy)) {
eleTy = recTy.getType(index.getFieldName());
continue;
@@ -3406,26 +3407,30 @@ llvm::LogicalResult fir::SaveResultOp::verify() {
auto eleTy = resultType;
if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(resultType)) {
if (seqTy.getDimension() != shapeTyRank)
- emitOpError("shape operand must be provided and have the value rank "
- "when the value is a fir.array");
+ return emitOpError(
+ "shape operand must be provided and have the value rank "
+ "when the value is a fir.array");
eleTy = seqTy.getEleTy();
} else {
if (shapeTyRank != 0)
- emitOpError(
+ return emitOpError(
"shape operand should only be provided if the value is a fir.array");
}
if (auto recTy = mlir::dyn_cast<fir::RecordType>(eleTy)) {
if (recTy.getNumLenParams() != getTypeparams().size())
- emitOpError("length parameters number must match with the value type "
- "length parameters");
+ return emitOpError(
+ "length parameters number must match with the value type "
+ "length parameters");
} else if (auto charTy = mlir::dyn_cast<fir::CharacterType>(eleTy)) {
if (getTypeparams().size() > 1)
- emitOpError("no more than one length parameter must be provided for "
- "character value");
+ return emitOpError(
+ "no more than one length parameter must be provided for "
+ "character value");
} else {
if (!getTypeparams().empty())
- emitOpError("length parameters must not be provided for this value type");
+ return emitOpError(
+ "length parameters must not be provided for this value type");
}
return mlir::success();
diff --git a/flang/lib/Optimizer/Dialect/FortranVariableInterface.cpp b/flang/lib/Optimizer/Dialect/FortranVariableInterface.cpp
index f16072a90dfae..925276e1f86c4 100644
--- a/flang/lib/Optimizer/Dialect/FortranVariableInterface.cpp
+++ b/flang/lib/Optimizer/Dialect/FortranVariableInterface.cpp
@@ -53,8 +53,9 @@ fir::FortranVariableOpInterface::verifyDeclareLikeOpImpl(mlir::Value memref) {
shapeRank = shapeShiftType.getRank();
} else {
if (!sourceIsBoxValue)
- emitOpError("of array entity with a raw address base must have a "
- "shape operand that is a shape or shapeshift");
+ return emitOpError(
+ "of array entity with a raw address base must have a "
+ "shape operand that is a shape or shapeshift");
shapeRank = mlir::cast<fir::ShiftType>(shape.getType()).getRank();
}
@@ -62,8 +63,9 @@ fir::FortranVariableOpInterface::verifyDeclareLikeOpImpl(mlir::Value memref) {
if (!rank || *rank != shapeRank)
return emitOpError("has conflicting shape and base operand ranks");
} else if (!sourceIsBox) {
- emitOpError("of array entity with a raw address base must have a shape "
- "operand that is a shape or shapeshift");
+ return emitOpError(
+ "of array entity with a raw address base must have a shape "
+ "operand that is a shape or shapeshift");
}
}
return mlir::success();
|
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.
Nice catch. Thank you!
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.
Nice catch
Some
return
were missing beforeemitOpError
, leading the compiler to print an error and continue, leading to the same error to be raised again and again at each verifier pass without a proper abort.