[clang] [OpenMP][wip] Rework 'containing struct'/overlapped mapping handling (PR #153672)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 14 13:37:17 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- clang/lib/CodeGen/CGOpenMPRuntime.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index e969192c1..18125efb2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6779,7 +6779,7 @@ public:
Indirect = Ind;
}
- EffectiveBaseMapKey(llvm::FoldingSetNodeID FromID) : ID(FromID) { }
+ EffectiveBaseMapKey(llvm::FoldingSetNodeID FromID) : ID(FromID) {}
llvm::FoldingSetNodeID getID() const { return ID; }
bool getIndirect() const { return Indirect; }
@@ -6809,8 +6809,7 @@ template <> struct llvm::DenseMapInfo<EffectiveBaseMapKey> {
static bool isEqual(const EffectiveBaseMapKey &LHS,
const EffectiveBaseMapKey &RHS) {
- return LHS.getID() == RHS.getID() &&
- LHS.getIndirect() == RHS.getIndirect();
+ return LHS.getID() == RHS.getID() && LHS.getIndirect() == RHS.getIndirect();
}
};
@@ -6889,27 +6888,27 @@ public:
bool CompleteExpression = false;
Address Base = Address::invalid();
Address Pointer = Address::invalid();
-
- //MappableExprMetadata() {}
-
- /*MappableExprMetadata(OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
- const MapData *MD, bool CompleteExpression)
- : Components(Components), MD(MD),
- CompleteExpression(CompleteExpression) {}
-
+
+ // MappableExprMetadata() {}
+
+ /*MappableExprMetadata(OMPClauseMappableExprCommon::MappableExprComponentListRef
+ Components, const MapData *MD, bool CompleteExpression) :
+ Components(Components), MD(MD), CompleteExpression(CompleteExpression) {}
+
MappableExprMetadata(MappableExprMetadata &Other) {
}*/
};
- using ExprComponentMap = llvm::MapVector<EffectiveBaseMapKey, MappableExprMetadata>;
+ using ExprComponentMap =
+ llvm::MapVector<EffectiveBaseMapKey, MappableExprMetadata>;
/// Map between a struct and the its lowest & highest elements which have been
/// mapped.
/// [ValueDecl *] --> {LE(FieldIndex, Pointer),
/// HE(FieldIndex, Pointer)}
struct StructRangeInfoTy {
- //MapCombinedInfoTy PreliminaryMapData;
+ // MapCombinedInfoTy PreliminaryMapData;
const Expr *BaseExpr = nullptr;
ExprComponentMap ChildComponents;
unsigned MemberDepth = -1u;
@@ -6925,7 +6924,8 @@ public:
};
// A map from effective base addresses to struct range info for that base.
- using PartialStructMap = llvm::DenseMap<EffectiveBaseMapKey, StructRangeInfoTy>;
+ using PartialStructMap =
+ llvm::DenseMap<EffectiveBaseMapKey, StructRangeInfoTy>;
private:
/// Kind that defines how a device pointer has to be returned.
@@ -7203,15 +7203,16 @@ private:
const FieldDecl *FD,
llvm::function_ref<LValue(CodeGenFunction &, const MemberExpr *)>
EmitMemberExprBase) {
- uint64_t FieldOffset = CGF.getContext().toBits(CharUnits::fromQuantity(Layout[FD]));
+ uint64_t FieldOffset =
+ CGF.getContext().toBits(CharUnits::fromQuantity(Layout[FD]));
uint64_t FieldSize =
CGF.getContext().getTypeSize(FD->getType().getCanonicalType());
Address ComponentLB = Address::invalid();
fprintf(stderr, "Process field: ");
MC.getAssociatedExpression()->dumpPretty(CGF.getContext());
- fprintf(stderr, " offset: %d index: %d cursor: %d\n", (int) FieldOffset, (int) FD->getFieldIndex(),
- (int) Cursor);
+ fprintf(stderr, " offset: %d index: %d cursor: %d\n", (int)FieldOffset,
+ (int)FD->getFieldIndex(), (int)Cursor);
if (FD->getType()->isLValueReferenceType()) {
const auto *ME = cast<MemberExpr>(MC.getAssociatedExpression());
@@ -7245,8 +7246,8 @@ private:
}
void copyUntilEnd(Address HB, CharUnits TypeSize) {
- fprintf(stderr, "copyUntilEnd: Cursor=%d TypeSize=%d\n",
- (int) Cursor, (int) CGF.getContext().toBits(TypeSize));
+ fprintf(stderr, "copyUntilEnd: Cursor=%d TypeSize=%d\n", (int)Cursor,
+ (int)CGF.getContext().toBits(TypeSize));
if ((uint64_t)CGF.getContext().toBits(TypeSize) <= Cursor)
return;
llvm::Value *LBPtr = LB.emitRawPointer(CGF);
@@ -7272,7 +7273,8 @@ private:
/// Given a MemberExpr \c ME, find the containing structure as understood by
/// OpenMP (OpenMP 6.0, "2 Glossary").
- const Expr *getEffectiveBase(const MemberExpr *ME, const MemberExpr **IME, bool &Ind) const {
+ const Expr *getEffectiveBase(const MemberExpr *ME, const MemberExpr **IME,
+ bool &Ind) const {
const Expr *Base = ME->getBase()->IgnoreParenImpCasts();
Ind = false;
@@ -7314,28 +7316,29 @@ private:
using iterator_category = std::forward_iterator_tag;
using value_type = const OMPClauseMappableExprCommon::MappableComponent;
using difference_type = std::ptrdiff_t;
- using pointer = const OMPClauseMappableExprCommon::MappableComponent*;
- using reference = const OMPClauseMappableExprCommon::MappableComponent&;
+ using pointer = const OMPClauseMappableExprCommon::MappableComponent *;
+ using reference = const OMPClauseMappableExprCommon::MappableComponent &;
- std::reverse_iterator<const OMPClauseMappableExprCommon::MappableComponent *> Pos;
+ std::reverse_iterator<
+ const OMPClauseMappableExprCommon::MappableComponent *>
+ Pos;
bool RefPtee = false;
const ValueDecl *BaseDecl = nullptr;
// We repeat on references -- this is the position in the underlying list.
unsigned ComponentPos = 0;
-
- ComponentListRefPtrPteeIterator(std::reverse_iterator<const OMPClauseMappableExprCommon::MappableComponent *> From) : Pos(From)
- { }
+
+ ComponentListRefPtrPteeIterator(
+ std::reverse_iterator<
+ const OMPClauseMappableExprCommon::MappableComponent *>
+ From)
+ : Pos(From) {}
reference operator*() const { return *Pos; }
pointer operator->() { return &*Pos; }
- void setBaseDecl(const ValueDecl *Decl) {
- BaseDecl = Decl;
- }
+ void setBaseDecl(const ValueDecl *Decl) { BaseDecl = Decl; }
- bool isRefPtee() {
- return RefPtee;
- }
+ bool isRefPtee() { return RefPtee; }
bool isRef() {
const OMPClauseMappableExprCommon::MappableComponent *Comp = &*Pos;
@@ -7351,11 +7354,12 @@ private:
const OMPClauseMappableExprCommon::MappableComponent *Comp = &*Pos;
const Expr *AE = Comp->getAssociatedExpression();
const auto *OASE = dyn_cast<ArraySectionExpr>(AE);
- bool IsPointer =
- isa<OMPArrayShapingExpr>(AE) ||
- (OASE && ArraySectionExpr::getBaseOriginalType(OASE).getCanonicalType()->isAnyPointerType()) ||
- AE->getType()->isAnyPointerType();
-
+ bool IsPointer = isa<OMPArrayShapingExpr>(AE) ||
+ (OASE && ArraySectionExpr::getBaseOriginalType(OASE)
+ .getCanonicalType()
+ ->isAnyPointerType()) ||
+ AE->getType()->isAnyPointerType();
+
if (AllowDeref)
return IsPointer;
else if (!IsPointer)
@@ -7367,11 +7371,9 @@ private:
return !isa<BinaryOperator>(AE);
}
- unsigned getComponentPos() {
- return ComponentPos;
- }
+ unsigned getComponentPos() { return ComponentPos; }
- ComponentListRefPtrPteeIterator& operator++() {
+ ComponentListRefPtrPteeIterator &operator++() {
if (isRef()) {
if (!RefPtee)
RefPtee = true;
@@ -7384,8 +7386,9 @@ private:
// This could skip to outermost MemberExprs (over ".").
++Pos;
++ComponentPos;
- /*while (auto ME = dyn_cast<MemberExpr>(Pos->getAssociatedExpression()->IgnoreParenImpCasts())) {
- if (ME->isArrow() || ME->getBase()->getType()->isReferenceType())
+ /*while (auto ME =
+ dyn_cast<MemberExpr>(Pos->getAssociatedExpression()->IgnoreParenImpCasts()))
+ { if (ME->isArrow() || ME->getBase()->getType()->isReferenceType())
break;
else
++Pos;
@@ -7400,8 +7403,8 @@ private:
return tmp;
}
- friend bool operator==(const ComponentListRefPtrPteeIterator& a,
- const ComponentListRefPtrPteeIterator& b) {
+ friend bool operator==(const ComponentListRefPtrPteeIterator &a,
+ const ComponentListRefPtrPteeIterator &b) {
return a.Pos == b.Pos && a.RefPtee == b.RefPtee;
}
@@ -7482,14 +7485,15 @@ private:
return E;
}
- bool componentsEqual(const OMPClauseMappableExprCommon::MappableComponent &One,
- const OMPClauseMappableExprCommon::MappableComponent &Two) const {
+ bool componentsEqual(
+ const OMPClauseMappableExprCommon::MappableComponent &One,
+ const OMPClauseMappableExprCommon::MappableComponent &Two) const {
if (One.isNonContiguous() != Two.isNonContiguous())
return false;
ValueDecl *DeclOne = One.getAssociatedDeclaration();
ValueDecl *DeclTwo = Two.getAssociatedDeclaration();
-
+
if (DeclOne == nullptr || DeclTwo == nullptr)
return DeclOne == DeclTwo;
@@ -7500,17 +7504,24 @@ private:
Two.getAssociatedExpression());
}
- bool hasMemberExpr(const OMPClauseMappableExprCommon::MappableExprComponentListRef Components) const {
- return llvm::any_of(Components, [](const OMPClauseMappableExprCommon::MappableComponent &M) {
- return isa<MemberExpr>(M.getAssociatedExpression());
- });
+ bool
+ hasMemberExpr(const OMPClauseMappableExprCommon::MappableExprComponentListRef
+ Components) const {
+ return llvm::any_of(
+ Components,
+ [](const OMPClauseMappableExprCommon::MappableComponent &M) {
+ return isa<MemberExpr>(M.getAssociatedExpression());
+ });
}
- void gatherStructDataForComponentList(const MapData &MD, OpenMPMapClauseKind MapType, ArrayRef<OpenMPMapModifierKind> MapModifiers,
- OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
- MapCombinedInfoTy &CombinedInfo, PartialStructMap &PartialStructs,
- bool IsImplicit, const ValueDecl *Mapper = nullptr,
- const ValueDecl *BaseDecl = nullptr, const Expr *MapExpr = nullptr) const {
+ void gatherStructDataForComponentList(
+ const MapData &MD, OpenMPMapClauseKind MapType,
+ ArrayRef<OpenMPMapModifierKind> MapModifiers,
+ OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
+ MapCombinedInfoTy &CombinedInfo, PartialStructMap &PartialStructs,
+ bool IsImplicit, const ValueDecl *Mapper = nullptr,
+ const ValueDecl *BaseDecl = nullptr,
+ const Expr *MapExpr = nullptr) const {
// Scan the components from the base to the complete expression.
auto CI = ComponentListRefPtrPteeIterator(Components.rbegin());
auto CE = ComponentListRefPtrPteeIterator(Components.rend());
@@ -7525,9 +7536,8 @@ private:
/*const auto *AE = dyn_cast<ArraySubscriptExpr>(AssocExpr);
const auto *OASE = dyn_cast<ArraySectionExpr>(AssocExpr);
const auto *OAShE = dyn_cast<OMPArrayShapingExpr>(AssocExpr);*/
-
- auto &&EmitMemberExprBase = [](CodeGenFunction &CGF,
- const MemberExpr *E) {
+
+ auto &&EmitMemberExprBase = [](CodeGenFunction &CGF, const MemberExpr *E) {
const Expr *BaseExpr = E->getBase();
// If this is s.x, emit s as an lvalue. If it is s->x, emit s as a
// scalar.
@@ -7564,18 +7574,19 @@ private:
CGF.ConvertTypeForMem(OAShE->getBase()->getType()->getPointeeType()),
CGF.getContext().getTypeAlignInChars(OAShE->getBase()->getType()));
} else {*/
- // The base is the reference to the variable.
- // BP = &Var.
- fprintf(stderr, "Init new BP from ");
- AssocExpr->dumpPretty(CGF.getContext());
- fprintf(stderr, "\n");
- BP = CGF.EmitOMPSharedLValue(AssocExpr).getAddress();
- BPP = Address::invalid();
- QualType Ty = CI->getAssociatedDeclaration()->getType().getNonReferenceType();
- if (Ty->isAnyPointerType()) {
- BPP = BP;
- BP = CGF.EmitLoadOfPointer(BP, Ty->castAs<PointerType>());
- }
+ // The base is the reference to the variable.
+ // BP = &Var.
+ fprintf(stderr, "Init new BP from ");
+ AssocExpr->dumpPretty(CGF.getContext());
+ fprintf(stderr, "\n");
+ BP = CGF.EmitOMPSharedLValue(AssocExpr).getAddress();
+ BPP = Address::invalid();
+ QualType Ty =
+ CI->getAssociatedDeclaration()->getType().getNonReferenceType();
+ if (Ty->isAnyPointerType()) {
+ BPP = BP;
+ BP = CGF.EmitLoadOfPointer(BP, Ty->castAs<PointerType>());
+ }
//}
bool IsNonContiguous = CombinedInfo.NonContigInfo.IsNonContiguous;
@@ -7590,13 +7601,14 @@ private:
StructRangeInfoTy *PartialStruct = nullptr;
bool Indirected = false;
- //auto Next = std::next(I);
- if (auto ME = dyn_cast<MemberExpr>(I->getAssociatedExpression()->IgnoreParenImpCasts())) {
+ // auto Next = std::next(I);
+ if (auto ME = dyn_cast<MemberExpr>(
+ I->getAssociatedExpression()->IgnoreParenImpCasts())) {
/*if (!FirstMemberExpr) {
- QualType Ty = CI->getAssociatedDeclaration()->getType().getNonReferenceType();
- if (Ty->isAnyPointerType()) {
- BP = CGF.EmitLoadOfPointer(BP, Ty->castAs<PointerType>());
- Indirected = true;
+ QualType Ty =
+ CI->getAssociatedDeclaration()->getType().getNonReferenceType(); if
+ (Ty->isAnyPointerType()) { BP = CGF.EmitLoadOfPointer(BP,
+ Ty->castAs<PointerType>()); Indirected = true;
}
FirstMemberExpr = ME;
}*/
@@ -7604,15 +7616,18 @@ private:
}
// Peek at the next outer expression to see if it's a "." member access
- if (auto ME = dyn_cast<MemberExpr>(I->getAssociatedExpression()->IgnoreParenImpCasts())) {
+ if (auto ME = dyn_cast<MemberExpr>(
+ I->getAssociatedExpression()->IgnoreParenImpCasts())) {
auto Next = std::next(I);
if (Next != CE) {
- if (auto NME = dyn_cast<MemberExpr>(Next->getAssociatedExpression()->IgnoreParenImpCasts())) {
+ if (auto NME = dyn_cast<MemberExpr>(
+ Next->getAssociatedExpression()->IgnoreParenImpCasts())) {
if (!NME->isArrow())
continue;
}
}
- /*QualType Ty = I->getAssociatedDeclaration()->getType().getNonReferenceType();
+ /*QualType Ty =
+ I->getAssociatedDeclaration()->getType().getNonReferenceType();
fprintf(stderr, "expr: ");
I->getAssociatedExpression()->dumpPretty(CGF.getContext());
fprintf(stderr, "\n");
@@ -7629,11 +7644,10 @@ private:
bool LastIter = std::next(I) == CE;
const auto *OASE =
- dyn_cast<ArraySectionExpr>(I->getAssociatedExpression());
+ dyn_cast<ArraySectionExpr>(I->getAssociatedExpression());
const auto *OAShE =
- dyn_cast<OMPArrayShapingExpr>(I->getAssociatedExpression());
- const auto *UO =
- dyn_cast<UnaryOperator>(I->getAssociatedExpression());
+ dyn_cast<OMPArrayShapingExpr>(I->getAssociatedExpression());
+ const auto *UO = dyn_cast<UnaryOperator>(I->getAssociatedExpression());
bool IsDeref = UO && UO->getOpcode() == UO_Deref;
// A final array section, is one whose length can't be proved to be one.
@@ -7643,37 +7657,38 @@ private:
!IsNonContiguous &&
isFinalArraySectionExpression(I->getAssociatedExpression());
- // If we have a declaration for the mapping use that, otherwise use
+ // If we have a declaration for the mapping use that, otherwise use
// the base declaration of the map clause.
const ValueDecl *MapDecl = (I->getAssociatedDeclaration())
? I->getAssociatedDeclaration()
: BaseDecl;
- //if (OASE)
- // ++DimSize;
+ // if (OASE)
+ // ++DimSize;
if (LastIter || I.isRef() || I.isPointer(false) || IsFinalArraySection) {
Address LB = Address::invalid();
- //Address LowestElem = Address::invalid();
+ // Address LowestElem = Address::invalid();
if (OAShE) {
- /*LowestElem = */LB =
+ /*LowestElem = */ LB =
Address(CGF.EmitScalarExpr(OAShE->getBase()),
- CGF.ConvertTypeForMem(OAShE->getBase()->getType()->getPointeeType()),
- CGF.getContext().getTypeAlignInChars(
- OAShE->getBase()->getType()));
+ CGF.ConvertTypeForMem(
+ OAShE->getBase()->getType()->getPointeeType()),
+ CGF.getContext().getTypeAlignInChars(
+ OAShE->getBase()->getType()));
} else if (I.isRef()) {
const auto *ME = cast<MemberExpr>(I->getAssociatedExpression());
LValue BaseLVal = EmitMemberExprBase(CGF, ME);
/*LowestElem =*/
- LB = CGF.EmitLValueForFieldInitialization(
- BaseLVal, cast<FieldDecl>(MapDecl))
- .getAddress();
+ LB = CGF.EmitLValueForFieldInitialization(BaseLVal,
+ cast<FieldDecl>(MapDecl))
+ .getAddress();
if (I.isRefPtee())
LB = CGF.EmitLoadOfReferenceLValue(LB, MapDecl->getType())
- .getAddress();
+ .getAddress();
} else {
- /*LowestElem = */LB =
+ /*LowestElem = */ LB =
CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
.getAddress();
fprintf(stderr, "Calculated LB from: ");
@@ -7681,7 +7696,8 @@ private:
fprintf(stderr, "\n");
}
- if (MemberExpr *ME = dyn_cast<MemberExpr>(I->getAssociatedExpression())) {
+ if (MemberExpr *ME =
+ dyn_cast<MemberExpr>(I->getAssociatedExpression())) {
const MemberExpr *IME = ME;
bool Ind;
const Expr *EB = getEffectiveBase(ME, &IME, Ind);
@@ -7702,24 +7718,24 @@ private:
unsigned FieldIndex = FD->getFieldIndex();
// FIXME: Inadequate.
- //if (MemberDepth > 1) {
+ // if (MemberDepth > 1) {
// QualType Ty = ME->getBase()->getType().getNonReferenceType();
// if (Ty->isAnyPointerType()) {
// fprintf(stderr, "Indirect BP\n");
// BP = CGF.EmitLoadOfPointer(BP, Ty->castAs<PointerType>());
// }
- // }
+ // }
// Update info about the lowest and highest elements for this struct
if (!PartialStruct->Base.isValid()) {
- PartialStruct->LowestElem = {FieldIndex, LB/*LowestElem*/};
+ PartialStruct->LowestElem = {FieldIndex, LB /*LowestElem*/};
if (IsFinalArraySection && OASE) {
Address HB =
- CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/false)
- .getAddress();
+ CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/false)
+ .getAddress();
PartialStruct->HighestElem = {FieldIndex, HB};
} else {
- PartialStruct->HighestElem = {FieldIndex, LB/*LowestElem*/};
+ PartialStruct->HighestElem = {FieldIndex, LB /*LowestElem*/};
}
// This gets overridden (to the beginning of the struct) in the
// second pass, when we know if we're also mapping the whole struct.
@@ -7729,7 +7745,7 @@ private:
PartialStruct->BaseAddr = BPP;
PartialStruct->BaseExpr = EB;
} else if (FieldIndex < PartialStruct->LowestElem.first) {
- PartialStruct->LowestElem = {FieldIndex, LB/*LowestElem*/};
+ PartialStruct->LowestElem = {FieldIndex, LB /*LowestElem*/};
} else if (FieldIndex > PartialStruct->HighestElem.first) {
if (IsFinalArraySection && OASE) {
Address HB =
@@ -7737,39 +7753,41 @@ private:
.getAddress();
PartialStruct->HighestElem = {FieldIndex, HB};
} else {
- PartialStruct->HighestElem = {FieldIndex, LB/*LowestElem*/};
+ PartialStruct->HighestElem = {FieldIndex, LB /*LowestElem*/};
}
}
LastMemberExpr = ME;
}
- /*auto Next = std::next(I);
- if (Next != CE) {
- const Expr *NE = Next->getAssociatedExpression();
- bool Ind;
- const Expr *INE = indirectOnce(NE, Ind);
- if (Ind) {
- fprintf(stderr, "Indirected once, from: ");
- NE->dumpPretty(CGF.getContext());
- fprintf(stderr, "\nto: ");
- INE->dumpPretty(CGF.getContext());
- fprintf(stderr, "\n");
- if (isa<MemberExpr>(INE) ||
- isa<DeclRefExpr>(INE)) {
- fprintf(stderr, "continuing\n");
- continue;
- } else {
- fprintf(stderr, "breaking\n");
- break;
- }
+ /*auto Next = std::next(I);
+ if (Next != CE) {
+ const Expr *NE = Next->getAssociatedExpression();
+ bool Ind;
+ const Expr *INE = indirectOnce(NE, Ind);
+ if (Ind) {
+ fprintf(stderr, "Indirected once, from: ");
+ NE->dumpPretty(CGF.getContext());
+ fprintf(stderr, "\nto: ");
+ INE->dumpPretty(CGF.getContext());
+ fprintf(stderr, "\n");
+ if (isa<MemberExpr>(INE) ||
+ isa<DeclRefExpr>(INE)) {
+ fprintf(stderr, "continuing\n");
+ continue;
+ } else {
+ fprintf(stderr, "breaking\n");
+ break;
}
- }*/
+ }
+ }*/
do {
if (isa<MemberExpr>(I->getAssociatedExpression()) || LastIter) {
- EffectiveBaseMapKey IKey(CGF.getContext(), I->getAssociatedExpression(), false);
+ EffectiveBaseMapKey IKey(CGF.getContext(),
+ I->getAssociatedExpression(), false);
if (!PartialStruct) {
- assert(LastIter && "only expected null PartialStruct on last iter");
+ assert(LastIter &&
+ "only expected null PartialStruct on last iter");
if (!LastMemberExpr)
break;
bool Ind;
@@ -7777,10 +7795,11 @@ private:
EffectiveBaseMapKey EBKey(CGF.getContext(), EB, Ind);
PartialStruct = &PartialStructs[EBKey];
}
- if (PartialStruct->ChildComponents.find(IKey) == PartialStruct->ChildComponents.end()) {
+ if (PartialStruct->ChildComponents.find(IKey) ==
+ PartialStruct->ChildComponents.end()) {
int CutElems = Components.size() - I.getComponentPos() - 1;
- ArrayRef<OMPClauseMappableExprCommon::MappableComponent> Tmp =
- Components.drop_front(CutElems);
+ ArrayRef<OMPClauseMappableExprCommon::MappableComponent> Tmp =
+ Components.drop_front(CutElems);
bool CompleteExpr = CutElems == 0;
auto CI = Tmp.rbegin();
auto CE = Tmp.rend();
@@ -7790,14 +7809,16 @@ private:
I->getAssociatedExpression()->dumpPretty(CGF.getContext());
fprintf(stderr, "\n");
}
- PartialStruct->ChildComponents[IKey] = {Tmp, &MD, CompleteExpr, BP, LB};
+ PartialStruct->ChildComponents[IKey] = {Tmp, &MD, CompleteExpr,
+ BP, LB};
}
}
} while (false);
fprintf(stderr, "copy LB to BP\n");
BPP = LB;
- QualType Ty = I->getAssociatedExpression()->getType().getCanonicalType();
+ QualType Ty =
+ I->getAssociatedExpression()->getType().getCanonicalType();
if (Ty->isAnyPointerType()) {
BP = CGF.EmitLoadOfPointer(BPP, Ty->castAs<PointerType>());
} else {
@@ -8027,14 +8048,14 @@ private:
const auto *OAShE = dyn_cast<OMPArrayShapingExpr>(AssocExpr);
fprintf(stderr, "generateInfoForComponentList\n");
- //fprintf(stderr, "Preliminary data length: %d\n",
- // (int) PartialStruct.PreliminaryMapData.Exprs.size());
+ // fprintf(stderr, "Preliminary data length: %d\n",
+ // (int) PartialStruct.PreliminaryMapData.Exprs.size());
fprintf(stderr, "Combined info length: %d\n",
- (int) CombinedInfo.Exprs.size());
+ (int)CombinedInfo.Exprs.size());
- /* fprintf(stderr, "last component list entry:\n");
- std::prev(CE)->getAssociatedExpression()->dumpPretty(CGF.getContext());
- fprintf(stderr, "\n");*/
+ /* fprintf(stderr, "last component list entry:\n");
+ std::prev(CE)->getAssociatedExpression()->dumpPretty(CGF.getContext());
+ fprintf(stderr, "\n");*/
if (AreBothBasePtrAndPteeMapped && std::next(I) == CE)
return;
@@ -8150,8 +8171,8 @@ private:
bool IsPrevMemberReference = false;
- //bool IsPartialMapped =
- // !PartialStruct.PreliminaryMapData.BasePointers.empty();
+ // bool IsPartialMapped =
+ // !PartialStruct.PreliminaryMapData.BasePointers.empty();
for (; I != CE; ++I) {
// If the current component is member of a struct (parent struct) mark it.
@@ -8295,15 +8316,15 @@ private:
// PartialStruct.PreliminaryMapData.BasePointers has been mapped.
if ((!IsMemberPointerOrAddr /*&& !IsPartialMapped*/) ||
(Next == CE && MapType != OMPC_MAP_unknown)) {
- CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
- CombinedInfo.BasePointers.push_back(BP.emitRawPointer(CGF));
- CombinedInfo.DevicePtrDecls.push_back(nullptr);
- CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None);
- CombinedInfo.Pointers.push_back(LB.emitRawPointer(CGF));
- CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
- Size, CGF.Int64Ty, /*isSigned=*/true));
- CombinedInfo.NonContigInfo.Dims.push_back(IsNonContiguous ? DimSize
- : 1);
+ CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
+ CombinedInfo.BasePointers.push_back(BP.emitRawPointer(CGF));
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
+ CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None);
+ CombinedInfo.Pointers.push_back(LB.emitRawPointer(CGF));
+ CombinedInfo.Sizes.push_back(
+ CGF.Builder.CreateIntCast(Size, CGF.Int64Ty, /*isSigned=*/true));
+ CombinedInfo.NonContigInfo.Dims.push_back(IsNonContiguous ? DimSize
+ : 1);
// If Mapper is valid, the last component inherits the mapper.
bool HasMapper = Mapper && Next == CE;
CombinedInfo.Mappers.push_back(HasMapper ? Mapper : nullptr);
@@ -8380,7 +8401,7 @@ private:
#endif
// Need to emit combined struct for array sections.
- //if (IsFinalArraySection || IsNonContiguous)
+ // if (IsFinalArraySection || IsNonContiguous)
// PartialStruct.IsArraySection = true;
// If we have a final array section, we are done with this expression.
@@ -8406,7 +8427,7 @@ private:
}
// If ran into the whole component - allocate the space for the whole
// record.
- //if (!EncounteredME)
+ // if (!EncounteredME)
// PartialStruct.HasCompleteRecord = true;
if (!IsNonContiguous)
@@ -8685,8 +8706,7 @@ private:
void getFieldOffsets(const CXXRecordDecl *RD,
llvm::DenseMap<const FieldDecl *, uint64_t> &Layout,
llvm::SmallPtrSetImpl<const CXXRecordDecl *> &Processed,
- uint64_t ParentOffset,
- bool AsBase) const {
+ uint64_t ParentOffset, bool AsBase) const {
const CGRecordLayout &RL = CGF.getTypes().getCGRecordLayout(RD);
fprintf(stderr, "Getting field offsets for decl:\n");
@@ -8695,8 +8715,7 @@ private:
llvm::StructType *St =
AsBase ? RL.getBaseSubobjectLLVMType() : RL.getLLVMType();
auto &DL = CGF.CGM.getDataLayout();
- const llvm::StructLayout *SL =
- DL.getStructLayout(St);
+ const llvm::StructLayout *SL = DL.getStructLayout(St);
Processed.insert(RD);
@@ -8734,10 +8753,14 @@ private:
unsigned FieldIndex = RL.getLLVMFieldNo(Field);
RecordLayout[FieldIndex] = Field;
if (Field->getType().getCanonicalType().getTypePtr()->isRecordType()) {
- const CXXRecordDecl *RD2 = Field->getType().getCanonicalType().getTypePtr()->getAsCXXRecordDecl();
+ const CXXRecordDecl *RD2 = Field->getType()
+ .getCanonicalType()
+ .getTypePtr()
+ ->getAsCXXRecordDecl();
if (!Processed.contains(RD2)) {
llvm::TypeSize Offset = SL->getElementOffset(FieldIndex);
- getFieldOffsets(RD2, Layout, Processed, ParentOffset + Offset, /*AsBase=*/true);
+ getFieldOffsets(RD2, Layout, Processed, ParentOffset + Offset,
+ /*AsBase=*/true);
}
}
}
@@ -8756,7 +8779,7 @@ private:
}
} else {
const auto *FD = cast<const FieldDecl *>(Data);
- //const auto *RD = FD->getParent();
+ // const auto *RD = FD->getParent();
unsigned FieldNo = RL.getLLVMFieldNo(FD);
llvm::TypeSize FieldOffset = SL->getElementOffset(FieldNo);
if (Layout.find(FD) == Layout.end()) {
@@ -9122,11 +9145,11 @@ private:
}
// If there is an entry in PartialStruct it means we have a struct with
// individual members mapped. Emit an extra combined entry. FIXME.
- //if (PartialStruct.Base.isValid()) {
+ // if (PartialStruct.Base.isValid()) {
// CurInfo.NonContigInfo.Dims.push_back(0);
// emitCombinedEntry(CombinedInfo, CurInfo.Types, PartialStruct,
// /*IsMapThis*/ !VD, OMPBuilder, VD);
- // }
+ // }
// We need to append the results of this capture to what we already
// have.
@@ -9195,7 +9218,8 @@ public:
llvm::OpenMPIRBuilder &OMPBuilder,
const ValueDecl *VD = nullptr,
unsigned OffsetForMemberOfFlag = 0,
- OpenMPOffloadMappingFlags Flags = OpenMPOffloadMappingFlags::OMP_MAP_NONE) const {
+ OpenMPOffloadMappingFlags Flags =
+ OpenMPOffloadMappingFlags::OMP_MAP_NONE) const {
fprintf(stderr, "emitCombinedEntry\n");
if (CurTypes.size() == 1 &&
((CurTypes.back() & OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF) !=
@@ -9211,9 +9235,11 @@ public:
CombinedInfo.Exprs.push_back(VD);
// Base is the base of the struct
if (Flags == OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ)
- CombinedInfo.BasePointers.push_back(PartialStruct.BaseAddr.emitRawPointer(CGF));
+ CombinedInfo.BasePointers.push_back(
+ PartialStruct.BaseAddr.emitRawPointer(CGF));
else
- CombinedInfo.BasePointers.push_back(PartialStruct.Base.emitRawPointer(CGF));
+ CombinedInfo.BasePointers.push_back(
+ PartialStruct.Base.emitRawPointer(CGF));
CombinedInfo.DevicePtrDecls.push_back(nullptr);
CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None);
// Pointer is the address of the lowest element
@@ -9253,10 +9279,10 @@ public:
CombinedInfo.Mappers.push_back(nullptr);
// Map type is always TARGET_PARAM, if generate info for captures.
CombinedInfo.Types.push_back(Flags);
- //NotTargetParams ? OpenMPOffloadMappingFlags::OMP_MAP_NONE
- //: /*!PartialStruct.PreliminaryMapData.BasePointers.empty()
- // ? OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ
- // :*/ OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM);
+ // NotTargetParams ? OpenMPOffloadMappingFlags::OMP_MAP_NONE
+ //: /*!PartialStruct.PreliminaryMapData.BasePointers.empty()
+ // ? OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ
+ // :*/ OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM);
// If any element has the present modifier, then make sure the runtime
// doesn't attempt to allocate the struct.
if (CurTypes.end() !=
@@ -9437,8 +9463,7 @@ public:
void generateInfoForCaptureFromClauseInfo(
const CapturedStmt::Capture *Cap, llvm::Value *Arg,
MapCombinedInfoTy &CurCaptureVarInfo, PartialStructMap &PartialStructs,
- llvm::OpenMPIRBuilder &OMPBuilder,
- unsigned OffsetForMemberOfFlag) const {
+ llvm::OpenMPIRBuilder &OMPBuilder, unsigned OffsetForMemberOfFlag) const {
assert(!Cap->capturesVariableArrayType() &&
"Not expecting to generate map info for a variable array type!");
@@ -9540,21 +9565,21 @@ public:
return;
generateInfoForCaptureFromComponentLists(
- OMPBuilder, VD, DeclComponentLists, CurInfoForComponentLists, PartialStructs,
- IsEligibleForTargetParamFlag,
+ OMPBuilder, VD, DeclComponentLists, CurInfoForComponentLists,
+ PartialStructs, IsEligibleForTargetParamFlag,
/*AreBothBasePtrAndPteeMapped=*/HasMapBasePtr && HasMapArraySec);
// 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()) {
+ // if (PartialStruct.Base.isValid()) {
// CurCaptureVarInfo.append(PartialStruct.PreliminaryMapData);
// emitCombinedEntry(
// CurCaptureVarInfo, CurInfoForComponentLists.Types,
// PartialStruct, Cap->capturesThis(), OMPBuilder, nullptr,
// OffsetForMemberOfFlag,
// /*NotTargetParams*/ !IsEligibleForTargetParamFlag);
- // }
+ // }
// Return if we didn't add any entries.
if (CurInfoForComponentLists.BasePointers.empty())
@@ -9571,7 +9596,8 @@ public:
/// mappers associated to \a DeclComponentLists for a given capture
/// \a VD (all included in \a CurComponentListInfo).
void generateInfoForCaptureFromComponentLists(
- llvm::OpenMPIRBuilder &OMPBuilder, const ValueDecl *VD, ArrayRef<MapData> DeclComponentLists,
+ llvm::OpenMPIRBuilder &OMPBuilder, const ValueDecl *VD,
+ ArrayRef<MapData> DeclComponentLists,
MapCombinedInfoTy &CurComponentListInfo, PartialStructMap &PartialStructs,
bool IsListEligibleForTargetParamFlag,
bool AreBothBasePtrAndPteeMapped = false) const {
@@ -9696,7 +9722,7 @@ public:
return *It == FD1;
});
}
- #endif
+#endif
fprintf(stderr, "Gather structs, pass 1\n");
@@ -9768,8 +9794,7 @@ public:
}
}
if (CheckLength) {
- if (ArrayBase->getType()->isArrayType() &&
- !ASecE->getLength()) {
+ if (ArrayBase->getType()->isArrayType() && !ASecE->getLength()) {
MapExpr = ArrayBase;
} else if (ASecE->getLength()) {
const Expr *Upper = ASecE->getLength();
@@ -9800,15 +9825,17 @@ public:
QualType Ty = PartialStruct->BaseExpr->getType().getCanonicalType();
fprintf(stderr, "BaseExpr Type:\n");
Ty.dump();
- //if (PartialStruct->MemberDepth > 1) {
- // PartialStruct->LB =
- // CGF.EmitLoadOfPointer(PartialStruct->Base, Ty->castAs<PointerType>());
- //} else {
- // The first one is indirected already.
- PartialStruct->LB = CGF.EmitLoadOfPointer(PartialStruct->BaseAddr, Ty->castAs<PointerType>());
- ProcessedMappings.insert(&L);
+ // if (PartialStruct->MemberDepth > 1) {
+ // PartialStruct->LB =
+ // CGF.EmitLoadOfPointer(PartialStruct->Base,
+ // Ty->castAs<PointerType>());
+ // } else {
+ // The first one is indirected already.
+ PartialStruct->LB = CGF.EmitLoadOfPointer(PartialStruct->BaseAddr,
+ Ty->castAs<PointerType>());
+ ProcessedMappings.insert(&L);
//} else {
- // }
+ // }
}
}
@@ -9818,7 +9845,8 @@ public:
llvm::DenseMap<const FieldDecl *, uint64_t> Layout;
- const Type *BaseType = PartialStruct.BaseExpr->getType().getCanonicalType().getTypePtr();
+ const Type *BaseType =
+ PartialStruct.BaseExpr->getType().getCanonicalType().getTypePtr();
const Type *OrigType = BaseType->getPointeeOrArrayElementType();
while (BaseType != OrigType) {
@@ -9833,85 +9861,86 @@ public:
assert(false && "Not CXX record decl");
}
- llvm::stable_sort(PartialStruct.ChildComponents,
- [this, &Layout](auto &a, auto &b) {
- OMPClauseMappableExprCommon::MappableExprComponentListRef First = a.second.Components;
- OMPClauseMappableExprCommon::MappableExprComponentListRef Second = b.second.Components;
-
- auto CI = First.begin();
- auto CE = First.end();
- auto SI = Second.begin();
- auto SE = Second.end();
-
- // We may have a member expression, or an ArraySectionExpr. Find the
- // outermost member expression.
- while (CI != CE) {
- if (isa<MemberExpr>(CI->getAssociatedExpression()))
- break;
- else
- ++CI;
- }
+ llvm::stable_sort(
+ PartialStruct.ChildComponents, [this, &Layout](auto &a, auto &b) {
+ OMPClauseMappableExprCommon::MappableExprComponentListRef First =
+ a.second.Components;
+ OMPClauseMappableExprCommon::MappableExprComponentListRef Second =
+ b.second.Components;
+
+ auto CI = First.begin();
+ auto CE = First.end();
+ auto SI = Second.begin();
+ auto SE = Second.end();
+
+ // We may have a member expression, or an ArraySectionExpr. Find the
+ // outermost member expression.
+ while (CI != CE) {
+ if (isa<MemberExpr>(CI->getAssociatedExpression()))
+ break;
+ else
+ ++CI;
+ }
- if (CI == CE)
- return false;
+ if (CI == CE)
+ return false;
- while (SI != SE) {
- if (isa<MemberExpr>(SI->getAssociatedExpression()))
- break;
- else
- ++SI;
- }
+ while (SI != SE) {
+ if (isa<MemberExpr>(SI->getAssociatedExpression()))
+ break;
+ else
+ ++SI;
+ }
- if (SI == SE)
- return false;
+ if (SI == SE)
+ return false;
- fprintf(stderr, "Compare CI expr: ");
- CI->getAssociatedExpression()->dumpPretty(CGF.getContext());
- fprintf(stderr, "\nwith SI expr: ");
- SI->getAssociatedExpression()->dumpPretty(CGF.getContext());
- fprintf(stderr, "\n");
+ fprintf(stderr, "Compare CI expr: ");
+ CI->getAssociatedExpression()->dumpPretty(CGF.getContext());
+ fprintf(stderr, "\nwith SI expr: ");
+ SI->getAssociatedExpression()->dumpPretty(CGF.getContext());
+ fprintf(stderr, "\n");
- const auto *FD1 = cast<FieldDecl>(CI->getAssociatedDeclaration());
- const auto *FD2 = cast<FieldDecl>(SI->getAssociatedDeclaration());
+ const auto *FD1 = cast<FieldDecl>(CI->getAssociatedDeclaration());
+ const auto *FD2 = cast<FieldDecl>(SI->getAssociatedDeclaration());
- /*while (auto *ME = dyn_cast<MemberExpr>(CI->getAssociatedExpression())) {
- if (ME->isArrow())
- break;
- auto *Next = std::next(CI);
- if (Next == CE)
- break;
- if (isa<MemberExpr>(Next->getAssociatedExpression()))
- ++CI;
- else
- break;
- }
+ /*while (auto *ME =
+ dyn_cast<MemberExpr>(CI->getAssociatedExpression())) { if
+ (ME->isArrow()) break; auto *Next = std::next(CI); if (Next == CE)
+ break;
+ if (isa<MemberExpr>(Next->getAssociatedExpression()))
+ ++CI;
+ else
+ break;
+ }
- while (auto *ME = dyn_cast<MemberExpr>(SI->getAssociatedExpression())) {
- if (ME->isArrow())
- break;
- auto *Next = std::next(SI);
- if (Next == SE)
- break;
- if (isa<MemberExpr>(Next->getAssociatedExpression()))
- ++SI;
- else
- break;
- }
+ while (auto *ME =
+ dyn_cast<MemberExpr>(SI->getAssociatedExpression())) { if
+ (ME->isArrow()) break; auto *Next = std::next(SI); if (Next == SE)
+ break;
+ if (isa<MemberExpr>(Next->getAssociatedExpression()))
+ ++SI;
+ else
+ break;
+ }
- const RecordDecl *RD = FD1->getParent();
- const RecordDecl *RD2 = FD2->getParent();
+ const RecordDecl *RD = FD1->getParent();
+ const RecordDecl *RD2 = FD2->getParent();
- assert(RD == RD2 && "expected the same record decl");
+ assert(RD == RD2 && "expected the same record decl");
- const ASTRecordLayout &RL = CGF.getContext().getASTRecordLayout(RD);*/
- uint64_t FieldOffset1 = Layout[FD1];
- uint64_t FieldOffset2 = Layout[FD2];
+ const ASTRecordLayout &RL =
+ CGF.getContext().getASTRecordLayout(RD);*/
+ uint64_t FieldOffset1 = Layout[FD1];
+ uint64_t FieldOffset2 = Layout[FD2];
- fprintf(stderr, "Field offset 1: %llu\n", (unsigned long long) FieldOffset1);
- fprintf(stderr, "Field offset 2: %llu\n", (unsigned long long) FieldOffset2);
+ fprintf(stderr, "Field offset 1: %llu\n",
+ (unsigned long long)FieldOffset1);
+ fprintf(stderr, "Field offset 2: %llu\n",
+ (unsigned long long)FieldOffset2);
- return FieldOffset2 > FieldOffset1;
- });
+ return FieldOffset2 > FieldOffset1;
+ });
}
// FIXME
@@ -9930,8 +9959,7 @@ public:
return FirstInfo.MemberDepth < SecondInfo.MemberDepth;
});
- auto &&EmitMemberExprBase = [](CodeGenFunction &CGF,
- const MemberExpr *E) {
+ auto &&EmitMemberExprBase = [](CodeGenFunction &CGF, const MemberExpr *E) {
const Expr *BaseExpr = E->getBase();
// If this is s.x, emit s as an lvalue. If it is s->x, emit s as a
// scalar.
@@ -9956,26 +9984,30 @@ public:
auto &PartialStruct = PartialStructs[Ord];
MapCombinedInfoTy CombinedInfo;
- fprintf(stderr, "A partial struct (depth %d):\n", PartialStruct.MemberDepth);
+ fprintf(stderr, "A partial struct (depth %d):\n",
+ PartialStruct.MemberDepth);
if (PartialStruct.Base.isValid()) {
llvm::dbgs() << "Base expr: ";
PartialStruct.BaseExpr->dumpPretty(CGF.getContext());
fprintf(stderr, "\n");
llvm::dbgs() << "Name: " << PartialStruct.Base.getName() << "\n";
- llvm::dbgs() << "Is valid: " << (PartialStruct.Base.isValid() ? "true" : "false") << "\n";
+ llvm::dbgs() << "Is valid: "
+ << (PartialStruct.Base.isValid() ? "true" : "false")
+ << "\n";
} else {
llvm::dbgs() << "(no base set)\n";
}
llvm::dbgs() << "Lo elem: " << PartialStruct.LowestElem.first << "\n";
llvm::dbgs() << "Hi elem: " << PartialStruct.HighestElem.first << "\n";
- //CombinedInfo.append(PartialStruct.PreliminaryMapData);
+ // CombinedInfo.append(PartialStruct.PreliminaryMapData);
fprintf(stderr, "Child components:\n");
for (auto &CC : PartialStruct.ChildComponents) {
auto Comp = CC.second.Components;
Comp[0].getAssociatedExpression()->dumpPretty(CGF.getContext());
fprintf(stderr, "\n");
}
- fprintf(stderr, "Map whole struct: %s\n", PartialStruct.ContainingStructMap ? "yes" : "no");
+ fprintf(stderr, "Map whole struct: %s\n",
+ PartialStruct.ContainingStructMap ? "yes" : "no");
if (PartialStruct.ContainingStructMap) {
OMPClauseMappableExprCommon::MappableExprComponentListRef Components;
@@ -9984,9 +10016,10 @@ public:
bool IsImplicit;
const ValueDecl *Mapper;
const Expr *MapExpr;
- std::tie(Components, MapType, MapModifiers, IsImplicit, Mapper, MapExpr) =
- *PartialStruct.ContainingStructMap;
- const Type *BaseType = PartialStruct.BaseExpr->getType().getCanonicalType().getTypePtr();
+ std::tie(Components, MapType, MapModifiers, IsImplicit, Mapper,
+ MapExpr) = *PartialStruct.ContainingStructMap;
+ const Type *BaseType =
+ PartialStruct.BaseExpr->getType().getCanonicalType().getTypePtr();
const Type *OrigType = BaseType->getPointeeOrArrayElementType();
while (BaseType != OrigType) {
@@ -10003,18 +10036,18 @@ public:
PartialStruct.Base, CGF.VoidPtrTy, CGF.Int8Ty),
TypeSize.getQuantity() - 1);
PartialStruct.HighestElem = {
- std::numeric_limits<decltype(
- PartialStruct.HighestElem.first)>::max(),
+ std::numeric_limits<
+ decltype(PartialStruct.HighestElem.first)>::max(),
HB};
OpenMPOffloadMappingFlags Flags =
OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF |
getMapTypeBits(MapType, MapModifiers, {}, IsImplicit,
- /*AddPtrFlag=*/false,
- /*AddIsTargetParamFlag=*/false, IsNonContiguous);
+ /*AddPtrFlag=*/false,
+ /*AddIsTargetParamFlag=*/false, IsNonContiguous);
fprintf(stderr, "Starting CopyGaps...\n");
- CopyOverlappedEntryGaps CopyGaps(CGF, CombinedInfo, Flags, nullptr,
- PartialStruct.BaseExpr, PartialStruct.Base,
- PartialStruct.LB, IsNonContiguous, DimSize);
+ CopyOverlappedEntryGaps CopyGaps(
+ CGF, CombinedInfo, Flags, nullptr, PartialStruct.BaseExpr,
+ PartialStruct.Base, PartialStruct.LB, IsNonContiguous, DimSize);
llvm::DenseMap<const FieldDecl *, uint64_t> Layout;
@@ -10026,7 +10059,8 @@ public:
}
for (auto &CC : PartialStruct.ChildComponents) {
- const OMPClauseMappableExprCommon::MappableComponent &MC = CC.second.Components.front();
+ const OMPClauseMappableExprCommon::MappableComponent &MC =
+ CC.second.Components.front();
if (const ValueDecl *VD = MC.getAssociatedDeclaration()) {
if (const auto *FD = dyn_cast<FieldDecl>(VD)) {
CopyGaps.processField(MC, Layout, FD, EmitMemberExprBase);
@@ -10039,7 +10073,7 @@ public:
for (auto &CC : PartialStruct.ChildComponents) {
MappableExprMetadata Metadata = CC.second;
auto Field = Metadata.Components.front().getAssociatedExpression();
- // Address Ptr = CGF.EmitOMPSharedLValue(Field).getAddress();
+ // Address Ptr = CGF.EmitOMPSharedLValue(Field).getAddress();
llvm::Value *Size = getExprTypeSize(Field);
fprintf(stderr, "Emitting expr: ");
@@ -10053,47 +10087,50 @@ public:
bool IsImplicit;
const ValueDecl *Mapper;
const Expr *MapExpr;
- //if (PartialStruct.ContainingStructMap) {
- // std::tie(Components, MapType, MapModifiers, IsImplicit, Mapper, MapExpr) =
- // *PartialStruct.ContainingStructMap;
- //} else {
- std::tie(Components, MapType, MapModifiers, IsImplicit, Mapper, MapExpr) =
- *Metadata.MD;
+ // if (PartialStruct.ContainingStructMap) {
+ // std::tie(Components, MapType, MapModifiers, IsImplicit, Mapper,
+ // MapExpr) =
+ // *PartialStruct.ContainingStructMap;
+ // } else {
+ std::tie(Components, MapType, MapModifiers, IsImplicit, Mapper,
+ MapExpr) = *Metadata.MD;
//}
CombinedInfo.Exprs.push_back(nullptr);
- CombinedInfo.BasePointers.push_back(Metadata.Base.emitRawPointer(CGF));
+ CombinedInfo.BasePointers.push_back(
+ Metadata.Base.emitRawPointer(CGF));
CombinedInfo.DevicePtrDecls.push_back(nullptr);
CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None);
CombinedInfo.Pointers.push_back(Metadata.Pointer.emitRawPointer(CGF));
- CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
- Size, CGF.Int64Ty, /*isSigned=*/true));
- CombinedInfo.NonContigInfo.Dims.push_back(IsNonContiguous ? DimSize : 1);
+ CombinedInfo.Sizes.push_back(
+ CGF.Builder.CreateIntCast(Size, CGF.Int64Ty, /*isSigned=*/true));
+ CombinedInfo.NonContigInfo.Dims.push_back(IsNonContiguous ? DimSize
+ : 1);
CombinedInfo.Mappers.push_back(nullptr);
bool PointerAndObj = false;
- if (isa<ArraySectionExpr>(Field) ||
- isa<ArraySubscriptExpr>(Field) ||
- isa<OMPArrayShapingExpr>(Field) ||
- isa<UnaryOperator>(Field))
+ if (isa<ArraySectionExpr>(Field) || isa<ArraySubscriptExpr>(Field) ||
+ isa<OMPArrayShapingExpr>(Field) || isa<UnaryOperator>(Field))
PointerAndObj = true;
OpenMPOffloadMappingFlags Flags =
- getMapTypeBits(MapType, MapModifiers, {}, IsImplicit, PointerAndObj, false, IsNonContiguous);
+ getMapTypeBits(MapType, MapModifiers, {}, IsImplicit,
+ PointerAndObj, false, IsNonContiguous);
Flags |= OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF;
CombinedInfo.Types.push_back(Flags);
- fprintf(stderr, "Marking %p as processed\n", (void*) Metadata.MD);
+ fprintf(stderr, "Marking %p as processed\n", (void *)Metadata.MD);
ProcessedMappings.insert(Metadata.MD);
}
}
if (ParamFlag || !PartialStruct.ContainingStructMap) {
- OpenMPOffloadMappingFlags Flags = ParamFlag ? OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM
- : OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ;
- emitCombinedEntry(CurComponentListInfo, CombinedInfo.Types, PartialStruct,
- false, OMPBuilder, VD, 0, Flags);
+ OpenMPOffloadMappingFlags Flags =
+ ParamFlag ? OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM
+ : OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ;
+ emitCombinedEntry(CurComponentListInfo, CombinedInfo.Types,
+ PartialStruct, false, OMPBuilder, VD, 0, Flags);
} else {
OpenMPOffloadMappingFlags MemberOfFlag = OMPBuilder.getMemberOfFlag(
CurComponentListInfo.BasePointers.size() - 1);
@@ -10106,7 +10143,7 @@ public:
}
fprintf(stderr, "That's all\n");
- #if 0
+#if 0
// Associated with a capture, because the mapping flags depend on it.
// Go through all of the elements with the overlapped elements.
bool AddTargetParamFlag = IsListEligibleForTargetParamFlag;
@@ -10130,7 +10167,7 @@ public:
/*ForDeviceAddr=*/false, VD, VarRef, OverlappedComponents);
AddTargetParamFlag = false;
}
- #endif
+#endif
// FIXME: Check this.
bool AddTargetParamFlag = IsListEligibleForTargetParamFlag;
@@ -10139,7 +10176,7 @@ public:
for (const MapData &L : DeclComponentLists) {
if (ProcessedMappings.contains(&L)) {
fprintf(stderr, "Already processed map data for %p, skipping\n",
- (void*) &L);
+ (void *)&L);
continue;
}
@@ -10151,15 +10188,16 @@ public:
const Expr *VarRef;
std::tie(Components, MapType, MapModifiers, IsImplicit, Mapper, VarRef) =
L;
- //auto It = OverlappedData.find(&L);
- //if (It == OverlappedData.end()) {
- fprintf(stderr, "*** From generateInfoForCaptureFromComponentLists (non-overlapped)...\n");
+ // auto It = OverlappedData.find(&L);
+ // if (It == OverlappedData.end()) {
+ fprintf(stderr, "*** From generateInfoForCaptureFromComponentLists "
+ "(non-overlapped)...\n");
#if 1
- generateInfoForComponentList(
- MapType, MapModifiers, {}, Components, CurComponentListInfo,
- PartialStructs, AddTargetParamFlag, IsImplicit, Mapper,
- /*ForDeviceAddr=*/false, VD, VarRef,
- /*OverlappedElements {},*/ AreBothBasePtrAndPteeMapped);
+ generateInfoForComponentList(
+ MapType, MapModifiers, {}, Components, CurComponentListInfo,
+ PartialStructs, AddTargetParamFlag, IsImplicit, Mapper,
+ /*ForDeviceAddr=*/false, VD, VarRef,
+ /*OverlappedElements {},*/ AreBothBasePtrAndPteeMapped);
#endif
//}
AddTargetParamFlag = false;
@@ -10651,10 +10689,18 @@ static void genMapInfoForCaptures(
V->dump();
llvm::dbgs() << "\ncaptured by:\n";
switch (CI->getCaptureKind()) {
- case CapturedStmt::VCK_This: llvm::dbgs() << "this\n"; break;
- case CapturedStmt::VCK_ByRef: llvm::dbgs() << "byref\n"; break;
- case CapturedStmt::VCK_ByCopy: llvm::dbgs() << "bycopy\n"; break;
- case CapturedStmt::VCK_VLAType: llvm::dbgs() << "vlatype\n"; break;
+ case CapturedStmt::VCK_This:
+ llvm::dbgs() << "this\n";
+ break;
+ case CapturedStmt::VCK_ByRef:
+ llvm::dbgs() << "byref\n";
+ break;
+ case CapturedStmt::VCK_ByCopy:
+ llvm::dbgs() << "bycopy\n";
+ break;
+ case CapturedStmt::VCK_VLAType:
+ llvm::dbgs() << "vlatype\n";
+ break;
}
// VLA sizes are passed to the outlined region by copy and do not have map
@@ -10704,7 +10750,7 @@ static void genMapInfoForCaptures(
// If there is an entry in PartialStruct it means we have a struct with
// individual members mapped. Emit an extra combined entry. FIXME.
- //if (PartialStruct.Base.isValid()) {
+ // if (PartialStruct.Base.isValid()) {
// CombinedInfo.append(PartialStruct.PreliminaryMapData);
// MEHandler.emitCombinedEntry(CombinedInfo, CurInfo.Types, PartialStruct,
// CI->capturesThis(), OMPBuilder, nullptr,
``````````
</details>
https://github.com/llvm/llvm-project/pull/153672
More information about the cfe-commits
mailing list