[llvm] r273614 - Uses shouldAssumeDSOLocal.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 14:18:59 PDT 2016


Author: rafael
Date: Thu Jun 23 16:18:59 2016
New Revision: 273614

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

With that SystemZ knows to avoid a GOT for PIE.

Added:
    llvm/trunk/test/CodeGen/SystemZ/pie.ll
Modified:
    llvm/trunk/lib/Target/SystemZ/SystemZSubtarget.cpp

Modified: llvm/trunk/lib/Target/SystemZ/SystemZSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZSubtarget.cpp?rev=273614&r1=273613&r2=273614&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZSubtarget.cpp Thu Jun 23 16:18:59 2016
@@ -9,6 +9,7 @@
 
 #include "SystemZSubtarget.h"
 #include "MCTargetDesc/SystemZMCTargetDesc.h"
+#include "llvm/CodeGen/Analysis.h"
 #include "llvm/IR/GlobalValue.h"
 
 using namespace llvm;
@@ -44,15 +45,6 @@ SystemZSubtarget::SystemZSubtarget(const
       InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
       TSInfo(), FrameLowering() {}
 
-// Return true if GV binds locally under reloc model RM.
-static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
-  // For non-PIC, all symbols bind locally.
-  if (RM == Reloc::Static)
-    return true;
-
-  return GV->hasLocalLinkage() || !GV->hasDefaultVisibility();
-}
-
 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
                                        Reloc::Model RM,
                                        CodeModel::Model CM) const {
@@ -63,7 +55,7 @@ bool SystemZSubtarget::isPC32DBLSymbol(c
 
   // For the small model, all locally-binding symbols are in range.
   if (CM == CodeModel::Small)
-    return bindsLocally(GV, RM);
+    return shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV);
 
   // For Medium and above, assume that the symbol is not within the 4GB range.
   // Taking the address of locally-defined text would be OK, but that

Added: llvm/trunk/test/CodeGen/SystemZ/pie.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/pie.ll?rev=273614&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SystemZ/pie.ll (added)
+++ llvm/trunk/test/CodeGen/SystemZ/pie.ll Thu Jun 23 16:18:59 2016
@@ -0,0 +1,13 @@
+; RUN: llc -mtriple=s390x-linux-gnu -relocation-model=pic < %s | FileCheck %s
+
+ at foo = global i32 42
+
+define i32* @get_foo() {
+  ret i32* @foo
+}
+
+; CHECK: larl    %r2, foo{{$}}
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"PIE Level", i32 2}




More information about the llvm-commits mailing list