[flang-commits] [flang] [flang][hlfir] Lower Cray pointee references. (PR #65563)
via flang-commits
flang-commits at lists.llvm.org
Thu Sep 7 07:23:20 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);
----------------
jeanPerier wrote:
This code allocates and initialize the pointer storage, I think the initialization is not needed/confusing in the generated IR given it is done again with the actual shape info below.
Maybe you can just use builder.createTemporary(loc, ptrBoxType) to get the temp and move the initialization code you have below before the hlfir.declare. That way, at the point of the hlfir.declare, the pointer contains the right shape/length info.
https://github.com/llvm/llvm-project/pull/65563
More information about the flang-commits
mailing list