diff options
| author | Joseph Huber <jhuber6@vols.utk.edu> | 2023-10-09 07:55:05 -0500 |
|---|---|---|
| committer | Joseph Huber <jhuber6@vols.utk.edu> | 2023-10-09 07:56:43 -0500 |
| commit | 85feb9347f77859a877e767692e1c11d00cf6ffd (patch) | |
| tree | 1a97826ed9af24a13c97b4adc28dab6d8ed862f9 /clang/lib/CodeGen/CodeGenModule.cpp | |
| parent | bcf172ec578a2a787de45858871e59fd64f7b196 (diff) | |
[OpenMP] Fix setting visibility on declare target variables
Summary:
A previous patch changed the logic to force external visibliity on
declare target variables. This is because they need to be exported in
the dynamic symbol table to be usable as the standard depicts. However,
the logic was always setting the visibility to `protected`, which would
override some symbols. For example, when calling `libc` functions for
CPU offloading. This patch changes the logic to only fire if the
variable has hidden visibliity to start with.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index cae9dd93bc55..d6ab7b3567b9 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1391,6 +1391,10 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV, if (!D) return; + // Set visibility for definitions, and for declarations if requested globally + // or set explicitly. + LinkageInfo LV = D->getLinkageAndVisibility(); + // OpenMP declare target variables must be visible to the host so they can // be registered. We require protected visibility unless the variable has // the DT_nohost modifier and does not need to be registered. @@ -1398,14 +1402,12 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV, Context.getLangOpts().OpenMPIsTargetDevice && isa<VarDecl>(D) && D->hasAttr<OMPDeclareTargetDeclAttr>() && D->getAttr<OMPDeclareTargetDeclAttr>()->getDevType() != - OMPDeclareTargetDeclAttr::DT_NoHost) { + OMPDeclareTargetDeclAttr::DT_NoHost && + LV.getVisibility() == HiddenVisibility) { GV->setVisibility(llvm::GlobalValue::ProtectedVisibility); return; } - // Set visibility for definitions, and for declarations if requested globally - // or set explicitly. - LinkageInfo LV = D->getLinkageAndVisibility(); if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass()) { // Reject incompatible dlllstorage and visibility annotations. if (!LV.isVisibilityExplicit()) |
