]> granicus.if.org Git - llvm/commitdiff
Mips: Fix access to private functions.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 Jun 2016 03:19:40 +0000 (03:19 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 Jun 2016 03:19:40 +0000 (03:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273843 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MipsISelLowering.cpp
test/CodeGen/Mips/private-addr.ll [new file with mode: 0644]

index 0c43cc07634dcc44dc233729e2b5642a44bf340b..1e640e173791cf9aa2adaba89d883b71075706c9 100644 (file)
@@ -1764,7 +1764,7 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
     return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
   }
 
-  if (GV->hasInternalLinkage() || (GV->hasLocalLinkage() && !isa<Function>(GV)))
+  if (GV->hasLocalLinkage())
     return getAddrLocal(N, SDLoc(N), Ty, DAG, ABI.IsN32() || ABI.IsN64());
 
   if (LargeGOT)
diff --git a/test/CodeGen/Mips/private-addr.ll b/test/CodeGen/Mips/private-addr.ll
new file mode 100644 (file)
index 0000000..37dd6fe
--- /dev/null
@@ -0,0 +1,14 @@
+; RUN: llc -mtriple=mips-pc-linux -relocation-model=pic < %s | FileCheck %s
+
+define private void @bar() {
+  ret void
+}
+
+define void()* @foo() {
+; CHECK:      foo:
+; CHECK:      lw     $[[REG:.*]], %got($bar)($1)
+; CHECK-NEXT: jr     $ra
+; CHECK-NEXT: addiu  $2, $[[REG]], %lo($bar)
+
+  ret void()* @bar
+}