[llvm] r273499 - Use shouldAssumeDSOLocal.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 15:09:17 PDT 2016


Author: rafael
Date: Wed Jun 22 17:09:17 2016
New Revision: 273499

URL: http://llvm.org/viewvc/llvm-project?rev=273499&view=rev
Log:
Use shouldAssumeDSOLocal.

With this it handle -fPIE.

Added:
    llvm/trunk/test/CodeGen/PowerPC/pie.ll
Modified:
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=273499&r1=273498&r2=273499&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Wed Jun 22 17:09:17 2016
@@ -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 &
     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.

Added: llvm/trunk/test/CodeGen/PowerPC/pie.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/pie.ll?rev=273499&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/pie.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/pie.ll Wed Jun 22 17:09:17 2016
@@ -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}




More information about the llvm-commits mailing list