From e41c71efea8da2beb5f10c1fe7e8cf69b3eb193c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 23 Jun 2016 21:18:59 +0000 Subject: [PATCH] Uses shouldAssumeDSOLocal. With that SystemZ knows to avoid a GOT for PIE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273614 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/SystemZ/SystemZSubtarget.cpp | 12 ++---------- test/CodeGen/SystemZ/pie.ll | 13 +++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 test/CodeGen/SystemZ/pie.ll diff --git a/lib/Target/SystemZ/SystemZSubtarget.cpp b/lib/Target/SystemZ/SystemZSubtarget.cpp index 0b49fcdd8f7..5f947495e32 100644 --- a/lib/Target/SystemZ/SystemZSubtarget.cpp +++ b/lib/Target/SystemZ/SystemZSubtarget.cpp @@ -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 Triple &TT, const std::string &CPU, 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(const GlobalValue *GV, // 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 diff --git a/test/CodeGen/SystemZ/pie.ll b/test/CodeGen/SystemZ/pie.ll new file mode 100644 index 00000000000..8fc26145446 --- /dev/null +++ b/test/CodeGen/SystemZ/pie.ll @@ -0,0 +1,13 @@ +; RUN: llc -mtriple=s390x-linux-gnu -relocation-model=pic < %s | FileCheck %s + +@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} -- 2.50.1