aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-09-04 16:09:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-09-04 16:09:01 +0000
commit9718158222ad9c52b2fb14609a341d4e24def8bb (patch)
tree7aeaa76fe84666731515e4840a2545e6f392ec0a
parent280e5eef43ecf2279ab78f132922920ed7ce7952 (diff)
downloadexternal_llvm-9718158222ad9c52b2fb14609a341d4e24def8bb.zip
external_llvm-9718158222ad9c52b2fb14609a341d4e24def8bb.tar.gz
external_llvm-9718158222ad9c52b2fb14609a341d4e24def8bb.tar.bz2
Revert "Add r159136 back now that pr13124 has been fixed."
This reverts commit r189886. I found a corner case where this optimization is not valid: Say we have a "linkonce_odr unnamed_addr" in two translation units: * In TU 1 this optimization kicks in and makes it hidden. * In TU 2 it gets const merged with a constant that is *not* unnamed_addr, resulting in a non unnamed_addr constant with default visibility. * The static linker rules for combining visibility them produce a hidden symbol, which is incorrect from the point of view of the non unnamed_addr constant. The one place we can do this is when we know that the symbol is not used from another TU in the same shared object, i.e., during LTO. I will move it there. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189954 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/IR/GlobalValue.h6
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp11
-rw-r--r--test/Transforms/GlobalOpt/hidden.ll14
3 files changed, 0 insertions, 31 deletions
diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h
index a5049e4..1dc99cf 100644
--- a/include/llvm/IR/GlobalValue.h
+++ b/include/llvm/IR/GlobalValue.h
@@ -122,9 +122,6 @@ public:
static bool isAvailableExternallyLinkage(LinkageTypes Linkage) {
return Linkage == AvailableExternallyLinkage;
}
- static bool isLinkOnceODRLinkage(LinkageTypes Linkage) {
- return Linkage == LinkOnceODRLinkage;
- }
static bool isLinkOnceLinkage(LinkageTypes Linkage) {
return Linkage == LinkOnceAnyLinkage ||
Linkage == LinkOnceODRLinkage ||
@@ -205,9 +202,6 @@ public:
bool hasAvailableExternallyLinkage() const {
return isAvailableExternallyLinkage(Linkage);
}
- bool hasLinkOnceODRLinkage() const {
- return isLinkOnceODRLinkage(Linkage);
- }
bool hasLinkOnceLinkage() const {
return isLinkOnceLinkage(Linkage);
}
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index ab9d30d..64cd515 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1914,12 +1914,6 @@ 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;
@@ -1932,7 +1926,6 @@ bool GlobalOpt::ProcessGlobal(GlobalVariable *GV,
if (!GS.isCompared && !GV->hasUnnamedAddr()) {
GV->setUnnamedAddr(true);
NumUnnamed++;
- return true;
}
if (GV->isConstant() || !GV->hasInitializer())
@@ -2112,10 +2105,6 @@ 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()) {
diff --git a/test/Transforms/GlobalOpt/hidden.ll b/test/Transforms/GlobalOpt/hidden.ll
deleted file mode 100644
index 301e158..0000000
--- a/test/Transforms/GlobalOpt/hidden.ll
+++ /dev/null
@@ -1,14 +0,0 @@
-; RUN: opt %s -globalopt -S | FileCheck %s
-
-@foo = linkonce_odr unnamed_addr constant i32 42
-; CHECK: @foo = linkonce_odr hidden unnamed_addr constant i32 42
-
-define linkonce_odr void @bar() unnamed_addr {
-; CHECK: define linkonce_odr hidden void @bar() unnamed_addr {
- ret void
-}
-
-define i32* @zed() {
- call void @bar()
- ret i32* @foo
-}