From d6173167df31388869d22751fdd745f5da928ef7 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Thu, 2 May 2024 10:04:24 -0400 Subject: [Flang] Get fir::SequenceType from hlfir::ExprType before getShape. (#90055) This PR is to fix issue #88889 . Because the type of an actual argument of an array expression of character has type of `hlfir::ExprType`, we need to transform it to `fir::SequenceType` before calling `getBoxTypeWithNewShape`. Calling `hlfir::ExprType::getShape` inside of `getBoxTypeWithNewShape` will introduce a circular dependency on FIRDialect and HLFIRDialect libraries. --- flang/lib/Lower/ConvertCall.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp index e4a0cc8..3659dad 100644 --- a/flang/lib/Lower/ConvertCall.cpp +++ b/flang/lib/Lower/ConvertCall.cpp @@ -1184,12 +1184,15 @@ static PreparedDummyArgument preparePresentUserCallActualArgument( // actual argument shape information. A descriptor with the dummy shape // information will be created later when all actual arguments are ready. mlir::Type dummyTypeWithActualRank = dummyType; - if (auto baseBoxDummy = mlir::dyn_cast(dummyType)) + if (auto baseBoxDummy = mlir::dyn_cast(dummyType)) { if (baseBoxDummy.isAssumedRank() || arg.testTKR(Fortran::common::IgnoreTKR::Rank) || - arg.isSequenceAssociatedDescriptor()) - dummyTypeWithActualRank = - baseBoxDummy.getBoxTypeWithNewShape(actual.getType()); + arg.isSequenceAssociatedDescriptor()) { + mlir::Type actualTy = + hlfir::getFortranElementOrSequenceType(actual.getType()); + dummyTypeWithActualRank = baseBoxDummy.getBoxTypeWithNewShape(actualTy); + } + } // Preserve the actual type in the argument preparation in case IgnoreTKR(t) // is set (descriptors must be created with the actual type in this case, and // copy-in/copy-out should be driven by the contiguity with regard to the -- cgit v1.1