[lld] r322572 - Set dso_local in lld.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 17:11:38 PST 2018


I'm not familiar with this part of code and wondering what this code is for.

On Tue, Jan 16, 2018 at 8:49 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rafael
> Date: Tue Jan 16 08:49:05 2018
> New Revision: 322572
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322572&view=rev
> Log:
> Set dso_local in lld.
>
> We were already doing this in gold, but not in lld.
>
> Modified:
>     lld/trunk/ELF/LTO.cpp
>     lld/trunk/test/ELF/lto/asmundef.ll
>     lld/trunk/test/ELF/lto/internalize-basic.ll
>     lld/trunk/test/ELF/lto/internalize-exportdyn.ll
>     lld/trunk/test/ELF/lto/internalize-llvmused.ll
>     lld/trunk/test/ELF/lto/wrap-1.ll
>
> Modified: lld/trunk/ELF/LTO.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?
> rev=322572&r1=322571&r2=322572&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/LTO.cpp (original)
> +++ lld/trunk/ELF/LTO.cpp Tue Jan 16 08:49:05 2018
> @@ -134,6 +134,8 @@ void BitcodeCompiler::add(BitcodeFile &F
>      if (auto *Cmd = dyn_cast<SymbolAssignment>(Base))
>        ScriptSymbols.insert(Cmd->Name);
>
> +  bool IsExecutable = !Config->Shared && !Config->Relocatable;
> +
>    // Provide a resolution to the LTO API for each symbol.
>    for (const lto::InputFile::Symbol &ObjSym : Obj.symbols()) {
>      Symbol *Sym = Syms[SymNum];
> @@ -156,6 +158,10 @@ void BitcodeCompiler::add(BitcodeFile &F
>      R.VisibleToRegularObj = Config->Relocatable ||
> Sym->IsUsedInRegularObj ||
>                              (R.Prevailing && Sym->includeInDynsym()) ||
>                              UsedStartStop.count(ObjSym.getSectionName());
> +    R.FinalDefinitionInLinkageUnit =
> +        Sym->isDefined() &&
> +        (IsExecutable || Sym->getVisibility() != STV_DEFAULT);
> +
>      if (R.Prevailing)
>        undefine(Sym);
>
>
> Modified: lld/trunk/test/ELF/lto/asmundef.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> lto/asmundef.ll?rev=322572&r1=322571&r2=322572&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/lto/asmundef.ll (original)
> +++ lld/trunk/test/ELF/lto/asmundef.ll Tue Jan 16 08:49:05 2018
> @@ -20,5 +20,5 @@ define void @_start() {
>    ret void
>  }
>
> -; CHECK: define void @foo
> +; CHECK: define dso_local void @foo
>
>
> Modified: lld/trunk/test/ELF/lto/internalize-basic.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> lto/internalize-basic.ll?rev=322572&r1=322571&r2=322572&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/lto/internalize-basic.ll (original)
> +++ lld/trunk/test/ELF/lto/internalize-basic.ll Tue Jan 16 08:49:05 2018
> @@ -15,7 +15,7 @@ define hidden void @foo() {
>  }
>
>  ; Check that _start is not internalized.
> -; CHECK: define void @_start()
> +; CHECK: define dso_local void @_start()
>
>  ; Check that foo function is correctly internalized.
>  ; CHECK: define internal void @foo()
>
> Modified: lld/trunk/test/ELF/lto/internalize-exportdyn.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> lto/internalize-exportdyn.ll?rev=322572&r1=322571&r2=322572&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/lto/internalize-exportdyn.ll (original)
> +++ lld/trunk/test/ELF/lto/internalize-exportdyn.ll Tue Jan 16 08:49:05
> 2018
> @@ -38,10 +38,10 @@ define linkonce_odr void @baz() {
>  @use_baz = global void ()* @baz
>
>  ; Check what gets internalized.
> -; CHECK: define void @_start()
> -; CHECK: define void @foo()
> +; CHECK: define dso_local void @_start()
> +; CHECK: define dso_local void @foo()
>  ; CHECK: define internal void @bar()
>  ; CHECK: define internal void @zed()
>  ; CHECK: define internal void @zed2()
> -; CHECK: define weak_odr void @bah()
> -; CHECK: define weak_odr void @baz()
> +; CHECK: define weak_odr dso_local void @bah()
> +; CHECK: define weak_odr dso_local void @baz()
>
> Modified: lld/trunk/test/ELF/lto/internalize-llvmused.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> lto/internalize-llvmused.ll?rev=322572&r1=322571&r2=322572&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/lto/internalize-llvmused.ll (original)
> +++ lld/trunk/test/ELF/lto/internalize-llvmused.ll Tue Jan 16 08:49:05
> 2018
> @@ -17,4 +17,4 @@ define hidden void @f() {
>  @llvm.used = appending global [1 x i8*] [ i8* bitcast (void ()* @f to
> i8*)]
>
>  ; Check that f is not internalized.
> -; CHECK: define hidden void @f()
> +; CHECK: define dso_local hidden void @f()
>
> Modified: lld/trunk/test/ELF/lto/wrap-1.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> lto/wrap-1.ll?rev=322572&r1=322571&r2=322572&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/lto/wrap-1.ll (original)
> +++ lld/trunk/test/ELF/lto/wrap-1.ll Tue Jan 16 08:49:05 2018
> @@ -20,8 +20,8 @@
>  ; Make sure that the 'r' (linker redefined) bit is set for bar and
> __wrap_bar
>  ; in the resolutions file.
>  ; RESOLS: ,bar,xr
> -; RESOLS: ,__wrap_bar,px
> -; RESOLS: ,__real_bar,pxr
> +; RESOLS: ,__wrap_bar,plx
> +; RESOLS: ,__real_bar,plxr
>
>  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>  target triple = "x86_64-unknown-linux-gnu"
>
>
> _______________________________________________
> 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/20180116/2de66e44/attachment.html>


More information about the llvm-commits mailing list