[flang-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Support mapping of zero-sized arrays (PR #208133)
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Wed Jul 8 06:40:45 PDT 2026
================
@@ -6273,8 +6294,53 @@ static llvm::Value *getSizeInBytes(DataLayout &dl, const mlir::Type &type,
// size, so we do some on the fly runtime math to get the size in
// bytes from the extent (ub - lb) * sizeInBytes. NOTE: This may need
// some adjustment for members with more complex types.
- return builder.CreateMul(elementCount,
- builder.getInt64(underlyingTypeSzInBits / 8));
+ llvm::Value *sizeCalc = builder.CreateMul(
+ elementCount, builder.getInt64(underlyingTypeSzInBits / 8),
+ "element_count");
+
+ // This is a part of a "complicated" bit of size calculation logic that is
+ // in place to handle a couple of scenarios, one specific to Fortran and
+ // the other a more general OpenMP issue. The other piece of the
+ // calculation can be found as the final size calculation within the
+ // processIndividualMap function. Ideally we would move it here, but due
+ // to the complexity of calculating the final base address of some
+ // constructs (required for a nullary check), it's left as the final step.
+ // So, in the below 2 cases, the nullary check is in processIndividualMap
+ // and the size equality check is here. The cases this modifications help
+ // cover are:
+ //
+ // 1) If an argument has a null base pointer, then the size must be set to
+ // 0
----------------
Meinersbur wrote:
[nit] awkward line break
https://github.com/llvm/llvm-project/pull/208133
More information about the flang-commits
mailing list