https://github.com/amitamd7 updated 
https://github.com/llvm/llvm-project/pull/157443

>From 57bd313653a208eefbd5d349704ea984f499d08a Mon Sep 17 00:00:00 2001
From: amtiwari <[email protected]>
Date: Mon, 8 Sep 2025 08:23:21 -0400
Subject: [PATCH 1/2] handle_array_pointer_var_check

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b38eb54036e60..416a8c1ad4a03 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7930,10 +7930,12 @@ class MappableExprsHandler {
           ElementType = CAT->getElementType().getTypePtr();
         else if (VAT)
           ElementType = VAT->getElementType().getTypePtr();
-        else
-          assert(&Component == &*Components.begin() &&
-                 "Only expect pointer (non CAT or VAT) when this is the "
-                 "first Component");
+        else if (&Component == &*Components.begin()) {
+          // Handle pointer-based array sections like data[a:b:c]
+          if (const auto *PtrType = Ty->getAs<PointerType>()) {
+            ElementType = PtrType->getPointeeType().getTypePtr();
+          }
+        }
         // If ElementType is null, then it means the base is a pointer
         // (neither CAT nor VAT) and we'll attempt to get ElementType again
         // for next iteration.

>From f627a170244dadea744ab1f2ead48a5e9c9b66ed Mon Sep 17 00:00:00 2001
From: amtiwari <[email protected]>
Date: Fri, 21 Nov 2025 06:47:59 -0500
Subject: [PATCH 2/2] plugin_interface_issue_fix

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 30 +++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 416a8c1ad4a03..e811327b14ec7 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7931,14 +7931,25 @@ class MappableExprsHandler {
         else if (VAT)
           ElementType = VAT->getElementType().getTypePtr();
         else if (&Component == &*Components.begin()) {
-          // Handle pointer-based array sections like data[a:b:c]
+          // If the base is a raw pointer (e.g. T *data with data[a:b:c]),
+          // there was no earlier CAT/VAT/array handling to establish
+          // ElementType. Capture the pointee type now so that subsequent
+          // components (offset/length/stride) have a concrete element type to
+          // work with. This makes pointer-backed sections behave consistently
+          // with CAT/VAT/array bases.
           if (const auto *PtrType = Ty->getAs<PointerType>()) {
             ElementType = PtrType->getPointeeType().getTypePtr();
           }
+        } else {
+          // Any component after the first should never have a raw pointer 
type;
+          // by this point. ElementType must already be known (set above or in
+          // prior array / CAT / VAT handling).
+          assert(!Ty->isPointerType() &&
+                 "Non-first components should not be raw pointers");
         }
-        // If ElementType is null, then it means the base is a pointer
-        // (neither CAT nor VAT) and we'll attempt to get ElementType again
-        // for next iteration.
+
+        // At this stage, if ElementType was a base pointer and we are in the
+        // first iteration, it has been computed. 
         if (ElementType) {
           // For the case that having pointer as base, we need to remove one
           // level of indirection.
@@ -8551,8 +8562,15 @@ class MappableExprsHandler {
       // If there is an entry in PartialStruct it means we have a struct with
       // individual members mapped. Emit an extra combined entry.
       if (PartialStruct.Base.isValid()) {
-        UnionCurInfo.NonContigInfo.Dims.push_back(0);
-        // Emit a combined entry:
+        // Prepend a synthetic dimension of length 1 to represent the
+        // aggregated struct object. Using 1 (not 0, as 0 produced an
+        //    incorrect non-contiguous descriptor (DimSize==1), causing the
+        //    non-contiguous motion clause path to be skipped.) is important:
+        //  * It preserves the correct rank so targetDataUpdate() computes
+        //    DimSize == 2 for cases like strided array sections originating
+        //    from user-defined mappers (e.g. test with s.data[0:8:2]).
+        UnionCurInfo.NonContigInfo.Dims.insert(
+            UnionCurInfo.NonContigInfo.Dims.begin(), 1);
         emitCombinedEntry(CombinedInfo, UnionCurInfo.Types, PartialStruct,
                           /*IsMapThis*/ !VD, OMPBuilder, VD);
       }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to