[flang-commits] [flang] [mlir] [mlir][OpenMP][flang] make private variable allocation implicit in omp.private (PR #124019)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Fri Jan 24 12:33:08 PST 2025
================
@@ -122,6 +122,58 @@ fir::ShapeShiftOp Fortran::lower::omp::getShapeShift(fir::FirOpBuilder &builder,
return shapeShift;
}
+// Initialize box newBox using moldBox. These should both have the same type and
+// be boxes containing derived types e.g.
+// fir.box<!fir.type<>>
+// fir.box<!fir.heap<!fir.type<>>
+// fir.box<!fir.heap<!fir.array<fir.type<>>>
+// fir.class<...<!fir.type<>>>
+// If the type doesn't match , this does nothing
+static void initializeIfDerivedTypeBox(fir::FirOpBuilder &builder,
+ mlir::Location loc, mlir::Value newBox,
+ mlir::Value moldBox, bool hasInitializer,
+ bool isFirstPrivate) {
+ fir::BoxType boxTy = mlir::dyn_cast<fir::BoxType>(newBox.getType());
+ fir::ClassType classTy = mlir::dyn_cast<fir::ClassType>(newBox.getType());
+ if (!boxTy && !classTy)
+ return;
+
+ // remove pointer and array types in the middle
+ mlir::Type eleTy;
+ if (boxTy)
+ eleTy = boxTy.getElementType();
+ if (classTy)
+ eleTy = classTy.getEleTy();
----------------
luporl wrote:
nit: `mlir::Type eleTy = boxTy ? boxTy.getElementType() : classTy.getEleTy();`
https://github.com/llvm/llvm-project/pull/124019
More information about the flang-commits
mailing list