@@ -7389,6 +7389,13 @@ class MappableExprsHandler {
7389
7389
SmallVector<OMPClauseMappableExprCommon::MappableExprComponentListRef, 4>>
7390
7390
DevPointersMap;
7391
7391
7392
+ /// Map between device addr declarations and their expression components.
7393
+ /// The key value for declarations in 'this' is null.
7394
+ llvm::DenseMap<
7395
+ const ValueDecl *,
7396
+ SmallVector<OMPClauseMappableExprCommon::MappableExprComponentListRef, 4>>
7397
+ HasDevAddrsMap;
7398
+
7392
7399
/// Map between lambda declarations and their map type.
7393
7400
llvm::DenseMap<const ValueDecl *, const OMPMapClause *> LambdasMap;
7394
7401
@@ -8819,6 +8826,10 @@ class MappableExprsHandler {
8819
8826
for (const auto *C : Dir.getClausesOfKind<OMPIsDevicePtrClause>())
8820
8827
for (auto L : C->component_lists())
8821
8828
DevPointersMap[std::get<0>(L)].push_back(std::get<1>(L));
8829
+ // Extract device addr clause information.
8830
+ for (const auto *C : Dir.getClausesOfKind<OMPHasDeviceAddrClause>())
8831
+ for (auto L : C->component_lists())
8832
+ HasDevAddrsMap[std::get<0>(L)].push_back(std::get<1>(L));
8822
8833
// Extract map information.
8823
8834
for (const auto *C : Dir.getClausesOfKind<OMPMapClause>()) {
8824
8835
if (C->getMapType() != OMPC_MAP_to)
@@ -9065,6 +9076,30 @@ class MappableExprsHandler {
9065
9076
CombinedInfo.Mappers.push_back(nullptr);
9066
9077
return;
9067
9078
}
9079
+ if (VD && HasDevAddrsMap.count(VD)) {
9080
+ auto I = HasDevAddrsMap.find(VD);
9081
+ CombinedInfo.Exprs.push_back(VD);
9082
+ Expr *E = nullptr;
9083
+ for (auto &MCL : I->second) {
9084
+ E = MCL.begin()->getAssociatedExpression();
9085
+ break;
9086
+ }
9087
+ llvm::Value *Ptr = nullptr;
9088
+ if (E->isGLValue())
9089
+ Ptr = CGF.EmitLValue(E).getPointer(CGF);
9090
+ else
9091
+ Ptr = CGF.EmitScalarExpr(E);
9092
+ CombinedInfo.BasePointers.emplace_back(Ptr, VD);
9093
+ CombinedInfo.Pointers.push_back(Ptr);
9094
+ CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
9095
+ CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
9096
+ /*isSigned=*/true));
9097
+ CombinedInfo.Types.push_back(
9098
+ (Cap->capturesVariable() ? OMP_MAP_TO : OMP_MAP_LITERAL) |
9099
+ OMP_MAP_TARGET_PARAM);
9100
+ CombinedInfo.Mappers.push_back(nullptr);
9101
+ return;
9102
+ }
9068
9103
9069
9104
using MapData =
9070
9105
std::tuple<OMPClauseMappableExprCommon::MappableExprComponentListRef,
@@ -9073,14 +9108,19 @@ class MappableExprsHandler {
9073
9108
SmallVector<MapData, 4> DeclComponentLists;
9074
9109
// For member fields list in is_device_ptr, store it in
9075
9110
// DeclComponentLists for generating components info.
9111
+ static const OpenMPMapModifierKind Unknown = OMPC_MAP_MODIFIER_unknown;
9076
9112
auto It = DevPointersMap.find(VD);
9077
9113
if (It != DevPointersMap.end())
9078
- for (const auto &MCL : It->second) {
9079
- static const OpenMPMapModifierKind Unknown = OMPC_MAP_MODIFIER_unknown;
9114
+ for (const auto &MCL : It->second)
9080
9115
DeclComponentLists.emplace_back(MCL, OMPC_MAP_to, Unknown,
9081
9116
/*IsImpicit = */ true, nullptr,
9082
9117
nullptr);
9083
- }
9118
+ auto I = HasDevAddrsMap.find(VD);
9119
+ if (I != HasDevAddrsMap.end())
9120
+ for (const auto &MCL : I->second)
9121
+ DeclComponentLists.emplace_back(MCL, OMPC_MAP_tofrom, Unknown,
9122
+ /*IsImpicit = */ true, nullptr,
9123
+ nullptr);
9084
9124
assert(CurDir.is<const OMPExecutableDirective *>() &&
9085
9125
"Expect a executable directive");
9086
9126
const auto *CurExecDir = CurDir.get<const OMPExecutableDirective *>();
0 commit comments