Skip to content

Commit f627a17

Browse files
committed
plugin_interface_issue_fix
1 parent 57bd313 commit f627a17

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7931,14 +7931,25 @@ class MappableExprsHandler {
79317931
else if (VAT)
79327932
ElementType = VAT->getElementType().getTypePtr();
79337933
else if (&Component == &*Components.begin()) {
7934-
// Handle pointer-based array sections like data[a:b:c]
7934+
// If the base is a raw pointer (e.g. T *data with data[a:b:c]),
7935+
// there was no earlier CAT/VAT/array handling to establish
7936+
// ElementType. Capture the pointee type now so that subsequent
7937+
// components (offset/length/stride) have a concrete element type to
7938+
// work with. This makes pointer-backed sections behave consistently
7939+
// with CAT/VAT/array bases.
79357940
if (const auto *PtrType = Ty->getAs<PointerType>()) {
79367941
ElementType = PtrType->getPointeeType().getTypePtr();
79377942
}
7943+
} else {
7944+
// Any component after the first should never have a raw pointer type;
7945+
// by this point. ElementType must already be known (set above or in
7946+
// prior array / CAT / VAT handling).
7947+
assert(!Ty->isPointerType() &&
7948+
"Non-first components should not be raw pointers");
79387949
}
7939-
// If ElementType is null, then it means the base is a pointer
7940-
// (neither CAT nor VAT) and we'll attempt to get ElementType again
7941-
// for next iteration.
7950+
7951+
// At this stage, if ElementType was a base pointer and we are in the
7952+
// first iteration, it has been computed.
79427953
if (ElementType) {
79437954
// For the case that having pointer as base, we need to remove one
79447955
// level of indirection.
@@ -8551,8 +8562,15 @@ class MappableExprsHandler {
85518562
// If there is an entry in PartialStruct it means we have a struct with
85528563
// individual members mapped. Emit an extra combined entry.
85538564
if (PartialStruct.Base.isValid()) {
8554-
UnionCurInfo.NonContigInfo.Dims.push_back(0);
8555-
// Emit a combined entry:
8565+
// Prepend a synthetic dimension of length 1 to represent the
8566+
// aggregated struct object. Using 1 (not 0, as 0 produced an
8567+
// incorrect non-contiguous descriptor (DimSize==1), causing the
8568+
// non-contiguous motion clause path to be skipped.) is important:
8569+
// * It preserves the correct rank so targetDataUpdate() computes
8570+
// DimSize == 2 for cases like strided array sections originating
8571+
// from user-defined mappers (e.g. test with s.data[0:8:2]).
8572+
UnionCurInfo.NonContigInfo.Dims.insert(
8573+
UnionCurInfo.NonContigInfo.Dims.begin(), 1);
85568574
emitCombinedEntry(CombinedInfo, UnionCurInfo.Types, PartialStruct,
85578575
/*IsMapThis*/ !VD, OMPBuilder, VD);
85588576
}

0 commit comments

Comments
 (0)