[llvm] [Mips][FastISel] Also add low part when materializing private functions (PR #229717)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 03:32:03 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-mips
Author: Alex Rønne Petersen (alexrp)
<details>
<summary>Changes</summary>
I have no idea why the code was explicitly written to exclude private functions; it seems obviously incorrect to me.
---
Full diff: https://github.com/llvm/llvm-project/pull/229717.diff
2 Files Affected:
- (modified) llvm/lib/Target/Mips/MipsFastISel.cpp (+1-2)
- (added) llvm/test/CodeGen/Mips/Fast-ISel/private-fn.ll (+21)
``````````diff
diff --git a/llvm/lib/Target/Mips/MipsFastISel.cpp b/llvm/lib/Target/Mips/MipsFastISel.cpp
index 20d1251b0919d..e223d453f771b 100644
--- a/llvm/lib/Target/Mips/MipsFastISel.cpp
+++ b/llvm/lib/Target/Mips/MipsFastISel.cpp
@@ -418,8 +418,7 @@ unsigned MipsFastISel::materializeGV(const GlobalValue *GV, MVT VT) {
emitInst(Mips::LW, DestReg)
.addReg(MFI->getGlobalBaseReg(*MF))
.addGlobalAddress(GV, 0, MipsII::MO_GOT);
- if ((GV->hasInternalLinkage() ||
- (GV->hasLocalLinkage() && !isa<Function>(GV)))) {
+ if (GV->hasLocalLinkage()) {
Register TempReg = createResultReg(RC);
emitInst(Mips::ADDiu, TempReg)
.addReg(DestReg)
diff --git a/llvm/test/CodeGen/Mips/Fast-ISel/private-fn.ll b/llvm/test/CodeGen/Mips/Fast-ISel/private-fn.ll
new file mode 100644
index 0000000000000..589deeb7ef0e3
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/Fast-ISel/private-fn.ll
@@ -0,0 +1,21 @@
+; RUN: llc -mtriple=mipsel -relocation-model=pic -O0 -fast-isel-abort=3 < %s | FileCheck %s
+
+define private void @priv() {
+ ret void
+}
+
+define ptr @addr() {
+; CHECK-LABEL: addr:
+; CHECK: lw $[[R:[0-9]+]], %got($priv)(${{[0-9]+}})
+; CHECK-NEXT: addiu ${{[0-9]+}}, $[[R]], %lo($priv)
+ ret ptr @priv
+}
+
+define void @call() {
+; CHECK-LABEL: call:
+; CHECK: lw $[[R:[0-9]+]], %got($priv)(${{[0-9]+}})
+; CHECK-NEXT: addiu $25, $[[R]], %lo($priv)
+; CHECK-NEXT: .reloc {{.*}}, R_MIPS_JALR, priv
+ call void @priv()
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/229717
More information about the llvm-commits
mailing list