[TargetMachine] Move X86 specific shouldAssumeDSOLocal logic to X86Subtarget::classif...
authorFangrui Song <i@maskray.me>
Sat, 5 Dec 2020 20:32:50 +0000 (12:32 -0800)
committerFangrui Song <i@maskray.me>
Sat, 5 Dec 2020 20:32:50 +0000 (12:32 -0800)
llvm/lib/Target/TargetMachine.cpp
llvm/lib/Target/X86/X86Subtarget.cpp

index 5067d94..dd41bc2 100644 (file)
@@ -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())
index d50c552..8c92485 100644 (file)
@@ -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;
   }