[llvm-branch-commits] [llvm] 930b339 - [TargetMachine] Clean up TargetMachine::shouldAssumeDSOLocal after x86-32 specific hack is moved to X86Subtarget

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 5 15:18:50 PST 2020


Author: Fangrui Song
Date: 2020-12-05T15:13:42-08:00
New Revision: 930b3398c7e4b3b15a9f262a2856d11fb2071eb7

URL: https://github.com/llvm/llvm-project/commit/930b3398c7e4b3b15a9f262a2856d11fb2071eb7
DIFF: https://github.com/llvm/llvm-project/commit/930b3398c7e4b3b15a9f262a2856d11fb2071eb7.diff

LOG: [TargetMachine] Clean up TargetMachine::shouldAssumeDSOLocal after x86-32 specific hack is moved to X86Subtarget

With my previous commit, X86Subtarget::classifyGlobalReference has learned to
use MO_NO_FLAG for 32-bit ELF -fno-pic code, the x86-32 special case in
TargetMachine::shouldAssumeDSOLocal can be removed. Since we no longer imply
dso_local for function declarations, we can drop the ppc64 special case as well.

This is NFC in terms of Clang emitted assembly.

Added: 
    

Modified: 
    llvm/lib/Target/TargetMachine.cpp
    llvm/test/CodeGen/X86/abi-isel.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 9770446470e7..3b48fd3622dc 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -173,27 +173,6 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
     // If the symbol is defined, it cannot be preempted.
     if (!GV->isDeclarationForLinker())
       return true;
-
-    // A symbol marked nonlazybind should not be accessed with a plt. If the
-    // symbol turns out to be external, the linker will convert a direct
-    // access to an access via the plt, so don't assume it is local.
-    const Function *F = dyn_cast<Function>(GV);
-    if (F && F->hasFnAttribute(Attribute::NonLazyBind))
-      return false;
-    Triple::ArchType Arch = TT.getArch();
-
-    // PowerPC64 prefers TOC indirection to avoid copy relocations.
-    if (TT.isPPC64())
-      return false;
-
-    // dso_local is traditionally implied for Reloc::Static. Eventually we shall
-    // drop the if block entirely and respect dso_local/dso_preemptable
-    // specifiers set by the frontend.
-    if (RM == Reloc::Static) {
-      // TODO Remove the special case for x86-32.
-      if (Arch == Triple::x86 && !F && !GV->isThreadLocal())
-        return true;
-    }
   } else if (TT.isOSBinFormatELF()) {
     // If dso_local allows AsmPrinter::getSymbolPreferLocal to use a local
     // alias, set the flag. We cannot set dso_local for other global values,

diff  --git a/llvm/test/CodeGen/X86/abi-isel.ll b/llvm/test/CodeGen/X86/abi-isel.ll
index 102120aa66bd..170e597d7498 100644
--- a/llvm/test/CodeGen/X86/abi-isel.ll
+++ b/llvm/test/CodeGen/X86/abi-isel.ll
@@ -1246,7 +1246,8 @@ define void @qux01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: qux01:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $dst+64, ptr
+; LINUX-32-STATIC-NEXT:    leal dst+64, %eax
+; LINUX-32-STATIC-NEXT:    movl %eax, ptr
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: qux01:
@@ -1334,7 +1335,8 @@ define void @qxx01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: qxx01:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $xdst+64, ptr
+; LINUX-32-STATIC-NEXT:    leal xdst+64, %eax
+; LINUX-32-STATIC-NEXT:    movl %eax, ptr
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: qxx01:
@@ -4519,7 +4521,8 @@ define void @moo01(i64 %i) nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: moo01:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $dst+262144, ptr
+; LINUX-32-STATIC-NEXT:    leal dst+262144, %eax
+; LINUX-32-STATIC-NEXT:    movl %eax, ptr
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: moo01:
@@ -7448,7 +7451,7 @@ define i8* @bat00() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bat00:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $src+64, %eax
+; LINUX-32-STATIC-NEXT:    leal src+64, %eax
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: bat00:
@@ -7519,7 +7522,7 @@ define i8* @bxt00() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bxt00:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $xsrc+64, %eax
+; LINUX-32-STATIC-NEXT:    leal xsrc+64, %eax
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: bxt00:
@@ -7590,7 +7593,7 @@ define i8* @bat01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bat01:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $dst+64, %eax
+; LINUX-32-STATIC-NEXT:    leal dst+64, %eax
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: bat01:
@@ -7661,7 +7664,7 @@ define i8* @bxt01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bxt01:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $xdst+64, %eax
+; LINUX-32-STATIC-NEXT:    leal xdst+64, %eax
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: bxt01:
@@ -8226,7 +8229,7 @@ define i8* @bam00() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bam00:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $src+262144, %eax
+; LINUX-32-STATIC-NEXT:    leal src+262144, %eax
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: bam00:
@@ -8297,7 +8300,7 @@ define i8* @bam01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bam01:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $dst+262144, %eax
+; LINUX-32-STATIC-NEXT:    leal dst+262144, %eax
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: bam01:
@@ -8368,7 +8371,7 @@ define i8* @bxm01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bxm01:
 ; LINUX-32-STATIC:       # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:    movl $xdst+262144, %eax
+; LINUX-32-STATIC-NEXT:    leal xdst+262144, %eax
 ; LINUX-32-STATIC-NEXT:    retl
 ;
 ; LINUX-32-PIC-LABEL: bxm01:


        


More information about the llvm-branch-commits mailing list