[PATCH] D38554: Fixed ppc32 function relocations in non-pic mode
vit9696 via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 23 06:35:55 PDT 2017
vit9696 updated this revision to Diff 119839.
vit9696 added a comment.
Alright, now I understand that the condition I added in the beginning did not conform to all the other relocation models available in LLVM:
-relocation-model - Choose relocation model
=static - Non-relocatable code
=pic - Fully relocatable, position independent code
=dynamic-no-pic - Relocatable external references, non-relocatable code
=ropi - Code and read-only data relocatable, accessed PC-relative
=rwpi - Read-write data relocatable, accessed relative to static base
=ropi-rwpi - Combination of ropi and rwpi
Initially I added PLT to be enabled only for PIC model, and you are right, in case of dynamic-no-pic model (which allows dynamic relocation) PLT must be used. I updated the diff to enable PLT unless static relocation model is used. No issues from then on?
https://reviews.llvm.org/D38554
Files:
lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/ppc32-static.ll
Index: test/CodeGen/PowerPC/ppc32-static.ll
===================================================================
--- test/CodeGen/PowerPC/ppc32-static.ll
+++ test/CodeGen/PowerPC/ppc32-static.ll
@@ -0,0 +1,13 @@
+; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=static | FileCheck --match-full-lines %s
+
+declare i32 @call_foo(i32, ...)
+
+define i32 @foo() {
+entry:
+ %call = call i32 (i32, ...) @call_foo(i32 0, i32 1)
+ ret i32 0
+}
+
+; LABEL:foo:
+; CHECK-NOT: bl call_foo at PLT
+; CHECK: bl call_foo
Index: lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.cpp
+++ lib/Target/PowerPC/PPCISelLowering.cpp
@@ -4719,7 +4719,8 @@
if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee))
GV = G->getGlobal();
bool Local = TM.shouldAssumeDSOLocal(*Mod, GV);
- bool UsePlt = !Local && Subtarget.isTargetELF() && !isPPC64;
+ bool UsePlt = !Local && Subtarget.isTargetELF() && !isPPC64 &&
+ DAG.getTarget().getRelocationModel() != Reloc::Static;
if (isFunctionGlobalAddress(Callee)) {
GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Callee);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38554.119839.patch
Type: text/x-patch
Size: 1199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171023/19631fb3/attachment.bin>
More information about the llvm-commits
mailing list