@@ -9442,7 +9442,7 @@ static void emitNonContiguousDescriptor(
9442
9442
DimsAddr, CGM.Int8PtrTy, CGM.Int8Ty);
9443
9443
llvm::Value *P = CGF.Builder.CreateConstInBoundsGEP2_32(
9444
9444
llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
9445
- Info.PointersArray, 0, I);
9445
+ Info.RTArgs. PointersArray, 0, I);
9446
9446
Address PAddr(P, CGM.VoidPtrTy, CGF.getPointerAlign());
9447
9447
CGF.Builder.CreateStore(DAddr.getPointer(), PAddr);
9448
9448
++L;
@@ -9520,13 +9520,13 @@ static void emitOffloadingArrays(
9520
9520
Ctx.VoidPtrTy, PointerNumAP, nullptr, ArrayType::Normal,
9521
9521
/*IndexTypeQuals=*/0);
9522
9522
9523
- Info.BasePointersArray =
9523
+ Info.RTArgs. BasePointersArray =
9524
9524
CGF.CreateMemTemp(PointerArrayType, ".offload_baseptrs").getPointer();
9525
- Info.PointersArray =
9525
+ Info.RTArgs. PointersArray =
9526
9526
CGF.CreateMemTemp(PointerArrayType, ".offload_ptrs").getPointer();
9527
9527
Address MappersArray =
9528
9528
CGF.CreateMemTemp(PointerArrayType, ".offload_mappers");
9529
- Info.MappersArray = MappersArray.getPointer();
9529
+ Info.RTArgs. MappersArray = MappersArray.getPointer();
9530
9530
9531
9531
// If we don't have any VLA types or other types that require runtime
9532
9532
// evaluation, we can use a constant array for the map sizes, otherwise we
@@ -9555,7 +9555,7 @@ static void emitOffloadingArrays(
9555
9555
QualType SizeArrayType = Ctx.getConstantArrayType(
9556
9556
Int64Ty, PointerNumAP, nullptr, ArrayType::Normal,
9557
9557
/*IndexTypeQuals=*/0);
9558
- Info.SizesArray =
9558
+ Info.RTArgs. SizesArray =
9559
9559
CGF.CreateMemTemp(SizeArrayType, ".offload_sizes").getPointer();
9560
9560
} else {
9561
9561
auto *SizesArrayInit = llvm::ConstantArray::get(
@@ -9579,9 +9579,9 @@ static void emitOffloadingArrays(
9579
9579
CGM.getNaturalTypeAlignment(Ctx.getIntTypeForBitwidth(
9580
9580
/*DestWidth=*/64, /*Signed=*/false))),
9581
9581
CGF.getTypeSize(SizeArrayType));
9582
- Info.SizesArray = Buffer.getPointer();
9582
+ Info.RTArgs. SizesArray = Buffer.getPointer();
9583
9583
} else {
9584
- Info.SizesArray = SizesArrayGbl;
9584
+ Info.RTArgs. SizesArray = SizesArrayGbl;
9585
9585
}
9586
9586
}
9587
9587
@@ -9593,12 +9593,12 @@ static void emitOffloadingArrays(
9593
9593
CGM.getOpenMPRuntime().getName({"offload_maptypes"});
9594
9594
auto *MapTypesArrayGbl =
9595
9595
OMPBuilder.createOffloadMaptypes(Mapping, MaptypesName);
9596
- Info.MapTypesArray = MapTypesArrayGbl;
9596
+ Info.RTArgs. MapTypesArray = MapTypesArrayGbl;
9597
9597
9598
9598
// The information types are only built if there is debug information
9599
9599
// requested.
9600
9600
if (CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo) {
9601
- Info.MapNamesArray = llvm::Constant::getNullValue(
9601
+ Info.RTArgs. MapNamesArray = llvm::Constant::getNullValue(
9602
9602
llvm::Type::getInt8Ty(CGF.Builder.getContext())->getPointerTo());
9603
9603
} else {
9604
9604
auto fillInfoMap = [&](MappableExprsHandler::MappingExprInfo &MapExpr) {
@@ -9610,7 +9610,7 @@ static void emitOffloadingArrays(
9610
9610
CGM.getOpenMPRuntime().getName({"offload_mapnames"});
9611
9611
auto *MapNamesArrayGbl =
9612
9612
OMPBuilder.createOffloadMapnames(InfoMap, MapnamesName);
9613
- Info.MapNamesArray = MapNamesArrayGbl;
9613
+ Info.RTArgs. MapNamesArray = MapNamesArrayGbl;
9614
9614
}
9615
9615
9616
9616
// If there's a present map type modifier, it must not be applied to the end
@@ -9626,15 +9626,15 @@ static void emitOffloadingArrays(
9626
9626
if (EndMapTypesDiffer) {
9627
9627
MapTypesArrayGbl =
9628
9628
OMPBuilder.createOffloadMaptypes(Mapping, MaptypesName);
9629
- Info.MapTypesArrayEnd = MapTypesArrayGbl;
9629
+ Info.RTArgs. MapTypesArrayEnd = MapTypesArrayGbl;
9630
9630
}
9631
9631
}
9632
9632
9633
9633
for (unsigned I = 0; I < Info.NumberOfPtrs; ++I) {
9634
9634
llvm::Value *BPVal = *CombinedInfo.BasePointers[I];
9635
9635
llvm::Value *BP = CGF.Builder.CreateConstInBoundsGEP2_32(
9636
9636
llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
9637
- Info.BasePointersArray, 0, I);
9637
+ Info.RTArgs. BasePointersArray, 0, I);
9638
9638
BP = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
9639
9639
BP, BPVal->getType()->getPointerTo(/*AddrSpace=*/0));
9640
9640
Address BPAddr(BP, BPVal->getType(),
@@ -9649,7 +9649,7 @@ static void emitOffloadingArrays(
9649
9649
llvm::Value *PVal = CombinedInfo.Pointers[I];
9650
9650
llvm::Value *P = CGF.Builder.CreateConstInBoundsGEP2_32(
9651
9651
llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
9652
- Info.PointersArray, 0, I);
9652
+ Info.RTArgs. PointersArray, 0, I);
9653
9653
P = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
9654
9654
P, PVal->getType()->getPointerTo(/*AddrSpace=*/0));
9655
9655
Address PAddr(P, PVal->getType(), Ctx.getTypeAlignInChars(Ctx.VoidPtrTy));
@@ -9658,7 +9658,7 @@ static void emitOffloadingArrays(
9658
9658
if (RuntimeSizes.test(I)) {
9659
9659
llvm::Value *S = CGF.Builder.CreateConstInBoundsGEP2_32(
9660
9660
llvm::ArrayType::get(CGM.Int64Ty, Info.NumberOfPtrs),
9661
- Info.SizesArray,
9661
+ Info.RTArgs. SizesArray,
9662
9662
/*Idx0=*/0,
9663
9663
/*Idx1=*/I);
9664
9664
Address SAddr(S, CGM.Int64Ty, Ctx.getTypeAlignInChars(Int64Ty));
@@ -9688,76 +9688,6 @@ static void emitOffloadingArrays(
9688
9688
emitNonContiguousDescriptor(CGF, CombinedInfo, Info);
9689
9689
}
9690
9690
9691
- namespace {
9692
- /// Additional arguments for emitOffloadingArraysArgument function.
9693
- struct ArgumentsOptions {
9694
- bool ForEndCall = false;
9695
- ArgumentsOptions() = default;
9696
- ArgumentsOptions(bool ForEndCall) : ForEndCall(ForEndCall) {}
9697
- };
9698
- } // namespace
9699
-
9700
- /// Emit the arguments to be passed to the runtime library based on the
9701
- /// arrays of base pointers, pointers, sizes, map types, and mappers. If
9702
- /// ForEndCall, emit map types to be passed for the end of the region instead of
9703
- /// the beginning.
9704
- static void emitOffloadingArraysArgument(
9705
- CodeGenFunction &CGF, llvm::Value *&BasePointersArrayArg,
9706
- llvm::Value *&PointersArrayArg, llvm::Value *&SizesArrayArg,
9707
- llvm::Value *&MapTypesArrayArg, llvm::Value *&MapNamesArrayArg,
9708
- llvm::Value *&MappersArrayArg, CGOpenMPRuntime::TargetDataInfo &Info,
9709
- const ArgumentsOptions &Options = ArgumentsOptions()) {
9710
- assert((!Options.ForEndCall || Info.separateBeginEndCalls()) &&
9711
- "expected region end call to runtime only when end call is separate");
9712
- CodeGenModule &CGM = CGF.CGM;
9713
- if (Info.NumberOfPtrs) {
9714
- BasePointersArrayArg = CGF.Builder.CreateConstInBoundsGEP2_32(
9715
- llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
9716
- Info.BasePointersArray,
9717
- /*Idx0=*/0, /*Idx1=*/0);
9718
- PointersArrayArg = CGF.Builder.CreateConstInBoundsGEP2_32(
9719
- llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
9720
- Info.PointersArray,
9721
- /*Idx0=*/0,
9722
- /*Idx1=*/0);
9723
- SizesArrayArg = CGF.Builder.CreateConstInBoundsGEP2_32(
9724
- llvm::ArrayType::get(CGM.Int64Ty, Info.NumberOfPtrs), Info.SizesArray,
9725
- /*Idx0=*/0, /*Idx1=*/0);
9726
- MapTypesArrayArg = CGF.Builder.CreateConstInBoundsGEP2_32(
9727
- llvm::ArrayType::get(CGM.Int64Ty, Info.NumberOfPtrs),
9728
- Options.ForEndCall && Info.MapTypesArrayEnd ? Info.MapTypesArrayEnd
9729
- : Info.MapTypesArray,
9730
- /*Idx0=*/0,
9731
- /*Idx1=*/0);
9732
-
9733
- // Only emit the mapper information arrays if debug information is
9734
- // requested.
9735
- if (CGF.CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo)
9736
- MapNamesArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
9737
- else
9738
- MapNamesArrayArg = CGF.Builder.CreateConstInBoundsGEP2_32(
9739
- llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
9740
- Info.MapNamesArray,
9741
- /*Idx0=*/0,
9742
- /*Idx1=*/0);
9743
- // If there is no user-defined mapper, set the mapper array to nullptr to
9744
- // avoid an unnecessary data privatization
9745
- if (!Info.HasMapper)
9746
- MappersArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
9747
- else
9748
- MappersArrayArg =
9749
- CGF.Builder.CreatePointerCast(Info.MappersArray, CGM.VoidPtrPtrTy);
9750
- } else {
9751
- BasePointersArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
9752
- PointersArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
9753
- SizesArrayArg = llvm::ConstantPointerNull::get(CGM.Int64Ty->getPointerTo());
9754
- MapTypesArrayArg =
9755
- llvm::ConstantPointerNull::get(CGM.Int64Ty->getPointerTo());
9756
- MapNamesArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
9757
- MappersArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
9758
- }
9759
- }
9760
-
9761
9691
/// Check for inner distribute directive.
9762
9692
static const OMPExecutableDirective *
9763
9693
getNestedDistributeDirective(ASTContext &Ctx, const OMPExecutableDirective &D) {
@@ -10479,25 +10409,26 @@ void CGOpenMPRuntime::emitTargetCall(
10479
10409
// weren't referenced within the construct.
10480
10410
MEHandler.generateAllInfo(CombinedInfo, MappedVarSet);
10481
10411
10482
- TargetDataInfo Info;
10412
+ CGOpenMPRuntime:: TargetDataInfo Info;
10483
10413
// Fill up the arrays and create the arguments.
10484
10414
emitOffloadingArrays(CGF, CombinedInfo, Info, OMPBuilder);
10485
- emitOffloadingArraysArgument(
10486
- CGF, Info.BasePointersArray, Info.PointersArray, Info.SizesArray,
10487
- Info.MapTypesArray, Info.MapNamesArray, Info.MappersArray, Info,
10488
- {/*ForEndCall=*/false});
10415
+ bool EmitDebug =
10416
+ CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
10417
+ OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, Info.RTArgs, Info,
10418
+ EmitDebug,
10419
+ /*ForEndCall=*/false);
10489
10420
10490
10421
InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
10491
- InputInfo.BasePointersArray =
10492
- Address(Info.BasePointersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
10493
- InputInfo.PointersArray =
10494
- Address(Info.PointersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
10422
+ InputInfo.BasePointersArray = Address(Info.RTArgs.BasePointersArray,
10423
+ CGF.VoidPtrTy, CGM.getPointerAlign());
10424
+ InputInfo.PointersArray = Address(Info.RTArgs.PointersArray, CGF.VoidPtrTy,
10425
+ CGM.getPointerAlign());
10495
10426
InputInfo.SizesArray =
10496
- Address(Info.SizesArray, CGF.Int64Ty, CGM.getPointerAlign());
10427
+ Address(Info.RTArgs. SizesArray, CGF.Int64Ty, CGM.getPointerAlign());
10497
10428
InputInfo.MappersArray =
10498
- Address(Info.MappersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
10499
- MapTypesArray = Info.MapTypesArray;
10500
- MapNamesArray = Info.MapNamesArray;
10429
+ Address(Info.RTArgs. MappersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
10430
+ MapTypesArray = Info.RTArgs. MapTypesArray;
10431
+ MapNamesArray = Info.RTArgs. MapNamesArray;
10501
10432
if (RequiresOuterTask)
10502
10433
CGF.EmitOMPTargetTaskBasedDirective(D, ThenGen, InputInfo);
10503
10434
else
@@ -11063,7 +10994,8 @@ void CGOpenMPRuntime::emitNumTeamsClause(CodeGenFunction &CGF,
11063
10994
11064
10995
void CGOpenMPRuntime::emitTargetDataCalls(
11065
10996
CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond,
11066
- const Expr *Device, const RegionCodeGenTy &CodeGen, TargetDataInfo &Info) {
10997
+ const Expr *Device, const RegionCodeGenTy &CodeGen,
10998
+ CGOpenMPRuntime::TargetDataInfo &Info) {
11067
10999
if (!CGF.HaveInsertPoint())
11068
11000
return;
11069
11001
@@ -11087,15 +11019,11 @@ void CGOpenMPRuntime::emitTargetDataCalls(
11087
11019
emitOffloadingArrays(CGF, CombinedInfo, Info, OMPBuilder,
11088
11020
/*IsNonContiguous=*/true);
11089
11021
11090
- llvm::Value *BasePointersArrayArg = nullptr;
11091
- llvm::Value *PointersArrayArg = nullptr;
11092
- llvm::Value *SizesArrayArg = nullptr;
11093
- llvm::Value *MapTypesArrayArg = nullptr;
11094
- llvm::Value *MapNamesArrayArg = nullptr;
11095
- llvm::Value *MappersArrayArg = nullptr;
11096
- emitOffloadingArraysArgument(CGF, BasePointersArrayArg, PointersArrayArg,
11097
- SizesArrayArg, MapTypesArrayArg,
11098
- MapNamesArrayArg, MappersArrayArg, Info);
11022
+ llvm::OpenMPIRBuilder::TargetDataRTArgs RTArgs;
11023
+ bool EmitDebug =
11024
+ CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
11025
+ OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, RTArgs, Info,
11026
+ EmitDebug);
11099
11027
11100
11028
// Emit device ID if any.
11101
11029
llvm::Value *DeviceID = nullptr;
@@ -11115,12 +11043,12 @@ void CGOpenMPRuntime::emitTargetDataCalls(
11115
11043
llvm::Value *OffloadingArgs[] = {RTLoc,
11116
11044
DeviceID,
11117
11045
PointerNum,
11118
- BasePointersArrayArg ,
11119
- PointersArrayArg ,
11120
- SizesArrayArg ,
11121
- MapTypesArrayArg ,
11122
- MapNamesArrayArg ,
11123
- MappersArrayArg };
11046
+ RTArgs.BasePointersArray ,
11047
+ RTArgs.PointersArray ,
11048
+ RTArgs.SizesArray ,
11049
+ RTArgs.MapTypesArray ,
11050
+ RTArgs.MapNamesArray ,
11051
+ RTArgs.MappersArray };
11124
11052
CGF.EmitRuntimeCall(
11125
11053
OMPBuilder.getOrCreateRuntimeFunction(
11126
11054
CGM.getModule(), OMPRTL___tgt_target_data_begin_mapper),
@@ -11137,16 +11065,12 @@ void CGOpenMPRuntime::emitTargetDataCalls(
11137
11065
PrePostActionTy &) {
11138
11066
assert(Info.isValid() && "Invalid data environment closing arguments.");
11139
11067
11140
- llvm::Value *BasePointersArrayArg = nullptr;
11141
- llvm::Value *PointersArrayArg = nullptr;
11142
- llvm::Value *SizesArrayArg = nullptr;
11143
- llvm::Value *MapTypesArrayArg = nullptr;
11144
- llvm::Value *MapNamesArrayArg = nullptr;
11145
- llvm::Value *MappersArrayArg = nullptr;
11146
- emitOffloadingArraysArgument(CGF, BasePointersArrayArg, PointersArrayArg,
11147
- SizesArrayArg, MapTypesArrayArg,
11148
- MapNamesArrayArg, MappersArrayArg, Info,
11149
- {/*ForEndCall=*/true});
11068
+ llvm::OpenMPIRBuilder::TargetDataRTArgs RTArgs;
11069
+ bool EmitDebug =
11070
+ CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
11071
+ OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, RTArgs, Info,
11072
+ EmitDebug,
11073
+ /*ForEndCall=*/true);
11150
11074
11151
11075
// Emit device ID if any.
11152
11076
llvm::Value *DeviceID = nullptr;
@@ -11166,12 +11090,12 @@ void CGOpenMPRuntime::emitTargetDataCalls(
11166
11090
llvm::Value *OffloadingArgs[] = {RTLoc,
11167
11091
DeviceID,
11168
11092
PointerNum,
11169
- BasePointersArrayArg ,
11170
- PointersArrayArg ,
11171
- SizesArrayArg ,
11172
- MapTypesArrayArg ,
11173
- MapNamesArrayArg ,
11174
- MappersArrayArg };
11093
+ RTArgs.BasePointersArray ,
11094
+ RTArgs.PointersArray ,
11095
+ RTArgs.SizesArray ,
11096
+ RTArgs.MapTypesArray ,
11097
+ RTArgs.MapNamesArray ,
11098
+ RTArgs.MappersArray };
11175
11099
CGF.EmitRuntimeCall(
11176
11100
OMPBuilder.getOrCreateRuntimeFunction(
11177
11101
CGM.getModule(), OMPRTL___tgt_target_data_end_mapper),
@@ -11360,27 +11284,28 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
11360
11284
MappableExprsHandler MEHandler(D, CGF);
11361
11285
MEHandler.generateAllInfo(CombinedInfo);
11362
11286
11363
- TargetDataInfo Info;
11287
+ CGOpenMPRuntime:: TargetDataInfo Info;
11364
11288
// Fill up the arrays and create the arguments.
11365
11289
emitOffloadingArrays(CGF, CombinedInfo, Info, OMPBuilder,
11366
11290
/*IsNonContiguous=*/true);
11367
11291
bool RequiresOuterTask = D.hasClausesOfKind<OMPDependClause>() ||
11368
11292
D.hasClausesOfKind<OMPNowaitClause>();
11369
- emitOffloadingArraysArgument(
11370
- CGF, Info.BasePointersArray, Info.PointersArray, Info.SizesArray,
11371
- Info.MapTypesArray, Info.MapNamesArray, Info.MappersArray, Info,
11372
- {/*ForEndCall=*/false});
11293
+ bool EmitDebug =
11294
+ CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
11295
+ OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, Info.RTArgs, Info,
11296
+ EmitDebug,
11297
+ /*ForEndCall=*/false);
11373
11298
InputInfo.NumberOfTargetItems = Info.NumberOfPtrs;
11374
- InputInfo.BasePointersArray =
11375
- Address(Info.BasePointersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
11376
- InputInfo.PointersArray =
11377
- Address(Info.PointersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
11299
+ InputInfo.BasePointersArray = Address(Info.RTArgs.BasePointersArray,
11300
+ CGF.VoidPtrTy, CGM.getPointerAlign());
11301
+ InputInfo.PointersArray = Address(Info.RTArgs.PointersArray, CGF.VoidPtrTy,
11302
+ CGM.getPointerAlign());
11378
11303
InputInfo.SizesArray =
11379
- Address(Info.SizesArray, CGF.Int64Ty, CGM.getPointerAlign());
11304
+ Address(Info.RTArgs. SizesArray, CGF.Int64Ty, CGM.getPointerAlign());
11380
11305
InputInfo.MappersArray =
11381
- Address(Info.MappersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
11382
- MapTypesArray = Info.MapTypesArray;
11383
- MapNamesArray = Info.MapNamesArray;
11306
+ Address(Info.RTArgs. MappersArray, CGF.VoidPtrTy, CGM.getPointerAlign());
11307
+ MapTypesArray = Info.RTArgs. MapTypesArray;
11308
+ MapNamesArray = Info.RTArgs. MapNamesArray;
11384
11309
if (RequiresOuterTask)
11385
11310
CGF.EmitOMPTargetTaskBasedDirective(D, ThenGen, InputInfo);
11386
11311
else
@@ -13075,7 +13000,8 @@ void CGOpenMPSIMDRuntime::emitNumTeamsClause(CodeGenFunction &CGF,
13075
13000
13076
13001
void CGOpenMPSIMDRuntime::emitTargetDataCalls(
13077
13002
CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond,
13078
- const Expr *Device, const RegionCodeGenTy &CodeGen, TargetDataInfo &Info) {
13003
+ const Expr *Device, const RegionCodeGenTy &CodeGen,
13004
+ CGOpenMPRuntime::TargetDataInfo &Info) {
13079
13005
llvm_unreachable("Not supported in SIMD-only mode");
13080
13006
}
13081
13007
0 commit comments