]> granicus.if.org Git - clang/commitdiff
Driver: switch Windows to static RelocModel
authorSaleem Abdulrasool <compnerd@compnerd.org>
Tue, 27 Dec 2016 02:20:35 +0000 (02:20 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Tue, 27 Dec 2016 02:20:35 +0000 (02:20 +0000)
Windows uses PE/COFF which is inherently position independent.  The use
of the PIC model is unnecessary.  In fact, we would generate invalid
code using the ELF PIC model when PIC was enabled previously.  Now that
we no longer accept -fPIC and -fpoc, this switches the internal
representation to the static model to permit us to make PIC modules
invalid when targeting Windows.  This should not change the code
generation, only the internal state management.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290569 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/MSVCToolChain.cpp
lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
test/Driver/pic.c

index 95cf056f7a741d7a0c849d95aec13d85c0a586f1..0bbe79c3aa7252d64ae0a90709f8f06386cdc76b 100644 (file)
@@ -82,18 +82,6 @@ bool MSVCToolChain::IsUnwindTablesDefault() const {
   return getArch() == llvm::Triple::x86_64;
 }
 
-bool MSVCToolChain::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
-}
-
-bool MSVCToolChain::isPIEDefault() const {
-  return false;
-}
-
-bool MSVCToolChain::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
-}
-
 #ifdef USE_WIN32
 static bool readFullStringValue(HKEY hkey, const char *valueName,
                                 std::string &value) {
index 968b0cb4724aebf4acc63c3a0e6df0f2a9855efb..d831ba8adc3fcb1a9ddf21525d6289155c950c45 100644 (file)
@@ -2880,22 +2880,13 @@ bool Generic_GCC::IsUnwindTablesDefault() const {
 
 bool Generic_GCC::isPICDefault() const {
   switch (getArch()) {
-  case llvm::Triple::x86_64:
-    return getTriple().isOSWindows();
+  default: return false;
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
     return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
-  default:
-    return false;
   }
 }
 
-bool Generic_GCC::isPIEDefault() const { return false; }
-
-bool Generic_GCC::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
-}
-
 bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   switch (getTriple().getArch()) {
   case llvm::Triple::x86:
index 7dab08915d48c232c3b8ad1899b5e6e4c53b833a..c8b7931cac82354835abd33bf3fa4f6564ade54f 100644 (file)
@@ -232,8 +232,8 @@ public:
 
   bool IsUnwindTablesDefault() const override;
   bool isPICDefault() const override;
-  bool isPIEDefault() const override;
-  bool isPICDefaultForced() const override;
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
   bool IsIntegratedAssemblerDefault() const override;
   llvm::opt::DerivedArgList *
   TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
@@ -1136,9 +1136,9 @@ public:
 
   bool IsIntegratedAssemblerDefault() const override;
   bool IsUnwindTablesDefault() const override;
-  bool isPICDefault() const override;
-  bool isPIEDefault() const override;
-  bool isPICDefaultForced() const override;
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
index 9f9d09c54cf0899b085cdbe354895319e41d06eb..57d1e3fd7dcf3cf66ed0cde903e5f2f4abb575ae 100644 (file)
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target arm64-linux-android -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
-//
-// On Windows-X64 PIC is enabled by default
-// RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
-// RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+