[PATCH] D38554: Fixed ppc32 function relocations in non-pic mode

vit9696 via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 11:17:29 PDT 2017


vit9696 created this revision.
Herald added subscribers: kbarton, nemanjai.

Appears to be a regression introduced in r273499 and r273595.
Further discussion at http://lists.llvm.org/pipermail/llvm-dev/2017-October/117982.html


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::PIC_;
 
   if (isFunctionGlobalAddress(Callee)) {
     GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Callee);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38554.117703.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/ff44c891/attachment.bin>


More information about the llvm-commits mailing list