diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-04-08 19:06:42 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-04-08 19:06:42 +0000 |
commit | 6cf7b715a0e5c8a6a5eab621fe490d5330d049fd (patch) | |
tree | 56d008039c7a0f33bed36c03608acf66e733750e /clang/lib/CodeGen/CGOpenMPRuntime.cpp | |
parent | f41e70d6eb90279019f0481fe0fd25742705f221 (diff) | |
download | bcm5719-llvm-6cf7b715a0e5c8a6a5eab621fe490d5330d049fd.tar.gz bcm5719-llvm-6cf7b715a0e5c8a6a5eab621fe490d5330d049fd.zip |
[OPENMP] Sync __kmpc_alloc/_kmpc_free function with the runtime.
Functions __kmpc_alloc/__kmpc_free are updated with the new interfaces.
Patch synchronizes the compiler with the runtime.
llvm-svn: 357933
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 67465c1acf0..03d7b51b4e9 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -667,9 +667,9 @@ enum OpenMPRTLFunction { // Call to void *__kmpc_task_reduction_get_th_data(int gtid, void *tg, void // *d); OMPRTL__kmpc_task_reduction_get_th_data, - // Call to void *__kmpc_alloc(int gtid, size_t sz, const omp_allocator_t *al); + // Call to void *__kmpc_alloc(int gtid, size_t sz, omp_allocator_handle_t al); OMPRTL__kmpc_alloc, - // Call to void __kmpc_free(int gtid, void *ptr, const omp_allocator_t *al); + // Call to void __kmpc_free(int gtid, void *ptr, omp_allocator_handle_t al); OMPRTL__kmpc_free, // @@ -2200,20 +2200,18 @@ llvm::FunctionCallee CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { break; } case OMPRTL__kmpc_alloc: { - // Build to void *__kmpc_alloc(int gtid, size_t sz, const omp_allocator_t - // *al); - // omp_allocator_t type is void *. - llvm::Type *TypeParams[] = {CGM.IntTy, CGM.SizeTy, CGM.VoidPtrPtrTy}; + // Build to void *__kmpc_alloc(int gtid, size_t sz, omp_allocator_handle_t + // al); omp_allocator_handle_t type is void *. + llvm::Type *TypeParams[] = {CGM.IntTy, CGM.SizeTy, CGM.VoidPtrTy}; auto *FnTy = llvm::FunctionType::get(CGM.VoidPtrTy, TypeParams, /*isVarArg=*/false); RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_alloc"); break; } case OMPRTL__kmpc_free: { - // Build to void __kmpc_free(int gtid, void *ptr, const omp_allocator_t - // *al); - // omp_allocator_t type is void *. - llvm::Type *TypeParams[] = {CGM.IntTy, CGM.VoidPtrTy, CGM.VoidPtrPtrTy}; + // Build to void __kmpc_free(int gtid, void *ptr, omp_allocator_handle_t + // al); omp_allocator_handle_t type is void *. + llvm::Type *TypeParams[] = {CGM.IntTy, CGM.VoidPtrTy, CGM.VoidPtrTy}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg=*/false); RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_free"); @@ -9781,6 +9779,13 @@ Address CGOpenMPRuntime::getAddressOfLocalVariable(CodeGenFunction &CGF, assert(AA->getAllocator() && "Expected allocator expression for non-default allocator."); llvm::Value *Allocator = CGF.EmitScalarExpr(AA->getAllocator()); + // According to the standard, the original allocator type is a enum (integer). + // Convert to pointer type, if required. + if (Allocator->getType()->isIntegerTy()) + Allocator = CGF.Builder.CreateIntToPtr(Allocator, CGM.VoidPtrTy); + else if (Allocator->getType()->isPointerTy()) + Allocator = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Allocator, + CGM.VoidPtrTy); llvm::Value *Args[] = {ThreadID, Size, Allocator}; llvm::Value *Addr = |