diff options
author | Scott Linder <scott@scottlinder.com> | 2019-01-28 17:12:19 +0000 |
---|---|---|
committer | Scott Linder <scott@scottlinder.com> | 2019-01-28 17:12:19 +0000 |
commit | bef2663751fd1f9ad12ddcbea2da87f47f1f42c7 (patch) | |
tree | 182f1d59e8b9f1a4e49d94a835c39169c7d1034a /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 23019f946d413a4a22351c7e96ce84872ac17560 (diff) | |
download | bcm5719-llvm-bef2663751fd1f9ad12ddcbea2da87f47f1f42c7.tar.gz bcm5719-llvm-bef2663751fd1f9ad12ddcbea2da87f47f1f42c7.zip |
Add -fapply-global-visibility-to-externs for -cc1
Introduce an option to request global visibility settings be applied to
declarations without a definition or an explicit visibility, rather than
the existing behavior of giving these default visibility. When the
visibility of all or most extern definitions are known this allows for
the same optimisations -fvisibility permits without updating source code
to annotate all declarations.
Differential Revision: https://reviews.llvm.org/D56868
llvm-svn: 352391
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 0be4bad7ee7..5a1b7cfe4fa 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -731,9 +731,11 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV, } if (!D) return; - // Set visibility for definitions. + // Set visibility for definitions, and for declarations if requested globally + // or set explicitly. LinkageInfo LV = D->getLinkageAndVisibility(); - if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker()) + if (LV.isVisibilityExplicit() || getLangOpts().SetVisibilityForExternDecls || + !GV->isDeclarationForLinker()) GV->setVisibility(GetLLVMVisibility(LV.getVisibility())); } |