aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-09-03 23:34:36 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-09-03 23:34:36 +0000
commit79869ee59abc3aeebda6e15540273a7e5936adb4 (patch)
tree00091e22e94e2126f6fff3a2ca6d15b68d97aadf /lib/Transforms/IPO/GlobalOpt.cpp
parent4b3e5f24ecedc075a3d9f1a5bdb77190a3a01f22 (diff)
downloadexternal_llvm-79869ee59abc3aeebda6e15540273a7e5936adb4.zip
external_llvm-79869ee59abc3aeebda6e15540273a7e5936adb4.tar.gz
external_llvm-79869ee59abc3aeebda6e15540273a7e5936adb4.tar.bz2
Add r159136 back now that pr13124 has been fixed.
Original message: If a constant or a function has linkonce_odr linkage and unnamed_addr, mark hidden. Being linkonce_odr guarantees that it is available in every dso that needs it. Being a constant/function with unnamed_addr guarantees that the copies don't have to be merged. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189886 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 64cd515..ab9d30d 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1914,6 +1914,12 @@ bool GlobalOpt::ProcessGlobal(GlobalVariable *GV,
return true;
}
+ if (GV->hasLinkOnceODRLinkage() && GV->hasUnnamedAddr() && GV->isConstant() &&
+ GV->getVisibility() != GlobalValue::HiddenVisibility) {
+ GV->setVisibility(GlobalValue::HiddenVisibility);
+ return true;
+ }
+
if (!GV->hasLocalLinkage())
return false;
@@ -1926,6 +1932,7 @@ bool GlobalOpt::ProcessGlobal(GlobalVariable *GV,
if (!GS.isCompared && !GV->hasUnnamedAddr()) {
GV->setUnnamedAddr(true);
NumUnnamed++;
+ return true;
}
if (GV->isConstant() || !GV->hasInitializer())
@@ -2105,6 +2112,10 @@ bool GlobalOpt::OptimizeFunctions(Module &M) {
F->eraseFromParent();
Changed = true;
++NumFnDeleted;
+ } else if (F->hasLinkOnceODRLinkage() && F->hasUnnamedAddr() &&
+ F->getVisibility() != GlobalValue::HiddenVisibility) {
+ F->setVisibility(GlobalValue::HiddenVisibility);
+ Changed = true;
} else if (F->hasLocalLinkage()) {
if (F->getCallingConv() == CallingConv::C && !F->isVarArg() &&
!F->hasAddressTaken()) {