[flang-commits] [flang] 540a76f - [flang] Convert assertion to a TODO
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Thu Jun 30 06:46:34 PDT 2022
Author: Valentin Clement
Date: 2022-06-30T15:46:24+02:00
New Revision: 540a76f07483bc202f48c01477e6efc87c79f7a5
URL: https://github.com/llvm/llvm-project/commit/540a76f07483bc202f48c01477e6efc87c79f7a5
DIFF: https://github.com/llvm/llvm-project/commit/540a76f07483bc202f48c01477e6efc87c79f7a5.diff
LOG: [flang] Convert assertion to a TODO
The original assertion is not necessarily correct since the shape
argument may involve a slice of an array (an expression) and not a whole
vector with constant length. In the presence of a slice operation, the
size must be computed (left as a TODO for now).
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D128894
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Added:
Modified:
flang/lib/Lower/IntrinsicCall.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index c8c4be6669681..c9aa91b2b6c5f 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -3492,10 +3492,10 @@ IntrinsicLibrary::genReshape(mlir::Type resultType,
assert(fir::BoxValue(shape).rank() == 1);
mlir::Type shapeTy = shape.getType();
mlir::Type shapeArrTy = fir::dyn_cast_ptrOrBoxEleTy(shapeTy);
- auto resultRank = shapeArrTy.cast<fir::SequenceType>().getShape();
+ auto resultRank = shapeArrTy.cast<fir::SequenceType>().getShape()[0];
- assert(resultRank[0] != fir::SequenceType::getUnknownExtent() &&
- "shape arg must have constant size");
+ if (resultRank == fir::SequenceType::getUnknownExtent())
+ TODO(loc, "RESHAPE intrinsic requires computing rank of result");
// Handle optional pad argument
mlir::Value pad = isStaticallyAbsent(args[2])
@@ -3510,7 +3510,7 @@ IntrinsicLibrary::genReshape(mlir::Type resultType,
: builder.createBox(loc, args[3]);
// Create mutable fir.box to be passed to the runtime for the result.
- mlir::Type type = builder.getVarLenSeqTy(resultType, resultRank[0]);
+ mlir::Type type = builder.getVarLenSeqTy(resultType, resultRank);
fir::MutableBoxValue resultMutableBox =
fir::factory::createTempMutableBox(builder, loc, type);
More information about the flang-commits
mailing list