diff options
author | Scott Linder <scott@scottlinder.com> | 2019-02-12 18:30:38 +0000 |
---|---|---|
committer | Scott Linder <scott@scottlinder.com> | 2019-02-12 18:30:38 +0000 |
commit | 80a1ee46d87b34f2bfabfc23e7226d615458bbec (patch) | |
tree | d10c2d340991820c685199a529aa820479927d40 /clang/lib | |
parent | 1ca9dd8507c7541b86e313b4ff99cdb98ee4dfd2 (diff) | |
download | bcm5719-llvm-80a1ee46d87b34f2bfabfc23e7226d615458bbec.tar.gz bcm5719-llvm-80a1ee46d87b34f2bfabfc23e7226d615458bbec.zip |
[AMDGPU] Require at least protected visibility for certain symbols
This allows the global visibility controls to be restrictive while still
populating the dynamic symbol table where required.
Differential Revision: https://reviews.llvm.org/D56871
llvm-svn: 353870
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e6c6da20385..ece26deff01 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3212,6 +3212,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace, ExpectedAS, Ty); + if (GV->isDeclaration()) + getTargetCodeGenInfo().setTargetAttributes(D, GV, *this); + return GV; } diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 1066531ccbf..ece64ab1533 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -7763,8 +7763,23 @@ public: }; } +static bool requiresAMDGPUProtectedVisibility(const Decl *D, + llvm::GlobalValue *GV) { + if (GV->getVisibility() != llvm::GlobalValue::HiddenVisibility) + return false; + + return D->hasAttr<OpenCLKernelAttr>() || + (isa<FunctionDecl>(D) && D->hasAttr<CUDAGlobalAttr>()) || + (isa<VarDecl>(D) && D->hasAttr<CUDADeviceAttr>()); +} + void AMDGPUTargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const { + if (requiresAMDGPUProtectedVisibility(D, GV)) { + GV->setVisibility(llvm::GlobalValue::ProtectedVisibility); + GV->setDSOLocal(true); + } + if (GV->isDeclaration()) return; const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D); |