[llvm-branch-commits] [flang] [mlir] [mlir][OpenMP][flang] make private variable allocation implicit in omp.private (PR #124019)
Kareem Ergawy via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 23 03:33:43 PST 2025
================
@@ -96,17 +149,118 @@ 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();
+ mlir::Type derivedTy = fir::unwrapRefType(eleTy);
+ if (auto array = mlir::dyn_cast<fir::SequenceType>(derivedTy))
+ derivedTy = array.getElementType();
+
+ if (!fir::isa_derived(derivedTy))
+ return;
+ assert(moldBox.getType() == newBox.getType());
----------------
ergawy wrote:
nit: move to the function start to document the pre-conditions expected by it.
https://github.com/llvm/llvm-project/pull/124019
More information about the llvm-branch-commits
mailing list