[llvm-commits] [llvm] r75093 - /llvm/trunk/lib/Target/X86/X86Subtarget.cpp

Chris Lattner sabre at nondot.org
Wed Jul 8 20:27:33 PDT 2009


Author: lattner
Date: Wed Jul  8 22:27:27 2009
New Revision: 75093

URL: http://llvm.org/viewvc/llvm-project?rev=75093&view=rev
Log:
Reduce indentation in GVRequiresExtraLoad.  Return true for windows
with DLLImport symbols even when in -static mode.

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

Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=75093&r1=75092&r2=75093&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Wed Jul  8 22:27:27 2009
@@ -40,32 +40,34 @@
 /// or index register of the address, not the GV offset field.
 bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
                                        const TargetMachine& TM,
-                                       bool isDirectCall) const
-{
-  // FIXME: PIC
-  if (TM.getRelocationModel() != Reloc::Static &&
-      TM.getCodeModel() != CodeModel::Large) {
-    if (isTargetDarwin()) {
-      if (isDirectCall)
-        return false;
-      bool isDecl = GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode();
-      if (GV->hasHiddenVisibility() &&
-          (Is64Bit || (!isDecl && !GV->hasCommonLinkage())))
-        // If symbol visibility is hidden, the extra load is not needed if
-        // target is x86-64 or the symbol is definitely defined in the current
-        // translation unit.
-        return false;
-      return !isDirectCall && (isDecl || GV->isWeakForLinker());
-    } else if (isTargetELF()) {
-      // Extra load is needed for all externally visible.
-      if (isDirectCall)
-        return false;
-      if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
-        return false;
-      return true;
-    } else if (isTargetCygMing() || isTargetWindows()) {
-      return (GV->hasDLLImportLinkage());
-    }
+                                       bool isDirectCall) const {
+  // Windows targets only require an extra load for DLLImport linkage values,
+  // and they need these regardless of whether we're in PIC mode or not.
+  if (isTargetCygMing() || isTargetWindows())
+    return GV->hasDLLImportLinkage();
+
+  if (TM.getRelocationModel() == Reloc::Static ||
+      TM.getCodeModel() == CodeModel::Large)
+    return false;
+    
+  if (isTargetDarwin()) {
+    if (isDirectCall)
+      return false;
+    bool isDecl = GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode();
+    if (GV->hasHiddenVisibility() &&
+        (Is64Bit || (!isDecl && !GV->hasCommonLinkage())))
+      // If symbol visibility is hidden, the extra load is not needed if
+      // target is x86-64 or the symbol is definitely defined in the current
+      // translation unit.
+      return false;
+    return !isDirectCall && (isDecl || GV->isWeakForLinker());
+  } else if (isTargetELF()) {
+    // Extra load is needed for all externally visible.
+    if (isDirectCall)
+      return false;
+    if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
+      return false;
+    return true;
   }
   return false;
 }





More information about the llvm-commits mailing list