[llvm] r189954 - Revert "Add r159136 back now that pr13124 has been fixed."
Nick Lewycky
nicholas at mxc.ca
Wed Sep 4 12:38:25 PDT 2013
Rafael Espindola wrote:
> Author: rafael
> Date: Wed Sep 4 11:09:01 2013
> New Revision: 189954
>
> URL: http://llvm.org/viewvc/llvm-project?rev=189954&view=rev
> Log:
> 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.
That shouldn't happen. A hidden symbol doesn't get merged with anything
outside its TU, right? I think you can just rename it.
Nick
> * 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.
>
> Removed:
> llvm/trunk/test/Transforms/GlobalOpt/hidden.ll
> Modified:
> llvm/trunk/include/llvm/IR/GlobalValue.h
> llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
>
> Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=189954&r1=189953&r2=189954&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
> +++ llvm/trunk/include/llvm/IR/GlobalValue.h Wed Sep 4 11:09:01 2013
> @@ -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);
> }
>
> Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=189954&r1=189953&r2=189954&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Sep 4 11:09:01 2013
> @@ -1914,12 +1914,6 @@ bool GlobalOpt::ProcessGlobal(GlobalVari
> 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(GlobalVari
> if (!GS.isCompared&& !GV->hasUnnamedAddr()) {
> GV->setUnnamedAddr(true);
> NumUnnamed++;
> - return true;
> }
>
> if (GV->isConstant() || !GV->hasInitializer())
> @@ -2112,10 +2105,6 @@ bool GlobalOpt::OptimizeFunctions(Module
> 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()) {
>
> Removed: llvm/trunk/test/Transforms/GlobalOpt/hidden.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/hidden.ll?rev=189953&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/GlobalOpt/hidden.ll (original)
> +++ llvm/trunk/test/Transforms/GlobalOpt/hidden.ll (removed)
> @@ -1,14 +0,0 @@
> -; RUN: opt %s -globalopt -S | FileCheck %s
> -
> - at 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
> -}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list