[PATCH] D39625: Attribute nonlazybind should not affect calls to functions with hidden visibility

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 20:22:43 PDT 2017


It is not just hidden visibility.

If we were to list all cases this if would grow to be a copy of
shouldAssumeDSOLocal.

The check for hasFnAttribute(Attribute::NonLazyBind) should be moved
bellow shouldAssumeDSOLocal and shouldAssumeDSOLocal should not assume
that a NonLazyBind is local.

Cheers,
Rafael

Sriraman Tallam via Phabricator <reviews at reviews.llvm.org> writes:

> tmsriram created this revision.
>
> Attribute nonlazybind should not affect calls to functions with hidden visibility.
>
> https://reviews.llvm.org/D39065 skips the PLT for calls to external functions marked with "nonlazybind" attribute.  However, this should not affect functions with hidden visibility or local linkage.  This patch fixes that.
>
>
> https://reviews.llvm.org/D39625
>
> Files:
>   lib/Target/X86/X86Subtarget.cpp
>   test/CodeGen/X86/no-plt.ll
>
>
> Index: test/CodeGen/X86/no-plt.ll
> ===================================================================
> --- test/CodeGen/X86/no-plt.ll
> +++ test/CodeGen/X86/no-plt.ll
> @@ -6,18 +6,25 @@
>  define i32 @main() #0 {
>  ; X64: callq *_Z3foov at GOTPCREL(%rip)
>  ; X64: callq _Z3barv
> +; X64: callq _Z3bazv
>  
>  entry:
>    %retval = alloca i32, align 4
>    store i32 0, i32* %retval, align 4
>    %call1 = call i32 @_Z3foov()
>    %call2 = call i32 @_Z3barv()
> +  %call3 = call i32 @_Z3bazv()
>    ret i32 0
>  }
>  
>  ; Function Attrs: nonlazybind
>  declare i32 @_Z3foov() #1
>  
>  declare i32 @_Z3barv() #2
>  
> +; Function Attrs: nonlazybind
> +declare hidden i32 @_Z3bazv() #3
> +
> +
>  attributes #1 = { nonlazybind }
> +attributes #3 = { nonlazybind }
> Index: lib/Target/X86/X86Subtarget.cpp
> ===================================================================
> --- lib/Target/X86/X86Subtarget.cpp
> +++ lib/Target/X86/X86Subtarget.cpp
> @@ -150,6 +150,7 @@
>    // target.
>    if (isTargetELF() && is64Bit() && F &&
>        F->hasFnAttribute(Attribute::NonLazyBind) &&
> +      !GV->hasLocalLinkage() && GV->hasDefaultVisibility() &&
>        GV->isDeclarationForLinker())
>      return X86II::MO_GOTPCREL;
>  
>
>
> Index: test/CodeGen/X86/no-plt.ll
> ===================================================================
> --- test/CodeGen/X86/no-plt.ll
> +++ test/CodeGen/X86/no-plt.ll
> @@ -6,18 +6,25 @@
>  define i32 @main() #0 {
>  ; X64: callq *_Z3foov at GOTPCREL(%rip)
>  ; X64: callq _Z3barv
> +; X64: callq _Z3bazv
>  
>  entry:
>    %retval = alloca i32, align 4
>    store i32 0, i32* %retval, align 4
>    %call1 = call i32 @_Z3foov()
>    %call2 = call i32 @_Z3barv()
> +  %call3 = call i32 @_Z3bazv()
>    ret i32 0
>  }
>  
>  ; Function Attrs: nonlazybind
>  declare i32 @_Z3foov() #1
>  
>  declare i32 @_Z3barv() #2
>  
> +; Function Attrs: nonlazybind
> +declare hidden i32 @_Z3bazv() #3
> +
> +
>  attributes #1 = { nonlazybind }
> +attributes #3 = { nonlazybind }
> Index: lib/Target/X86/X86Subtarget.cpp
> ===================================================================
> --- lib/Target/X86/X86Subtarget.cpp
> +++ lib/Target/X86/X86Subtarget.cpp
> @@ -150,6 +150,7 @@
>    // target.
>    if (isTargetELF() && is64Bit() && F &&
>        F->hasFnAttribute(Attribute::NonLazyBind) &&
> +      !GV->hasLocalLinkage() && GV->hasDefaultVisibility() &&
>        GV->isDeclarationForLinker())
>      return X86II::MO_GOTPCREL;
>  


More information about the llvm-commits mailing list