From 084b0c2f03786c1a40f834eec7e6d5a5458d27e6 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 21 Mar 2019 20:36:16 +0000 Subject: [OPENMP] Simplify codegen for allocate directive on local variables. Simplified codegen for the allocate directive for local variables, initial implementation of the codegen for NVPTX target. llvm-svn: 356710 --- clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp') diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp index 7de16032269..fd294dab640 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -4725,6 +4725,28 @@ void CGOpenMPRuntimeNVPTX::emitFunctionProlog(CodeGenFunction &CGF, Address CGOpenMPRuntimeNVPTX::getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) { + bool UseDefaultAllocator = true; + if (VD && VD->hasAttr()) { + const auto *A = VD->getAttr(); + switch (A->getAllocatorType()) { + // Use the default allocator here as by default local vars are + // threadlocal. + case OMPAllocateDeclAttr::OMPDefaultMemAlloc: + case OMPAllocateDeclAttr::OMPThreadMemAlloc: + // Just pass-through to check if the globalization is required. + break; + case OMPAllocateDeclAttr::OMPLargeCapMemAlloc: + case OMPAllocateDeclAttr::OMPCGroupMemAlloc: + case OMPAllocateDeclAttr::OMPHighBWMemAlloc: + case OMPAllocateDeclAttr::OMPLowLatMemAlloc: + case OMPAllocateDeclAttr::OMPConstMemAlloc: + case OMPAllocateDeclAttr::OMPPTeamMemAlloc: + case OMPAllocateDeclAttr::OMPUserDefinedMemAlloc: + UseDefaultAllocator = false; + break; + } + } + if (getDataSharingMode(CGM) != CGOpenMPRuntimeNVPTX::Generic) return Address::invalid(); @@ -4746,7 +4768,9 @@ Address CGOpenMPRuntimeNVPTX::getAddressOfLocalVariable(CodeGenFunction &CGF, return VDI->second.PrivateAddr; } } + // TODO: replace it with return + // UseDefaultAllocator ? Address::invalid : // CGOpenMPRuntime::getAddressOfLocalVariable(CGF, VD); when NVPTX libomp // supports __kmpc_alloc|__kmpc_free. return Address::invalid(); -- cgit v1.2.3