[flang-commits] [flang] [Flang] Get fir::SequenceType from hlfir::ExprType before getShape. (PR #90055)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Thu Apr 25 07:09:57 PDT 2024


https://github.com/DanielCChen updated https://github.com/llvm/llvm-project/pull/90055

>From f3fda5a4c3fa57327e137d763ab05d9c2f1357af Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Thu, 25 Apr 2024 09:53:51 -0400
Subject: [PATCH 1/2] [Flang] Get fir::SequenceType from hlfir::ExprType before
 getShape.

---
 flang/lib/Lower/ConvertCall.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index c6f7d3410ad5cf..32c114865f92c7 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -1184,12 +1184,16 @@ 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<fir::BaseBoxType>(dummyType))
+  if (auto baseBoxDummy = mlir::dyn_cast<fir::BaseBoxType>(dummyType)) {
     if (baseBoxDummy.isAssumedRank() ||
         arg.testTKR(Fortran::common::IgnoreTKR::Rank) ||
-        arg.isSequenceAssociatedDescriptor())
+        arg.isSequenceAssociatedDescriptor()) {
+      mlir::Type actualTy =
+          hlfir::getFortranElementOrSequenceType(actual.getType());
       dummyTypeWithActualRank =
-          baseBoxDummy.getBoxTypeWithNewShape(actual.getType());
+          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

>From b482a9856e67622d548cdef1e9a09185d67159f5 Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Thu, 25 Apr 2024 10:09:44 -0400
Subject: [PATCH 2/2] [Flang] Fixing formatting issue.

---
 flang/lib/Lower/ConvertCall.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 32c114865f92c7..660b90de595c5b 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -1190,8 +1190,7 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
         arg.isSequenceAssociatedDescriptor()) {
       mlir::Type actualTy =
           hlfir::getFortranElementOrSequenceType(actual.getType());
-      dummyTypeWithActualRank =
-          baseBoxDummy.getBoxTypeWithNewShape(actualTy);
+      dummyTypeWithActualRank = baseBoxDummy.getBoxTypeWithNewShape(actualTy);
     }
   }
   // Preserve the actual type in the argument preparation in case IgnoreTKR(t)



More information about the flang-commits mailing list