Add a use of shouldAssumeDSOLocal to ARM.

Now this code path knows about position independent executables.

llvm-svn: 271290
This commit is contained in:
Rafael Espindola 2016-05-31 15:31:55 +00:00
parent e93a73fb7a
commit 7ad97b2fe4
2 changed files with 24 additions and 2 deletions

View File

@ -24,6 +24,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
@ -2792,9 +2793,12 @@ SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op,
EVT PtrVT = getPointerTy(DAG.getDataLayout());
SDLoc dl(Op);
const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
if (getTargetMachine().getRelocationModel() == Reloc::PIC_) {
const TargetMachine &TM = getTargetMachine();
Reloc::Model RM = TM.getRelocationModel();
const Triple &TargetTriple = TM.getTargetTriple();
if (RM == Reloc::PIC_) {
bool UseGOT_PREL =
!(GV->hasHiddenVisibility() || GV->hasLocalLinkage());
!shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV);
MachineFunction &MF = DAG.getMachineFunction();
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();

View File

@ -0,0 +1,18 @@
; RUN: llc -mtriple=armv7-pc-linux-gnueabi -relocation-model=pic < %s | FileCheck %s
@foo = global i32 42
define i32* @get_foo() {
ret i32* @foo
}
; Test that we only use one load. Even that is only needed because there
; doesn't seem to be pc relative relocations for movw movt.
; CHECK: ldr r0, .LCPI0_0
; CHECK-NEXT: .L{{.*}}:
; CHECK-NEXT: add r0, pc, r0
; CHECK-NEXT: bx lr
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIE Level", i32 2}