================ @@ -148,41 +309,113 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions( builder.setInsertionPointToEnd(initBlock); mlir::Value boxAlloca = allocatedPrivVarArg; + + moldArg = builder.loadIfRef(loc, moldArg); + getLengthParameters(builder, loc, moldArg, lenParams); + + // The initial state of a private pointer is undefined so we don't need to + // match the mold argument (OpenMP 5.2 end of page 106). + if (isPrivatization(kind) && + mlir::isa<fir::PointerType>(boxTy.getEleTy())) { + // we need a shape with the right rank so that the embox op is lowered + // to an llvm struct of the right type. This returns nullptr if the types + // aren't right. + mlir::Value shape = generateZeroShapeForRank(builder, loc, moldArg); + // Just incase, do initialize the box with a null value + mlir::Value null = builder.createNullConstant(loc, boxTy.getEleTy()); + mlir::Value nullBox; + if (shape) + nullBox = builder.create<fir::EmboxOp>( + loc, boxTy, null, shape, /*slice=*/mlir::Value{}, lenParams); ---------------- ergawy wrote:
I think we can get rid of the `else`, right? If `shape` is an empty value, it is the same as passing `Value{}` I think. https://github.com/llvm/llvm-project/pull/124019 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits