]> granicus.if.org Git - llvm/commitdiff
Use shouldAssumeDSOLocal.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 22 Jun 2016 22:09:17 +0000 (22:09 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 22 Jun 2016 22:09:17 +0000 (22:09 +0000)
With this it handle -fPIE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273499 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/pie.ll [new file with mode: 0644]

index 68d1a679e8357ab23d078a95034f6c15e2961c7e..1df07071f8efb289c2e60ba55153af60d8799878 100644 (file)
@@ -23,6 +23,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/CallingConvLower.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -4287,11 +4288,10 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain,
     Reloc::Model RM = DAG.getTarget().getRelocationModel();
     const Triple &TargetTriple = Subtarget.getTargetTriple();
     const GlobalValue *GV = G->getGlobal();
-    if ((RM != Reloc::Static &&
-         (TargetTriple.isMacOSX() && TargetTriple.isMacOSXVersionLT(10, 5)) &&
-         !GV->isStrongDefinitionForLinker()) ||
-        (Subtarget.isTargetELF() && !isPPC64 && !GV->hasLocalLinkage() &&
-         RM == Reloc::PIC_)) {
+    bool OldMachOLinker =
+        TargetTriple.isMacOSX() && TargetTriple.isMacOSXVersionLT(10, 5);
+    if (!shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV) &&
+        (OldMachOLinker || (Subtarget.isTargetELF() && !isPPC64))) {
       // PC-relative references to external symbols should go through $stub,
       // unless we're building with the leopard linker or later, which
       // automatically synthesizes these stubs.
diff --git a/test/CodeGen/PowerPC/pie.ll b/test/CodeGen/PowerPC/pie.ll
new file mode 100644 (file)
index 0000000..56e07ca
--- /dev/null
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=powerpc-pc-linux -relocation-model=pic | FileCheck %s
+
+
+define void @f() {
+  ret void
+}
+
+define void @g() {
+; CHECK: g:
+; CHECK: bl f{{$}}
+  call void @f()
+  ret void
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"PIE Level", i32 1}