r289744 - Use PIC relocation mode by default for PowerPC64 ELF
Joerg Sonnenberger via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 14 16:02:57 PST 2016
Author: joerg
Date: Wed Dec 14 18:02:57 2016
New Revision: 289744
URL: http://llvm.org/viewvc/llvm-project?rev=289744&view=rev
Log:
Use PIC relocation mode by default for PowerPC64 ELF
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.
Differential Revision: https://reviews.llvm.org/D26564
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/ppc-abi.c
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=289744&r1=289743&r2=289744&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Dec 14 18:02:57 2016
@@ -2879,7 +2879,15 @@ bool Generic_GCC::IsUnwindTablesDefault(
}
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; }
Modified: cfe/trunk/test/Driver/ppc-abi.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-abi.c?rev=289744&r1=289743&r2=289744&view=diff
==============================================================================
--- cfe/trunk/test/Driver/ppc-abi.c (original)
+++ cfe/trunk/test/Driver/ppc-abi.c Wed Dec 14 18:02:57 2016
@@ -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"
More information about the cfe-commits
mailing list