[llvm] r176459 - Check isDiscardableIfUnused, rather than hasLocalLinkage, when bumping
David Blaikie
dblaikie at gmail.com
Mon Mar 4 14:53:00 PST 2013
On Mon, Mar 4, 2013 at 2:40 PM, Lang Hames <lhames at gmail.com> wrote:
> Author: lhames
> Date: Mon Mar 4 16:40:44 2013
> New Revision: 176459
>
> URL: http://llvm.org/viewvc/llvm-project?rev=176459&view=rev
> Log:
> Check isDiscardableIfUnused, rather than hasLocalLinkage, when bumping
> GlobalValue linkage up to ExternalLinkage in the ExtractGV pass. This
> prevents linkonce and linkonce_odr symbols from being DCE'd.
>
> Added:
> llvm/trunk/test/Other/extract-linkonce.ll
> Modified:
> llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
>
> Modified: llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=176459&r1=176458&r2=176459&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Mon Mar 4 16:40:44 2013
> @@ -60,7 +60,7 @@ namespace {
> continue;
> }
>
> - bool Local = I->hasLocalLinkage();
> + bool Local = I->isDiscardableIfUnused();
> if (Local)
> I->setVisibility(GlobalValue::HiddenVisibility);
>
> @@ -80,7 +80,7 @@ namespace {
> continue;
> }
>
> - bool Local = I->hasLocalLinkage();
> + bool Local = I->isDiscardableIfUnused();
> if (Local)
> I->setVisibility(GlobalValue::HiddenVisibility);
>
> @@ -97,7 +97,7 @@ namespace {
> Module::alias_iterator CurI = I;
> ++I;
>
> - if (CurI->hasLocalLinkage()) {
> + if (CurI->isDiscardableIfUnused()) {
> CurI->setVisibility(GlobalValue::HiddenVisibility);
Little bit of deja vu? Is there some refactoring that could be done to
reduce the duplication in this code? (I haven't really looked in
detail, just saw a patch with three rather similar changes to rather
similar code)
> CurI->setLinkage(GlobalValue::ExternalLinkage);
> }
>
> Added: llvm/trunk/test/Other/extract-linkonce.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/extract-linkonce.ll?rev=176459&view=auto
> ==============================================================================
> --- llvm/trunk/test/Other/extract-linkonce.ll (added)
> +++ llvm/trunk/test/Other/extract-linkonce.ll Mon Mar 4 16:40:44 2013
> @@ -0,0 +1,23 @@
> +; RUN: llvm-extract -func foo -S < %s | FileCheck %s
> +; RUN: llvm-extract -delete -func foo -S < %s | FileCheck --check-prefix=DELETE %s
> +
> +; Test that we don't convert weak_odr to external definitions.
> +
> +; CHECK: @bar = external hidden global i32
> +; CHECK: define hidden i32* @foo() {
> +; CHECK-NEXT: ret i32* @bar
> +; CHECK-NEXT: }
> +
> +; DELETE: @bar = hidden global i32 42
> +; DELETE: declare hidden i32* @foo()
> +
> + at bar = linkonce global i32 42
> +
> +define linkonce i32* @foo() {
> + ret i32* @bar
> +}
> +
> +define void @g() {
> + call i32* @foo()
> + ret void
> +}
>
>
> _______________________________________________
> 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