[llvm] r207979 - LTO: -internalize sets visibility to default
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon May 5 10:40:44 PDT 2014
Author: dexonsmith
Date: Mon May 5 12:40:44 2014
New Revision: 207979
URL: http://llvm.org/viewvc/llvm-project?rev=207979&view=rev
Log:
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>
Added:
llvm/trunk/test/Transforms/Internalize/local-visibility.ll
Modified:
llvm/trunk/lib/Transforms/IPO/Internalize.cpp
Modified: llvm/trunk/lib/Transforms/IPO/Internalize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Internalize.cpp?rev=207979&r1=207978&r2=207979&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Internalize.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Internalize.cpp Mon May 5 12:40:44 2014
@@ -159,6 +159,7 @@ bool InternalizePass::runOnModule(Module
if (!shouldInternalize(*I, ExternalNames))
continue;
+ I->setVisibility(GlobalValue::DefaultVisibility);
I->setLinkage(GlobalValue::InternalLinkage);
if (ExternalNode)
@@ -195,6 +196,7 @@ bool InternalizePass::runOnModule(Module
if (!shouldInternalize(*I, ExternalNames))
continue;
+ I->setVisibility(GlobalValue::DefaultVisibility);
I->setLinkage(GlobalValue::InternalLinkage);
Changed = true;
++NumGlobals;
@@ -207,6 +209,7 @@ bool InternalizePass::runOnModule(Module
if (!shouldInternalize(*I, ExternalNames))
continue;
+ I->setVisibility(GlobalValue::DefaultVisibility);
I->setLinkage(GlobalValue::InternalLinkage);
Changed = true;
++NumAliases;
Added: llvm/trunk/test/Transforms/Internalize/local-visibility.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Internalize/local-visibility.ll?rev=207979&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Internalize/local-visibility.ll (added)
+++ llvm/trunk/test/Transforms/Internalize/local-visibility.ll Mon May 5 12:40:44 2014
@@ -0,0 +1,25 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; Internalized symbols should have default visibility.
+
+; CHECK: @global = global i32 0
+ at global = global i32 0
+ at llvm.used = appending global [1 x i32*] [i32* @global]
+
+; CHECK: @hidden.variable = internal global i32 0
+ at hidden.variable = hidden global i32 0
+; CHECK: @protected.variable = internal global i32 0
+ at protected.variable = protected global i32 0
+
+; CHECK: @hidden.alias = alias internal i32* @global
+ at hidden.alias = hidden alias i32* @global
+; CHECK: @protected.alias = alias internal i32* @global
+ at 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
+}
More information about the llvm-commits
mailing list