Skip to content

Commit 540a76f

Browse files
[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 <[email protected]>
1 parent 7903b35 commit 540a76f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

flang/lib/Lower/IntrinsicCall.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,10 +3492,10 @@ IntrinsicLibrary::genReshape(mlir::Type resultType,
34923492
assert(fir::BoxValue(shape).rank() == 1);
34933493
mlir::Type shapeTy = shape.getType();
34943494
mlir::Type shapeArrTy = fir::dyn_cast_ptrOrBoxEleTy(shapeTy);
3495-
auto resultRank = shapeArrTy.cast<fir::SequenceType>().getShape();
3495+
auto resultRank = shapeArrTy.cast<fir::SequenceType>().getShape()[0];
34963496

3497-
assert(resultRank[0] != fir::SequenceType::getUnknownExtent() &&
3498-
"shape arg must have constant size");
3497+
if (resultRank == fir::SequenceType::getUnknownExtent())
3498+
TODO(loc, "RESHAPE intrinsic requires computing rank of result");
34993499

35003500
// Handle optional pad argument
35013501
mlir::Value pad = isStaticallyAbsent(args[2])
@@ -3510,7 +3510,7 @@ IntrinsicLibrary::genReshape(mlir::Type resultType,
35103510
: builder.createBox(loc, args[3]);
35113511

35123512
// Create mutable fir.box to be passed to the runtime for the result.
3513-
mlir::Type type = builder.getVarLenSeqTy(resultType, resultRank[0]);
3513+
mlir::Type type = builder.getVarLenSeqTy(resultType, resultRank);
35143514
fir::MutableBoxValue resultMutableBox =
35153515
fir::factory::createTempMutableBox(builder, loc, type);
35163516

0 commit comments

Comments
 (0)