[llvm-branch-commits] [llvm] db13a13 - [TargetMachine] Move X86 specific shouldAssumeDSOLocal logic to X86Subtarget::classifyGlobalFunctionReference

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 5 12:37:21 PST 2020


Author: Fangrui Song
Date: 2020-12-05T12:32:50-08:00
New Revision: db13a138bdad3aae1f0f387c871c43729badbc69

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

LOG: [TargetMachine] Move X86 specific shouldAssumeDSOLocal logic to X86Subtarget::classifyGlobalFunctionReference

Added: 
    

Modified: 
    llvm/lib/Target/TargetMachine.cpp
    llvm/lib/Target/X86/X86Subtarget.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 5067d942ec4c..dd41bc25ff3f 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -109,17 +109,8 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   // generated code.
   // FIXME: Add a module level metadata for whether intrinsics should be assumed
   // local.
-  if (!GV) {
-    if (TT.isOSBinFormatCOFF())
-      return true;
-    if (TT.isOSBinFormatELF() && TT.isX86() && RM == Reloc::Static) {
-      // For -fno-plt, we cannot assume that intrinsics are local since the
-      // linker can convert some direct access to access via plt.
-      return !M.getRtLibUseGOT();
-    }
-
-    return false;
-  }
+  if (!GV)
+    return TT.isOSBinFormatCOFF();
 
   // If the IR producer requested that this GV be treated as dso local, obey.
   if (GV->isDSOLocal())

diff  --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index d50c552a65b6..8c9248569a13 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -202,6 +202,9 @@ X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV,
          (!F && M.getRtLibUseGOT())) &&
         is64Bit())
        return X86II::MO_GOTPCREL;
+    // Reference ExternalSymbol directly in static relocation model.
+    if (!GV && TM.getRelocationModel() == Reloc::Static)
+      return X86II::MO_NO_FLAG;
     return X86II::MO_PLT;
   }
 


        


More information about the llvm-branch-commits mailing list