[llvm] r271290 - Add a use of shouldAssumeDSOLocal to ARM.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue May 31 08:31:56 PDT 2016


Author: rafael
Date: Tue May 31 10:31:55 2016
New Revision: 271290

URL: http://llvm.org/viewvc/llvm-project?rev=271290&view=rev
Log:
Add a use of shouldAssumeDSOLocal to ARM.

Now this code path knows about position independent executables.

Added:
    llvm/trunk/test/CodeGen/ARM/pie.ll
Modified:
    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=271290&r1=271289&r2=271290&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue May 31 10:31:55 2016
@@ -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::LowerGlobalAd
   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>();

Added: llvm/trunk/test/CodeGen/ARM/pie.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/pie.ll?rev=271290&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/pie.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/pie.ll Tue May 31 10:31:55 2016
@@ -0,0 +1,18 @@
+; RUN: llc  -mtriple=armv7-pc-linux-gnueabi -relocation-model=pic < %s | FileCheck %s
+
+ at 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}




More information about the llvm-commits mailing list