Skip to content

Commit 4762b11

Browse files
committed
plugin_interface_issue_fix
1 parent f394b93 commit 4762b11

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
@@ -8240,14 +8240,25 @@ class MappableExprsHandler {
82408240
else if (VAT)
82418241
ElementType = VAT->getElementType().getTypePtr();
82428242
else if (&Component == &*Components.begin()) {
8243-
// Handle pointer-based array sections like data[a:b:c]
8243+
// If the base is a raw pointer (e.g. T *data with data[a:b:c]),
8244+
// there was no earlier CAT/VAT/array handling to establish
8245+
// ElementType. Capture the pointee type now so that subsequent
8246+
// components (offset/length/stride) have a concrete element type to
8247+
// work with. This makes pointer-backed sections behave consistently
8248+
// with CAT/VAT/array bases.
82448249
if (const auto *PtrType = Ty->getAs<PointerType>()) {
82458250
ElementType = PtrType->getPointeeType().getTypePtr();
82468251
}
8252+
} else {
8253+
// Any component after the first should never have a raw pointer type;
8254+
// by this point. ElementType must already be known (set above or in
8255+
// prior array / CAT / VAT handling).
8256+
assert(!Ty->isPointerType() &&
8257+
"Non-first components should not be raw pointers");
82478258
}
8248-
// If ElementType is null, then it means the base is a pointer
8249-
// (neither CAT nor VAT) and we'll attempt to get ElementType again
8250-
// for next iteration.
8259+
8260+
// At this stage, if ElementType was a base pointer and we are in the
8261+
// first iteration, it has been computed.
82518262
if (ElementType) {
82528263
// For the case that having pointer as base, we need to remove one
82538264
// level of indirection.
@@ -8957,8 +8968,15 @@ class MappableExprsHandler {
89578968
// If there is an entry in PartialStruct it means we have a struct with
89588969
// individual members mapped. Emit an extra combined entry.
89598970
if (PartialStruct.Base.isValid()) {
8960-
UnionCurInfo.NonContigInfo.Dims.push_back(0);
8961-
// Emit a combined entry:
8971+
// Prepend a synthetic dimension of length 1 to represent the
8972+
// aggregated struct object. Using 1 (not 0, as 0 produced an
8973+
// incorrect non-contiguous descriptor (DimSize==1), causing the
8974+
// non-contiguous motion clause path to be skipped.) is important:
8975+
// * It preserves the correct rank so targetDataUpdate() computes
8976+
// DimSize == 2 for cases like strided array sections originating
8977+
// from user-defined mappers (e.g. test with s.data[0:8:2]).
8978+
UnionCurInfo.NonContigInfo.Dims.insert(
8979+
UnionCurInfo.NonContigInfo.Dims.begin(), 1);
89628980
emitCombinedEntry(CombinedInfo, UnionCurInfo.Types, PartialStruct,
89638981
/*IsMapThis*/ !VD, OMPBuilder, VD);
89648982
}

0 commit comments

Comments
 (0)