[llvm] r252054 - [ThinLTO] Always set linkage type to external when converting alias

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 09:33:37 PST 2015


Hey Lang,

Seem to recall you discussing this issue coming up in Orc recently too?
Hopefully there's some way to refactor/reuse the logic between Orc lazy
module splitting and ThinLTO splitting?

- Dave

On Wed, Nov 4, 2015 at 8:01 AM, Teresa Johnson via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: tejohnson
> Date: Wed Nov  4 10:01:16 2015
> New Revision: 252054
>
> URL: http://llvm.org/viewvc/llvm-project?rev=252054&view=rev
> Log:
> [ThinLTO] Always set linkage type to external when converting alias
>
> When converting an alias to a non-alias when the aliasee is not
> imported, ensure that the linkage type is set to external so that it is
> a valid linkage type. Added a test case that exposed this issue.
>
> Modified:
>     llvm/trunk/lib/Linker/LinkModules.cpp
>     llvm/trunk/test/Linker/funcimport.ll
>
> Modified: llvm/trunk/lib/Linker/LinkModules.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=252054&r1=252053&r2=252054&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Linker/LinkModules.cpp (original)
> +++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Nov  4 10:01:16 2015
> @@ -841,10 +841,12 @@ GlobalValue *ModuleLinker::copyGlobalAli
>        assert(F);
>        NewGV = copyFunctionProto(TypeMap, F);
>      }
> -    // Set the linkage to ExternalWeak, see also comments in
> -    // ModuleLinker::getLinkage.
> +    // Set the linkage to External or ExternalWeak (see comments in
> +    // ModuleLinker::getLinkage for why WeakAny is converted to
> ExternalWeak).
>      if (SGA->hasWeakAnyLinkage())
>        NewGV->setLinkage(GlobalValue::ExternalWeakLinkage);
> +    else
> +      NewGV->setLinkage(GlobalValue::ExternalLinkage);
>      // Don't attempt to link body, needs to be a declaration.
>      DoNotLinkFromSource.insert(SGA);
>      return NewGV;
>
> Modified: llvm/trunk/test/Linker/funcimport.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/funcimport.ll?rev=252054&r1=252053&r2=252054&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Linker/funcimport.ll (original)
> +++ llvm/trunk/test/Linker/funcimport.ll Wed Nov  4 10:01:16 2015
> @@ -14,11 +14,16 @@
>
>  ; Ensure that both weak alias to an imported function and strong alias to
> a
>  ; non-imported function are correctly turned into declarations.
> +; Also ensures that alias to a linkonce function is turned into a
> declaration
> +; and that the associated linkonce function is not in the output, as it is
> +; lazily linked and never referenced/materialized.
>  ; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc
> -import=globalfunc1:%t.bc -S | FileCheck %s --check-prefix=IMPORTGLOB1
>  ; IMPORTGLOB1: define available_externally void @globalfunc1
>  ; IMPORTGLOB1: declare void @globalfunc2
>  ; IMPORTGLOB1: declare extern_weak void @weakalias
>  ; IMPORTGLOB1: declare void @analias
> +; IMPORTGLOB1: declare void @linkoncealias
> +; IMPORTGLOB1-NOT: @linkoncefunc
>
>  ; Ensure that weak alias to a non-imported function is correctly
>  ; turned into a declaration, but that strong alias to an imported function
> @@ -91,6 +96,7 @@
>
>  @weakalias = weak alias void (...), bitcast (void ()* @globalfunc1 to
> void (...)*)
>  @analias = alias void (...), bitcast (void ()* @globalfunc2 to void
> (...)*)
> + at linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc to
> void (...)*)
>
>  define void @globalfunc1() #0 {
>  entry:
> @@ -101,6 +107,11 @@ define void @globalfunc2() #0 {
>  entry:
>    ret void
>  }
> +
> +define linkonce_odr void @linkoncefunc() #0 {
> +entry:
> +  ret void
> +}
>
>  define i32 @referencestatics(i32 %i) #0 {
>  entry:
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/697a8f7c/attachment.html>


More information about the llvm-commits mailing list