summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-11-21 11:30:43 -0500
committerAlexey Bataev <a.bataev@hotmail.com>2019-11-25 15:01:28 -0500
commitbbc328c62430dd3e2e72973ca85c5c6fb550b227 (patch)
tree07ec8bcbd6cd255edd565ff05d2b6205dd0dbe87 /clang/lib/AST/Decl.cpp
parent7b86188b50bf6e537fe98b326f258fbd23108b83 (diff)
downloadbcm5719-llvm-bbc328c62430dd3e2e72973ca85c5c6fb550b227.tar.gz
bcm5719-llvm-bbc328c62430dd3e2e72973ca85c5c6fb550b227.zip
[OPENMP]Fix PR41826: symbols visibility in device code.
Summary: Currently, we ignore all locality attributes/info when building for the device and thus all symblos are externally visible and can be preemted at the runtime. It may lead to incorrect results. We need to follow the same logic, compiler uses for static/pie builds. But in some cases changing of dso locality may lead to problems with codegen, so instead mark external symbols as hidden instead in the device code. Reviewers: jdoerfert Subscribers: guansong, caomhin, kkwli0, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70549
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 66446626c2e..3723c868004 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -901,6 +901,10 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
if (!isExternallyVisible(LV.getLinkage()))
return LinkageInfo(LV.getLinkage(), DefaultVisibility, false);
+ // Mark the symbols as hidden when compiling for the device.
+ if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice)
+ LV.mergeVisibility(HiddenVisibility, /*newExplicit=*/false);
+
return LV;
}
OpenPOWER on IntegriCloud