diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2018-08-15 19:45:12 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-08-15 19:45:12 +0000 |
commit | d01b74974ba2e87cfc1f05a08ccad54feb9ceb49 (patch) | |
tree | 1c8fee61f2d911f49c7aee8b7d60881a88cebaa9 /clang/lib/CodeGen/CGOpenMPRuntime.cpp | |
parent | dfb4f61d971a52c0c859b6483a16199aa4d2103b (diff) | |
download | bcm5719-llvm-d01b74974ba2e87cfc1f05a08ccad54feb9ceb49.tar.gz bcm5719-llvm-d01b74974ba2e87cfc1f05a08ccad54feb9ceb49.zip |
[OPENMP] FIx processing of declare target variables.
The compiler may produce unexpected error messages/crashes when declare
target variables were used. Patch fixes problems with the declarations
marked as declare target to or link.
llvm-svn: 339805
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 245eacc31e4..0072bdf7ad5 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2622,7 +2622,7 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD, Optional<OMPDeclareTargetDeclAttr::MapTypeTy> Res = OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD); if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_Link) - return false; + return CGM.getLangOpts().OpenMPIsDevice; VD = VD->getDefinition(CGM.getContext()); if (VD && !DeclareTargetWithDefinition.insert(VD).second) return CGM.getLangOpts().OpenMPIsDevice; @@ -8089,8 +8089,7 @@ bool CGOpenMPRuntime::emitTargetGlobalVariable(GlobalDecl GD) { OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration( cast<VarDecl>(GD.getDecl())); if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_Link) { - if (CGM.getContext().DeclMustBeEmitted(GD.getDecl())) - DeferredGlobalVariables.insert(cast<VarDecl>(GD.getDecl())); + DeferredGlobalVariables.insert(cast<VarDecl>(GD.getDecl())); return true; } return false; @@ -8154,10 +8153,14 @@ void CGOpenMPRuntime::emitDeferredTargetDecls() const { for (const VarDecl *VD : DeferredGlobalVariables) { llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy> Res = OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD); - if (Res) { - assert(*Res != OMPDeclareTargetDeclAttr::MT_Link && - "Implicit declare target variables must be only to()."); + if (!Res) + continue; + if (*Res == OMPDeclareTargetDeclAttr::MT_To) { CGM.EmitGlobal(VD); + } else { + assert(*Res == OMPDeclareTargetDeclAttr::MT_Link && + "Expected to or link clauses."); + (void)CGM.getOpenMPRuntime().getAddrOfDeclareTargetLink(VD); } } } |