diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2019-06-25 16:00:43 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-06-25 16:00:43 +0000 |
| commit | a90fc6617fb5df0d07956d08cbc300dca5924680 (patch) | |
| tree | 67540fdfea61b0c363ca79f2b039442ae63a7c03 /clang/lib/CodeGen | |
| parent | 9762b26032c8b926fc2a77b30c93c2aacc52a46e (diff) | |
| download | bcm5719-llvm-a90fc6617fb5df0d07956d08cbc300dca5924680.tar.gz bcm5719-llvm-a90fc6617fb5df0d07956d08cbc300dca5924680.zip | |
[OPENMP]Fix PR41966: type mismatch in runtime functions.
Target-based runtime functions use int64_t type for sizes, while the
compiler uses size_t type. It leads to miscompilation in 32 bit mode.
llvm-svn: 364327
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 122 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 3 |
2 files changed, 71 insertions, 54 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index ee5f3993940..6b9824b0103 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -710,19 +710,19 @@ enum OpenMPRTLFunction { // size); OMPRTL__kmpc_push_target_tripcount, // Call to int32_t __tgt_target(int64_t device_id, void *host_ptr, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); OMPRTL__tgt_target, // Call to int32_t __tgt_target_nowait(int64_t device_id, void *host_ptr, - // int32_t arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // int32_t arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); OMPRTL__tgt_target_nowait, // Call to int32_t __tgt_target_teams(int64_t device_id, void *host_ptr, - // int32_t arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // int32_t arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types, int32_t num_teams, int32_t thread_limit); OMPRTL__tgt_target_teams, // Call to int32_t __tgt_target_teams_nowait(int64_t device_id, void - // *host_ptr, int32_t arg_num, void** args_base, void **args, size_t + // *host_ptr, int32_t arg_num, void** args_base, void **args, int64_t // *arg_sizes, int64_t *arg_types, int32_t num_teams, int32_t thread_limit); OMPRTL__tgt_target_teams_nowait, // Call to void __tgt_register_requires(int64_t flags); @@ -732,24 +732,24 @@ enum OpenMPRTLFunction { // Call to void __tgt_unregister_lib(__tgt_bin_desc *desc); OMPRTL__tgt_unregister_lib, // Call to void __tgt_target_data_begin(int64_t device_id, int32_t arg_num, - // void** args_base, void **args, size_t *arg_sizes, int64_t *arg_types); + // void** args_base, void **args, int64_t *arg_sizes, int64_t *arg_types); OMPRTL__tgt_target_data_begin, // Call to void __tgt_target_data_begin_nowait(int64_t device_id, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); OMPRTL__tgt_target_data_begin_nowait, // Call to void __tgt_target_data_end(int64_t device_id, int32_t arg_num, // void** args_base, void **args, size_t *arg_sizes, int64_t *arg_types); OMPRTL__tgt_target_data_end, // Call to void __tgt_target_data_end_nowait(int64_t device_id, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); OMPRTL__tgt_target_data_end_nowait, // Call to void __tgt_target_data_update(int64_t device_id, int32_t arg_num, - // void** args_base, void **args, size_t *arg_sizes, int64_t *arg_types); + // void** args_base, void **args, int64_t *arg_sizes, int64_t *arg_types); OMPRTL__tgt_target_data_update, // Call to void __tgt_target_data_update_nowait(int64_t device_id, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); OMPRTL__tgt_target_data_update_nowait, }; @@ -2278,14 +2278,14 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target: { // Build int32_t __tgt_target(int64_t device_id, void *host_ptr, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.VoidPtrTy, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg*/ false); @@ -2294,14 +2294,14 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_nowait: { // Build int32_t __tgt_target_nowait(int64_t device_id, void *host_ptr, - // int32_t arg_num, void** args_base, void **args, size_t *arg_sizes, + // int32_t arg_num, void** args_base, void **args, int64_t *arg_sizes, // int64_t *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.VoidPtrTy, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg*/ false); @@ -2310,14 +2310,14 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_teams: { // Build int32_t __tgt_target_teams(int64_t device_id, void *host_ptr, - // int32_t arg_num, void** args_base, void **args, size_t *arg_sizes, + // int32_t arg_num, void** args_base, void **args, int64_t *arg_sizes, // int64_t *arg_types, int32_t num_teams, int32_t thread_limit); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.VoidPtrTy, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo(), CGM.Int32Ty, CGM.Int32Ty}; @@ -2328,14 +2328,14 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_teams_nowait: { // Build int32_t __tgt_target_teams_nowait(int64_t device_id, void - // *host_ptr, int32_t arg_num, void** args_base, void **args, size_t + // *host_ptr, int32_t arg_num, void** args_base, void **args, int64_t // *arg_sizes, int64_t *arg_types, int32_t num_teams, int32_t thread_limit); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.VoidPtrTy, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo(), CGM.Int32Ty, CGM.Int32Ty}; @@ -2374,12 +2374,12 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_data_begin: { // Build void __tgt_target_data_begin(int64_t device_id, int32_t arg_num, - // void** args_base, void **args, size_t *arg_sizes, int64_t *arg_types); + // void** args_base, void **args, int64_t *arg_sizes, int64_t *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false); @@ -2388,13 +2388,13 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_data_begin_nowait: { // Build void __tgt_target_data_begin_nowait(int64_t device_id, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg=*/false); @@ -2403,12 +2403,12 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_data_end: { // Build void __tgt_target_data_end(int64_t device_id, int32_t arg_num, - // void** args_base, void **args, size_t *arg_sizes, int64_t *arg_types); + // void** args_base, void **args, int64_t *arg_sizes, int64_t *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false); @@ -2417,13 +2417,13 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_data_end_nowait: { // Build void __tgt_target_data_end_nowait(int64_t device_id, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg=*/false); @@ -2432,12 +2432,12 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_data_update: { // Build void __tgt_target_data_update(int64_t device_id, int32_t arg_num, - // void** args_base, void **args, size_t *arg_sizes, int64_t *arg_types); + // void** args_base, void **args, int64_t *arg_sizes, int64_t *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false); @@ -2446,13 +2446,13 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { } case OMPRTL__tgt_target_data_update_nowait: { // Build void __tgt_target_data_update_nowait(int64_t device_id, int32_t - // arg_num, void** args_base, void **args, size_t *arg_sizes, int64_t + // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t // *arg_types); llvm::Type *TypeParams[] = {CGM.Int64Ty, CGM.Int32Ty, CGM.VoidPtrPtrTy, CGM.VoidPtrPtrTy, - CGM.SizeTy->getPointerTo(), + CGM.Int64Ty->getPointerTo(), CGM.Int64Ty->getPointerTo()}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg=*/false); @@ -7639,7 +7639,8 @@ private: } BasePointers.push_back(BP.getPointer()); Pointers.push_back(LB.getPointer()); - Sizes.push_back(Size); + Sizes.push_back(CGF.Builder.CreateIntCast(Size, CGF.Int64Ty, + /*isSigned=*/true)); Types.push_back(Flags); LB = CGF.Builder.CreateConstGEP(ComponentLB, 1); } @@ -7649,7 +7650,8 @@ private: CGF.EmitCastToVoidPtr( CGF.Builder.CreateConstGEP(HB, 1).getPointer()), CGF.EmitCastToVoidPtr(LB.getPointer())); - Sizes.push_back(Size); + Sizes.push_back( + CGF.Builder.CreateIntCast(Size, CGF.Int64Ty, /*isSigned=*/true)); Types.push_back(Flags); break; } @@ -7657,7 +7659,8 @@ private: if (!IsMemberPointer) { BasePointers.push_back(BP.getPointer()); Pointers.push_back(LB.getPointer()); - Sizes.push_back(Size); + Sizes.push_back( + CGF.Builder.CreateIntCast(Size, CGF.Int64Ty, /*isSigned=*/true)); // We need to add a pointer flag for each map that comes from the // same expression except for the first one. We also need to signal @@ -7859,7 +7862,7 @@ public: llvm::Value *CLAddr = CGF.Builder.CreatePointerCast(LB, CGF.VoidPtrTy); llvm::Value *CHAddr = CGF.Builder.CreatePointerCast(HAddr, CGF.VoidPtrTy); llvm::Value *Diff = CGF.Builder.CreatePtrDiff(CHAddr, CLAddr); - llvm::Value *Size = CGF.Builder.CreateIntCast(Diff, CGF.SizeTy, + llvm::Value *Size = CGF.Builder.CreateIntCast(Diff, CGF.Int64Ty, /*isSinged=*/false); Sizes.push_back(Size); // Map type is always TARGET_PARAM @@ -7976,7 +7979,7 @@ public: this->CGF.EmitLValue(IE), IE->getExprLoc()); BasePointers.emplace_back(Ptr, VD); Pointers.push_back(Ptr); - Sizes.push_back(llvm::Constant::getNullValue(this->CGF.SizeTy)); + Sizes.push_back(llvm::Constant::getNullValue(this->CGF.Int64Ty)); Types.push_back(OMP_MAP_RETURN_PARAM | OMP_MAP_TARGET_PARAM); } } @@ -8033,7 +8036,7 @@ public: this->CGF.EmitLValue(L.IE), L.IE->getExprLoc()); CurBasePointers.emplace_back(BasePtr, L.VD); CurPointers.push_back(Ptr); - CurSizes.push_back(llvm::Constant::getNullValue(this->CGF.SizeTy)); + CurSizes.push_back(llvm::Constant::getNullValue(this->CGF.Int64Ty)); // Entry is PTR_AND_OBJ and RETURN_PARAM. Also, set the placeholder // value MEMBER_OF=FFFF so that the entry is later updated with the // correct value of MEMBER_OF. @@ -8081,7 +8084,9 @@ public: LambdaPointers.try_emplace(ThisLVal.getPointer(), VDLVal.getPointer()); BasePointers.push_back(ThisLVal.getPointer()); Pointers.push_back(ThisLValVal.getPointer()); - Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy)); + Sizes.push_back( + CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy), + CGF.Int64Ty, /*isSigned=*/true)); Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL | OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT); } @@ -8096,8 +8101,10 @@ public: LambdaPointers.try_emplace(VarLVal.getPointer(), VDLVal.getPointer()); BasePointers.push_back(VarLVal.getPointer()); Pointers.push_back(VarLValVal.getPointer()); - Sizes.push_back(CGF.getTypeSize( - VD->getType().getCanonicalType().getNonReferenceType())); + Sizes.push_back(CGF.Builder.CreateIntCast( + CGF.getTypeSize( + VD->getType().getCanonicalType().getNonReferenceType()), + CGF.Int64Ty, /*isSigned=*/true)); Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL | OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT); } @@ -8154,7 +8161,9 @@ public: if (DevPointersMap.count(VD)) { BasePointers.emplace_back(Arg, VD); Pointers.push_back(Arg); - Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy)); + Sizes.push_back( + CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy), + CGF.Int64Ty, /*isSigned=*/true)); Types.push_back(OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM); return; } @@ -8350,7 +8359,9 @@ public: CurBasePointers.push_back(CV); CurPointers.push_back(CV); const auto *PtrTy = cast<PointerType>(RI.getType().getTypePtr()); - CurSizes.push_back(CGF.getTypeSize(PtrTy->getPointeeType())); + CurSizes.push_back( + CGF.Builder.CreateIntCast(CGF.getTypeSize(PtrTy->getPointeeType()), + CGF.Int64Ty, /*isSigned=*/true)); // Default map type. CurMapTypes.push_back(OMP_MAP_TO | OMP_MAP_FROM); } else if (CI.capturesVariableByCopy()) { @@ -8360,18 +8371,20 @@ public: // We have to signal to the runtime captures passed by value that are // not pointers. CurMapTypes.push_back(OMP_MAP_LITERAL); - CurSizes.push_back(CGF.getTypeSize(RI.getType())); + CurSizes.push_back(CGF.Builder.CreateIntCast( + CGF.getTypeSize(RI.getType()), CGF.Int64Ty, /*isSigned=*/true)); } else { // Pointers are implicitly mapped with a zero size and no flags // (other than first map that is added for all implicit maps). CurMapTypes.push_back(OMP_MAP_NONE); - CurSizes.push_back(llvm::Constant::getNullValue(CGF.SizeTy)); + CurSizes.push_back(llvm::Constant::getNullValue(CGF.Int64Ty)); } } else { assert(CI.capturesVariable() && "Expected captured reference."); const auto *PtrTy = cast<ReferenceType>(RI.getType().getTypePtr()); QualType ElementType = PtrTy->getPointeeType(); - CurSizes.push_back(CGF.getTypeSize(ElementType)); + CurSizes.push_back(CGF.Builder.CreateIntCast( + CGF.getTypeSize(ElementType), CGF.Int64Ty, /*isSigned=*/true)); // The default map type for a scalar/complex type is 'to' because by // default the value doesn't have to be retrieved. For an aggregate // type, the default is 'tofrom'. @@ -8450,10 +8463,12 @@ emitOffloadingArrays(CodeGenFunction &CGF, // If we don't have any VLA types or other types that require runtime // evaluation, we can use a constant array for the map sizes, otherwise we // need to fill up the arrays as we do for the pointers. + QualType Int64Ty = + Ctx.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1); if (hasRuntimeEvaluationCaptureSize) { - QualType SizeArrayType = Ctx.getConstantArrayType( - Ctx.getSizeType(), PointerNumAP, ArrayType::Normal, - /*IndexTypeQuals=*/0); + QualType SizeArrayType = + Ctx.getConstantArrayType(Int64Ty, PointerNumAP, ArrayType::Normal, + /*IndexTypeQuals=*/0); Info.SizesArray = CGF.CreateMemTemp(SizeArrayType, ".offload_sizes").getPointer(); } else { @@ -8464,7 +8479,7 @@ emitOffloadingArrays(CodeGenFunction &CGF, ConstSizes.push_back(cast<llvm::Constant>(S)); auto *SizesArrayInit = llvm::ConstantArray::get( - llvm::ArrayType::get(CGM.SizeTy, ConstSizes.size()), ConstSizes); + llvm::ArrayType::get(CGM.Int64Ty, ConstSizes.size()), ConstSizes); std::string Name = CGM.getOpenMPRuntime().getName({"offload_sizes"}); auto *SizesArrayGbl = new llvm::GlobalVariable( CGM.getModule(), SizesArrayInit->getType(), @@ -8514,13 +8529,13 @@ emitOffloadingArrays(CodeGenFunction &CGF, if (hasRuntimeEvaluationCaptureSize) { llvm::Value *S = CGF.Builder.CreateConstInBoundsGEP2_32( - llvm::ArrayType::get(CGM.SizeTy, Info.NumberOfPtrs), + llvm::ArrayType::get(CGM.Int64Ty, Info.NumberOfPtrs), Info.SizesArray, /*Idx0=*/0, /*Idx1=*/I); - Address SAddr(S, Ctx.getTypeAlignInChars(Ctx.getSizeType())); + Address SAddr(S, Ctx.getTypeAlignInChars(Int64Ty)); CGF.Builder.CreateStore( - CGF.Builder.CreateIntCast(Sizes[I], CGM.SizeTy, /*isSigned=*/true), + CGF.Builder.CreateIntCast(Sizes[I], CGM.Int64Ty, /*isSigned=*/true), SAddr); } } @@ -8544,7 +8559,7 @@ static void emitOffloadingArraysArgument( /*Idx0=*/0, /*Idx1=*/0); SizesArrayArg = CGF.Builder.CreateConstInBoundsGEP2_32( - llvm::ArrayType::get(CGM.SizeTy, Info.NumberOfPtrs), Info.SizesArray, + llvm::ArrayType::get(CGM.Int64Ty, Info.NumberOfPtrs), Info.SizesArray, /*Idx0=*/0, /*Idx1=*/0); MapTypesArrayArg = CGF.Builder.CreateConstInBoundsGEP2_32( llvm::ArrayType::get(CGM.Int64Ty, Info.NumberOfPtrs), @@ -8554,7 +8569,7 @@ static void emitOffloadingArraysArgument( } else { BasePointersArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy); PointersArrayArg = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy); - SizesArrayArg = llvm::ConstantPointerNull::get(CGM.SizeTy->getPointerTo()); + SizesArrayArg = llvm::ConstantPointerNull::get(CGM.Int64Ty->getPointerTo()); MapTypesArrayArg = llvm::ConstantPointerNull::get(CGM.Int64Ty->getPointerTo()); } @@ -8865,7 +8880,8 @@ void CGOpenMPRuntime::emitTargetCall(CodeGenFunction &CGF, if (CI->capturesVariableArrayType()) { CurBasePointers.push_back(*CV); CurPointers.push_back(*CV); - CurSizes.push_back(CGF.getTypeSize(RI->getType())); + CurSizes.push_back(CGF.Builder.CreateIntCast( + CGF.getTypeSize(RI->getType()), CGF.Int64Ty, /*isSigned=*/true)); // Copy to the device as an argument. No need to retrieve it. CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_LITERAL | MappableExprsHandler::OMP_MAP_TARGET_PARAM); diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 6a973cdb57e..a5396a362f2 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3119,7 +3119,8 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective( PVD = createImplicitFirstprivateForType( getContext(), Data, BaseAndPointersType, CD, S.getBeginLoc()); QualType SizesType = getContext().getConstantArrayType( - getContext().getSizeType(), ArrSize, ArrayType::Normal, + getContext().getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1), + ArrSize, ArrayType::Normal, /*IndexTypeQuals=*/0); SVD = createImplicitFirstprivateForType(getContext(), Data, SizesType, CD, S.getBeginLoc()); |

