diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2018-08-07 16:14:36 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-08-07 16:14:36 +0000 |
commit | bf8fe71b91ae4f2f223c6a7aa7e51c6aa4d6f329 (patch) | |
tree | 7da9deb1e688a7716827e7104dee5076d1ae47ef /clang/lib/CodeGen/CGOpenMPRuntime.cpp | |
parent | ab2cbad6fecd0b874dc51aaed0f3fb7aab8ebe4b (diff) | |
download | bcm5719-llvm-bf8fe71b91ae4f2f223c6a7aa7e51c6aa4d6f329.tar.gz bcm5719-llvm-bf8fe71b91ae4f2f223c6a7aa7e51c6aa4d6f329.zip |
[OPENMP] Mark variables captured in declare target region as implicitly
declare target.
According to OpenMP 5.0, variables captured in lambdas in declare target
regions must be considered as implicitly declare target.
llvm-svn: 339152
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 4d9f495c16e..168504ccaf7 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -8106,7 +8106,12 @@ bool CGOpenMPRuntime::emitTargetGlobalVariable(GlobalDecl GD) { // Do not to emit variable if it is not marked as declare target. llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy> Res = isDeclareTargetDeclaration(cast<VarDecl>(GD.getDecl())); - return !Res || *Res == OMPDeclareTargetDeclAttr::MT_Link; + if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_Link) { + if (CGM.getContext().DeclMustBeEmitted(GD.getDecl())) + DeferredGlobalVariables.insert(cast<VarDecl>(GD.getDecl())); + return true; + } + return false; } void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD, @@ -8163,6 +8168,18 @@ bool CGOpenMPRuntime::emitTargetGlobal(GlobalDecl GD) { return emitTargetGlobalVariable(GD); } +void CGOpenMPRuntime::emitDeferredTargetDecls() const { + for (const VarDecl *VD : DeferredGlobalVariables) { + llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy> Res = + isDeclareTargetDeclaration(VD); + if (Res) { + assert(*Res != OMPDeclareTargetDeclAttr::MT_Link && + "Implicit declare target variables must be only to()."); + CGM.EmitGlobal(VD); + } + } +} + CGOpenMPRuntime::DisableAutoDeclareTargetRAII::DisableAutoDeclareTargetRAII( CodeGenModule &CGM) : CGM(CGM) { |