[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 08:21:22 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:

Yes, `createTemporary` should be cleaner, and I will fix it.  Thank you!

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


More information about the flang-commits mailing list