When in -static mode, force the PIC style to none.  Doing this requires fixing
code which conflated RIPRel PIC with x86-64.  Fix these to just check for X86-64
directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75092 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index 5cf18a0..1909986 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -147,6 +147,9 @@
       setRelocationModel(Reloc::Static);
   }
 
+  assert(getRelocationModel() != Reloc::Default &&
+         "Relocation mode not picked");
+
   // ELF doesn't have a distinct dynamic-no-PIC model. Dynamic-no-PIC
   // is defined as a model for code which may be used in static or
   // dynamic executables but not necessarily a shared library. On ELF
@@ -164,9 +167,9 @@
       setCodeModel(CodeModel::Small);
   }
 
-  if (Subtarget.isTargetCygMing())
-    Subtarget.setPICStyle(PICStyles::WinPIC);
-  else if (Subtarget.isTargetDarwin()) {
+  if (Subtarget.isTargetCygMing()) {
+    Subtarget.setPICStyle(PICStyles::None);
+  } else if (Subtarget.isTargetDarwin()) {
     if (Subtarget.is64Bit())
       Subtarget.setPICStyle(PICStyles::RIPRel);
     else
@@ -177,6 +180,11 @@
     else
       Subtarget.setPICStyle(PICStyles::GOT);
   }
+      
+  // Finally, unless we're in PIC or DynamicNoPIC mode, set the PIC style to
+  // None.
+  if (getRelocationModel() == Reloc::Static)
+    Subtarget.setPICStyle(PICStyles::None);
 }
 
 //===----------------------------------------------------------------------===//