[llvm] [Clang][OpenMP] Handled `NonContig` Descriptor `DimCount` (PR #181987)

Abhinav Gaba via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 18 14:56:08 PST 2026


================
@@ -9945,16 +9945,29 @@ Error OpenMPIRBuilder::emitOffloadingArrays(
                                      ConstantInt::get(Int64Ty, 0));
   SmallBitVector RuntimeSizes(CombinedInfo.Sizes.size());
   for (unsigned I = 0, E = CombinedInfo.Sizes.size(); I < E; ++I) {
+    bool IsNonContigEntry =
+        IsNonContiguous &&
+        (static_cast<std::underlying_type_t<OpenMPOffloadMappingFlags>>(
+             CombinedInfo.Types[I] &
+             OpenMPOffloadMappingFlags::OMP_MAP_NON_CONTIG) != 0);
+    // For NON_CONTIG entries ArgSizes must carry the dimension count
+    // (number of descriptor_dim records) – NOT the byte size expression.
+    // Variable subsection forms (e.g. 0:s.len/2:2) previously produced a
+    // non-constant size so we marked them runtime and stored the byte size,
+    // leading the runtime to treat it as DimSize and overrun descriptors.
+    if (IsNonContigEntry) {
+      // Dims must be long enough and positive.
+      assert(I < CombinedInfo.NonContigInfo.Dims.size() &&
+             "Induction variable is in-bounds with the NON_CONTIG Dims array");
----------------
abhinavgaba wrote:

The message could be misleading to read when the assertion fails, because it will read "is in-bounds" when it it not. I think it's preferable to reword it similar to the next assertion in 9963.

https://github.com/llvm/llvm-project/pull/181987


More information about the llvm-commits mailing list