diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2018-03-30 18:31:07 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-03-30 18:31:07 +0000 |
commit | 03f270c900e1f8563419fdd302683a9503e98722 (patch) | |
tree | 9da96a39200b5080cc79dc9b6e0fee4d76bb4cc8 /clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp | |
parent | 399b46c98d638a9a6694091b2ba8c511052a3999 (diff) | |
download | bcm5719-llvm-03f270c900e1f8563419fdd302683a9503e98722.tar.gz bcm5719-llvm-03f270c900e1f8563419fdd302683a9503e98722.zip |
[OPENMP] Added emission of offloading data sections for declare target
variables.
Added emission of the offloading data sections for the variables within
declare target regions + fixes emission of the declare target variables
marked as declare target not within the declare target region.
llvm-svn: 328888
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp index 62131cd0243..75d3ba75b34 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -177,7 +177,21 @@ class CheckVarsEscapingDeclContext final RecordDecl *GlobalizedRD = nullptr; llvm::SmallDenseMap<const ValueDecl *, const FieldDecl *> MappedDeclsFields; + static llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy> + isDeclareTargetDeclaration(const ValueDecl *VD) { + for (const auto *D : VD->redecls()) { + if (!D->hasAttrs()) + continue; + if (const auto *Attr = D->getAttr<OMPDeclareTargetDeclAttr>()) + return Attr->getMapType(); + } + return llvm::None; + } + void markAsEscaped(const ValueDecl *VD) { + // Do not globalize declare target variables. + if (isDeclareTargetDeclaration(VD)) + return; VD = cast<ValueDecl>(VD->getCanonicalDecl()); // Variables captured by value must be globalized. if (auto *CSI = CGF.CapturedStmtInfo) { @@ -1117,7 +1131,8 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntimeFunction(unsigned Function) { void CGOpenMPRuntimeNVPTX::createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr, - uint64_t Size, int32_t) { + uint64_t Size, int32_t, + llvm::GlobalValue::LinkageTypes) { auto *F = dyn_cast<llvm::Function>(Addr); // TODO: Add support for global variables on the device after declare target // support. |