[PATCH] D26564: Use PIC relocation mode by default for PowerPC64 ELF

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 11 14:29:55 PST 2016


joerg created this revision.
joerg added a reviewer: hfinkel.
joerg added a subscriber: cfe-commits.
Herald added a subscriber: nemanjai.

Most of the PowerPC64 code generation already creates PIC access. This changes to a full PIC default, similar to what GCC is doing.

Overall, a monolithic clang binary shrinks by 600KB (about 1%). This can be a slight regression for TLS access and will use the TOC more aggressively instead of synthesizing immediates. It is expected to be performance neutral.


https://reviews.llvm.org/D26564

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/ppc-abi.c


Index: test/Driver/ppc-abi.c
===================================================================
--- test/Driver/ppc-abi.c
+++ test/Driver/ppc-abi.c
@@ -24,7 +24,10 @@
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
 
+// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1: "-target-abi" "elfv1"
+// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx"
+// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv2: "-target-abi" "elfv2"
 
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2796,7 +2796,15 @@
 }
 
 bool Generic_GCC::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
+  switch (getArch()) {
+  case llvm::Triple::x86_64:
+    return getTriple().isOSWindows();
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
+    return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
+  default:
+    return false;
+  }
 }
 
 bool Generic_GCC::isPIEDefault() const { return false; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26564.77670.patch
Type: text/x-patch
Size: 1258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161111/7558c995/attachment.bin>


More information about the cfe-commits mailing list