[flang-commits] [flang] [flang][hlfir] Lower Cray pointee references. (PR #65563)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Thu Sep 7 09:27:53 PDT 2023


================
@@ -1492,6 +1494,52 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
     auto name = converter.mangleName(sym);
     fir::FortranVariableFlagsAttr attributes =
         Fortran::lower::translateSymbolAttributes(builder.getContext(), sym);
+
+    if (isCrayPointee) {
+      mlir::Type baseType =
+          hlfir::getFortranElementOrSequenceType(base.getType());
+      if (auto seqType = mlir::dyn_cast<fir::SequenceType>(baseType)) {
+        // The pointer box's sequence type must be with unknown shape.
+        llvm::SmallVector<int64_t> shape(seqType.getDimension(),
+                                         fir::SequenceType::getUnknownExtent());
+        baseType = fir::SequenceType::get(shape, seqType.getEleTy());
+      }
+      fir::BoxType ptrBoxType =
+          fir::BoxType::get(fir::PointerType::get(baseType));
+      mlir::Value boxAlloc =
+          fir::factory::genNullBoxStorage(builder, loc, ptrBoxType);
----------------
vzakhari wrote:

Oh, okay.  Thank you for the clarification!

https://github.com/llvm/llvm-project/pull/65563


More information about the flang-commits mailing list