diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-05 17:40:44 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-05 17:40:44 +0000 |
commit | 1789fb6493d42e415b4881e9b6fac569000ec7e4 (patch) | |
tree | 868881536d081809d9a659884b40d2c9b962358b /llvm | |
parent | 48bc268290952547cc7dc74ce475fe58e6010c41 (diff) | |
download | bcm5719-llvm-1789fb6493d42e415b4881e9b6fac569000ec7e4.tar.gz bcm5719-llvm-1789fb6493d42e415b4881e9b6fac569000ec7e4.zip |
LTO: -internalize sets visibility to default
Visibility is meaningless when the linkage is local. Change
`-internalize` to reset the visibility to `default`.
<rdar://problem/16141113>
llvm-svn: 207979
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/IPO/Internalize.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Transforms/Internalize/local-visibility.ll | 25 |
2 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/Internalize.cpp b/llvm/lib/Transforms/IPO/Internalize.cpp index cdb85fd525c..c970a1a1c1a 100644 --- a/llvm/lib/Transforms/IPO/Internalize.cpp +++ b/llvm/lib/Transforms/IPO/Internalize.cpp @@ -159,6 +159,7 @@ bool InternalizePass::runOnModule(Module &M) { if (!shouldInternalize(*I, ExternalNames)) continue; + I->setVisibility(GlobalValue::DefaultVisibility); I->setLinkage(GlobalValue::InternalLinkage); if (ExternalNode) @@ -195,6 +196,7 @@ bool InternalizePass::runOnModule(Module &M) { if (!shouldInternalize(*I, ExternalNames)) continue; + I->setVisibility(GlobalValue::DefaultVisibility); I->setLinkage(GlobalValue::InternalLinkage); Changed = true; ++NumGlobals; @@ -207,6 +209,7 @@ bool InternalizePass::runOnModule(Module &M) { if (!shouldInternalize(*I, ExternalNames)) continue; + I->setVisibility(GlobalValue::DefaultVisibility); I->setLinkage(GlobalValue::InternalLinkage); Changed = true; ++NumAliases; diff --git a/llvm/test/Transforms/Internalize/local-visibility.ll b/llvm/test/Transforms/Internalize/local-visibility.ll new file mode 100644 index 00000000000..c24d4b7f32a --- /dev/null +++ b/llvm/test/Transforms/Internalize/local-visibility.ll @@ -0,0 +1,25 @@ +; RUN: opt < %s -internalize -S | FileCheck %s +; Internalized symbols should have default visibility. + +; CHECK: @global = global i32 0 +@global = global i32 0 +@llvm.used = appending global [1 x i32*] [i32* @global] + +; CHECK: @hidden.variable = internal global i32 0 +@hidden.variable = hidden global i32 0 +; CHECK: @protected.variable = internal global i32 0 +@protected.variable = protected global i32 0 + +; CHECK: @hidden.alias = alias internal i32* @global +@hidden.alias = hidden alias i32* @global +; CHECK: @protected.alias = alias internal i32* @global +@protected.alias = protected alias i32* @global + +; CHECK: define internal void @hidden.function() { +define hidden void @hidden.function() { + ret void +} +; CHECK: define internal void @protected.function() { +define protected void @protected.function() { + ret void +} |