[PATCH] D72479: [PowerPC][AIX] Make PIC the default relocation model for AIX
Steven Wan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 13:41:55 PST 2020
stevewan created this revision.
Herald added subscribers: llvm-commits, shchenz, jsji, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.
stevewan edited the summary of this revision.
stevewan added reviewers: daltenty, hubert.reinterpretcast, DiggerLin, Xiangling_L, sfertile.
Herald added a subscriber: wuzish.
The `llc` tool currently defaults to Static relocation model and generates non-relocatable code for 32-bit Power. This is not desirable on AIX where we always generate Position Independent Code (PIC). This patch makes PIC the default relocation model for AIX.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72479
Files:
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
llvm/test/CodeGen/PowerPC/aix-pic-default.ll
Index: llvm/test/CodeGen/PowerPC/aix-pic-default.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-pic-default.ll
@@ -0,0 +1,19 @@
+; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK64 %s
+
+ at a = common global i32 0
+ at b = constant i32* @a
+
+;CHECK: .comm a[RW],4,2
+;CHECK-NEXT: .csect .data[RW]
+;CHECK-NEXT: .globl b
+;CHECK-NEXT: .align 2
+;CHECK-NEXT: b:
+;CHECK-NEXT: .long a
+
+;CHECK64: .comm a[RW],4,2
+;CHECK64-NEXT: .csect .data[RW]
+;CHECK64-NEXT: .globl b
+;CHECK64-NEXT: .align 3
+;CHECK64-NEXT: b:
+;CHECK64-NEXT: .llong a
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -230,8 +230,8 @@
if (TT.isOSDarwin())
return Reloc::DynamicNoPIC;
- // Big Endian PPC is PIC by default.
- if (TT.getArch() == Triple::ppc64)
+ // Big Endian PPC and AIX default to PIC.
+ if (TT.getArch() == Triple::ppc64 || TT.isOSAIX())
return Reloc::PIC_;
// Rest are static by default.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72479.237187.patch
Type: text/x-patch
Size: 1343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200109/2d04f4e5/attachment.bin>
More information about the llvm-commits
mailing list