@@ -6831,67 +6831,30 @@ class MappableExprsHandler {
6831
6831
const Expr *getMapExpr() const { return MapExpr; }
6832
6832
};
6833
6833
6834
- /// Class that associates information with a base pointer to be passed to the
6835
- /// runtime library.
6836
- class BasePointerInfo {
6837
- /// The base pointer.
6838
- llvm::Value *Ptr = nullptr;
6839
- /// The base declaration that refers to this device pointer, or null if
6840
- /// there is none.
6841
- const ValueDecl *DevPtrDecl = nullptr;
6842
-
6843
- public:
6844
- BasePointerInfo(llvm::Value *Ptr, const ValueDecl *DevPtrDecl = nullptr)
6845
- : Ptr(Ptr), DevPtrDecl(DevPtrDecl) {}
6846
- llvm::Value *operator*() const { return Ptr; }
6847
- const ValueDecl *getDevicePtrDecl() const { return DevPtrDecl; }
6848
- void setDevicePtrDecl(const ValueDecl *D) { DevPtrDecl = D; }
6849
- };
6850
-
6834
+ using MapBaseValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
6835
+ using MapValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
6836
+ using MapFlagsArrayTy = llvm::OpenMPIRBuilder::MapFlagsArrayTy;
6837
+ using MapDimArrayTy = llvm::OpenMPIRBuilder::MapDimArrayTy;
6838
+ using MapNonContiguousArrayTy =
6839
+ llvm::OpenMPIRBuilder::MapNonContiguousArrayTy;
6851
6840
using MapExprsArrayTy = SmallVector<MappingExprInfo, 4>;
6852
- using MapBaseValuesArrayTy = SmallVector<BasePointerInfo, 4>;
6853
- using MapValuesArrayTy = SmallVector<llvm::Value *, 4>;
6854
- using MapFlagsArrayTy = SmallVector<OpenMPOffloadMappingFlags, 4>;
6855
- using MapMappersArrayTy = SmallVector<const ValueDecl *, 4>;
6856
- using MapDimArrayTy = SmallVector<uint64_t, 4>;
6857
- using MapNonContiguousArrayTy = SmallVector<MapValuesArrayTy, 4>;
6841
+ using MapValueDeclsArrayTy = SmallVector<const ValueDecl *, 4>;
6858
6842
6859
6843
/// This structure contains combined information generated for mappable
6860
6844
/// clauses, including base pointers, pointers, sizes, map types, user-defined
6861
6845
/// mappers, and non-contiguous information.
6862
- struct MapCombinedInfoTy {
6863
- struct StructNonContiguousInfo {
6864
- bool IsNonContiguous = false;
6865
- MapDimArrayTy Dims;
6866
- MapNonContiguousArrayTy Offsets;
6867
- MapNonContiguousArrayTy Counts;
6868
- MapNonContiguousArrayTy Strides;
6869
- };
6846
+ struct MapCombinedInfoTy : llvm::OpenMPIRBuilder::MapInfosTy {
6870
6847
MapExprsArrayTy Exprs;
6871
- MapBaseValuesArrayTy BasePointers;
6872
- MapValuesArrayTy Pointers;
6873
- MapValuesArrayTy Sizes;
6874
- MapFlagsArrayTy Types;
6875
- MapMappersArrayTy Mappers;
6876
- StructNonContiguousInfo NonContigInfo;
6848
+ MapValueDeclsArrayTy Mappers;
6849
+ MapValueDeclsArrayTy DevicePtrDecls;
6877
6850
6878
6851
/// Append arrays in \a CurInfo.
6879
6852
void append(MapCombinedInfoTy &CurInfo) {
6880
6853
Exprs.append(CurInfo.Exprs.begin(), CurInfo.Exprs.end());
6881
- BasePointers.append(CurInfo.BasePointers.begin(),
6882
- CurInfo.BasePointers.end());
6883
- Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
6884
- Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
6885
- Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
6854
+ DevicePtrDecls.append(CurInfo.DevicePtrDecls.begin(),
6855
+ CurInfo.DevicePtrDecls.end());
6886
6856
Mappers.append(CurInfo.Mappers.begin(), CurInfo.Mappers.end());
6887
- NonContigInfo.Dims.append(CurInfo.NonContigInfo.Dims.begin(),
6888
- CurInfo.NonContigInfo.Dims.end());
6889
- NonContigInfo.Offsets.append(CurInfo.NonContigInfo.Offsets.begin(),
6890
- CurInfo.NonContigInfo.Offsets.end());
6891
- NonContigInfo.Counts.append(CurInfo.NonContigInfo.Counts.begin(),
6892
- CurInfo.NonContigInfo.Counts.end());
6893
- NonContigInfo.Strides.append(CurInfo.NonContigInfo.Strides.begin(),
6894
- CurInfo.NonContigInfo.Strides.end());
6857
+ llvm::OpenMPIRBuilder::MapInfosTy::append(CurInfo);
6895
6858
}
6896
6859
};
6897
6860
@@ -7638,6 +7601,7 @@ class MappableExprsHandler {
7638
7601
assert(Size && "Failed to determine structure size");
7639
7602
CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
7640
7603
CombinedInfo.BasePointers.push_back(BP.getPointer());
7604
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
7641
7605
CombinedInfo.Pointers.push_back(LB.getPointer());
7642
7606
CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
7643
7607
Size, CGF.Int64Ty, /*isSigned=*/true));
@@ -7649,6 +7613,7 @@ class MappableExprsHandler {
7649
7613
}
7650
7614
CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
7651
7615
CombinedInfo.BasePointers.push_back(BP.getPointer());
7616
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
7652
7617
CombinedInfo.Pointers.push_back(LB.getPointer());
7653
7618
Size = CGF.Builder.CreatePtrDiff(
7654
7619
CGF.Int8Ty, CGF.Builder.CreateConstGEP(HB, 1).getPointer(),
@@ -7666,6 +7631,7 @@ class MappableExprsHandler {
7666
7631
(Next == CE && MapType != OMPC_MAP_unknown)) {
7667
7632
CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
7668
7633
CombinedInfo.BasePointers.push_back(BP.getPointer());
7634
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
7669
7635
CombinedInfo.Pointers.push_back(LB.getPointer());
7670
7636
CombinedInfo.Sizes.push_back(
7671
7637
CGF.Builder.CreateIntCast(Size, CGF.Int64Ty, /*isSigned=*/true));
@@ -8168,7 +8134,8 @@ class MappableExprsHandler {
8168
8134
[&UseDeviceDataCombinedInfo](const ValueDecl *VD, llvm::Value *Ptr,
8169
8135
CodeGenFunction &CGF) {
8170
8136
UseDeviceDataCombinedInfo.Exprs.push_back(VD);
8171
- UseDeviceDataCombinedInfo.BasePointers.emplace_back(Ptr, VD);
8137
+ UseDeviceDataCombinedInfo.BasePointers.emplace_back(Ptr);
8138
+ UseDeviceDataCombinedInfo.DevicePtrDecls.emplace_back(VD);
8172
8139
UseDeviceDataCombinedInfo.Pointers.push_back(Ptr);
8173
8140
UseDeviceDataCombinedInfo.Sizes.push_back(
8174
8141
llvm::Constant::getNullValue(CGF.Int64Ty));
@@ -8337,8 +8304,7 @@ class MappableExprsHandler {
8337
8304
assert(RelevantVD &&
8338
8305
"No relevant declaration related with device pointer??");
8339
8306
8340
- CurInfo.BasePointers[CurrentBasePointersIdx].setDevicePtrDecl(
8341
- RelevantVD);
8307
+ CurInfo.DevicePtrDecls[CurrentBasePointersIdx] = RelevantVD;
8342
8308
CurInfo.Types[CurrentBasePointersIdx] |=
8343
8309
OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
8344
8310
}
@@ -8377,7 +8343,8 @@ class MappableExprsHandler {
8377
8343
OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF);
8378
8344
}
8379
8345
CurInfo.Exprs.push_back(L.VD);
8380
- CurInfo.BasePointers.emplace_back(BasePtr, L.VD);
8346
+ CurInfo.BasePointers.emplace_back(BasePtr);
8347
+ CurInfo.DevicePtrDecls.emplace_back(L.VD);
8381
8348
CurInfo.Pointers.push_back(Ptr);
8382
8349
CurInfo.Sizes.push_back(
8383
8350
llvm::Constant::getNullValue(this->CGF.Int64Ty));
@@ -8472,6 +8439,7 @@ class MappableExprsHandler {
8472
8439
CombinedInfo.Exprs.push_back(VD);
8473
8440
// Base is the base of the struct
8474
8441
CombinedInfo.BasePointers.push_back(PartialStruct.Base.getPointer());
8442
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
8475
8443
// Pointer is the address of the lowest element
8476
8444
llvm::Value *LB = LBAddr.getPointer();
8477
8445
const CXXMethodDecl *MD =
@@ -8593,6 +8561,7 @@ class MappableExprsHandler {
8593
8561
VDLVal.getPointer(CGF));
8594
8562
CombinedInfo.Exprs.push_back(VD);
8595
8563
CombinedInfo.BasePointers.push_back(ThisLVal.getPointer(CGF));
8564
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
8596
8565
CombinedInfo.Pointers.push_back(ThisLValVal.getPointer(CGF));
8597
8566
CombinedInfo.Sizes.push_back(
8598
8567
CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy),
@@ -8619,6 +8588,7 @@ class MappableExprsHandler {
8619
8588
VDLVal.getPointer(CGF));
8620
8589
CombinedInfo.Exprs.push_back(VD);
8621
8590
CombinedInfo.BasePointers.push_back(VarLVal.getPointer(CGF));
8591
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
8622
8592
CombinedInfo.Pointers.push_back(VarLValVal.getPointer(CGF));
8623
8593
CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
8624
8594
CGF.getTypeSize(
@@ -8630,6 +8600,7 @@ class MappableExprsHandler {
8630
8600
VDLVal.getPointer(CGF));
8631
8601
CombinedInfo.Exprs.push_back(VD);
8632
8602
CombinedInfo.BasePointers.push_back(VarLVal.getPointer(CGF));
8603
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
8633
8604
CombinedInfo.Pointers.push_back(VarRVal.getScalarVal());
8634
8605
CombinedInfo.Sizes.push_back(llvm::ConstantInt::get(CGF.Int64Ty, 0));
8635
8606
}
@@ -8654,7 +8625,7 @@ class MappableExprsHandler {
8654
8625
OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF |
8655
8626
OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT))
8656
8627
continue;
8657
- llvm::Value *BasePtr = LambdaPointers.lookup(* BasePointers[I]);
8628
+ llvm::Value *BasePtr = LambdaPointers.lookup(BasePointers[I]);
8658
8629
assert(BasePtr && "Unable to find base lambda address.");
8659
8630
int TgtIdx = -1;
8660
8631
for (unsigned J = I; J > 0; --J) {
@@ -8696,7 +8667,8 @@ class MappableExprsHandler {
8696
8667
// pass its value.
8697
8668
if (VD && (DevPointersMap.count(VD) || HasDevAddrsMap.count(VD))) {
8698
8669
CombinedInfo.Exprs.push_back(VD);
8699
- CombinedInfo.BasePointers.emplace_back(Arg, VD);
8670
+ CombinedInfo.BasePointers.emplace_back(Arg);
8671
+ CombinedInfo.DevicePtrDecls.emplace_back(VD);
8700
8672
CombinedInfo.Pointers.push_back(Arg);
8701
8673
CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
8702
8674
CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
@@ -8938,6 +8910,7 @@ class MappableExprsHandler {
8938
8910
if (CI.capturesThis()) {
8939
8911
CombinedInfo.Exprs.push_back(nullptr);
8940
8912
CombinedInfo.BasePointers.push_back(CV);
8913
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
8941
8914
CombinedInfo.Pointers.push_back(CV);
8942
8915
const auto *PtrTy = cast<PointerType>(RI.getType().getTypePtr());
8943
8916
CombinedInfo.Sizes.push_back(
@@ -8950,6 +8923,7 @@ class MappableExprsHandler {
8950
8923
const VarDecl *VD = CI.getCapturedVar();
8951
8924
CombinedInfo.Exprs.push_back(VD->getCanonicalDecl());
8952
8925
CombinedInfo.BasePointers.push_back(CV);
8926
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
8953
8927
CombinedInfo.Pointers.push_back(CV);
8954
8928
if (!RI.getType()->isAnyPointerType()) {
8955
8929
// We have to signal to the runtime captures passed by value that are
@@ -8981,6 +8955,7 @@ class MappableExprsHandler {
8981
8955
auto I = FirstPrivateDecls.find(VD);
8982
8956
CombinedInfo.Exprs.push_back(VD->getCanonicalDecl());
8983
8957
CombinedInfo.BasePointers.push_back(CV);
8958
+ CombinedInfo.DevicePtrDecls.push_back(nullptr);
8984
8959
if (I != FirstPrivateDecls.end() && ElementType->isAnyPointerType()) {
8985
8960
Address PtrAddr = CGF.EmitLoadOfReference(CGF.MakeAddrLValue(
8986
8961
CV, ElementType, CGF.getContext().getDeclAlign(VD),
@@ -9266,7 +9241,7 @@ static void emitOffloadingArrays(
9266
9241
}
9267
9242
9268
9243
for (unsigned I = 0; I < Info.NumberOfPtrs; ++I) {
9269
- llvm::Value *BPVal = * CombinedInfo.BasePointers[I];
9244
+ llvm::Value *BPVal = CombinedInfo.BasePointers[I];
9270
9245
llvm::Value *BP = CGF.Builder.CreateConstInBoundsGEP2_32(
9271
9246
llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
9272
9247
Info.RTArgs.BasePointersArray, 0, I);
@@ -9277,8 +9252,7 @@ static void emitOffloadingArrays(
9277
9252
CGF.Builder.CreateStore(BPVal, BPAddr);
9278
9253
9279
9254
if (Info.requiresDevicePointerInfo())
9280
- if (const ValueDecl *DevVD =
9281
- CombinedInfo.BasePointers[I].getDevicePtrDecl())
9255
+ if (const ValueDecl *DevVD = CombinedInfo.DevicePtrDecls[I])
9282
9256
Info.CaptureDeviceAddrMap.try_emplace(DevVD, BPAddr);
9283
9257
9284
9258
llvm::Value *PVal = CombinedInfo.Pointers[I];
@@ -9592,7 +9566,7 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
9592
9566
// Fill up the runtime mapper handle for all components.
9593
9567
for (unsigned I = 0; I < Info.BasePointers.size(); ++I) {
9594
9568
llvm::Value *CurBaseArg = MapperCGF.Builder.CreateBitCast(
9595
- * Info.BasePointers[I], CGM.getTypes().ConvertTypeForMem(C.VoidPtrTy));
9569
+ Info.BasePointers[I], CGM.getTypes().ConvertTypeForMem(C.VoidPtrTy));
9596
9570
llvm::Value *CurBeginArg = MapperCGF.Builder.CreateBitCast(
9597
9571
Info.Pointers[I], CGM.getTypes().ConvertTypeForMem(C.VoidPtrTy));
9598
9572
llvm::Value *CurSizeArg = Info.Sizes[I];
@@ -10028,6 +10002,7 @@ void CGOpenMPRuntime::emitTargetCall(
10028
10002
if (CI->capturesVariableArrayType()) {
10029
10003
CurInfo.Exprs.push_back(nullptr);
10030
10004
CurInfo.BasePointers.push_back(*CV);
10005
+ CurInfo.DevicePtrDecls.push_back(nullptr);
10031
10006
CurInfo.Pointers.push_back(*CV);
10032
10007
CurInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
10033
10008
CGF.getTypeSize(RI->getType()), CGF.Int64Ty, /*isSigned=*/true));
0 commit comments