OSDN Git Service

Use shouldAssumeDSOLocal.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Jun 2016 17:45:33 +0000 (17:45 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Jun 2016 17:45:33 +0000 (17:45 +0000)
With this ARM fast isel knows that PIE variable are not preemptable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273169 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMFastISel.cpp
test/CodeGen/ARM/fast-isel-pie.ll [new file with mode: 0644]

index 01a5997..cbd96a7 100644 (file)
@@ -2967,8 +2967,10 @@ bool ARMFastISel::tryToFoldLoadIntoMI(MachineInstr *MI, unsigned OpNo,
 
 unsigned ARMFastISel::ARMLowerPICELF(const GlobalValue *GV,
                                      unsigned Align, MVT VT) {
+  Reloc::Model RM = TM.getRelocationModel();
+  const Triple &TargetTriple = TM.getTargetTriple();
   bool UseGOT_PREL =
-      !(GV->hasHiddenVisibility() || GV->hasLocalLinkage());
+      !shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV);
 
   LLVMContext *Context = &MF->getFunction()->getContext();
   unsigned ARMPCLabelIndex = AFI->createPICLabelUId();
diff --git a/test/CodeGen/ARM/fast-isel-pie.ll b/test/CodeGen/ARM/fast-isel-pie.ll
new file mode 100644 (file)
index 0000000..23a88bd
--- /dev/null
@@ -0,0 +1,19 @@
+; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=pic -mtriple=armv7-pc-linux-gnueabi | FileCheck %s
+
+@var = global i32 42
+
+define i32* @foo() {
+; CHECK:      foo:
+; CHECK:      ldr     r0, .L[[POOL:.*]]
+; CHECK-NEXT: .L[[ADDR:.*]]:
+; CHECK-NEXT: add     r0, pc, r0
+; CHECK-NEXT: bx      lr
+
+; CHECK:      .L[[POOL]]:
+; CHECK-NEXT: .long   var-(.L[[ADDR]]+8)
+
+  ret i32* @var
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"PIE Level", i32 2}