[llvm] [COFF][Mips] Set PrivateGlobalPrefix to .L (PR #140033)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 02:51:51 PDT 2025
https://github.com/yingopq created https://github.com/llvm/llvm-project/pull/140033
When calling external functions which start with `L`, would generate error: assembler label 'LeaveFoo' can not be undefined. This pr would fix this issue.
Fix #134914.
>From dc21810a1d36c269bfef30d5562b39c6ffb04de7 Mon Sep 17 00:00:00 2001
From: Ying Huang <ying.huang at oss.cipunited.com>
Date: Thu, 15 May 2025 05:43:12 -0400
Subject: [PATCH] [COFF][Mips] Set PrivateGlobalPrefix to .L
When calling external functions which start with `L`, would generate
error: assembler label 'LeaveFoo' can not be undefined.
This pr would fix this issue.
Fix #134914.
---
.../Mips/MCTargetDesc/MipsMCAsmInfo.cpp | 2 ++
.../CodeGen/Mips/private-global-prefix.ll | 24 +++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 llvm/test/CodeGen/Mips/private-global-prefix.ll
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
index 59c5bcb89bede..11df6fecaf37b 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
@@ -53,5 +53,7 @@ MipsCOFFMCAsmInfo::MipsCOFFMCAsmInfo() {
ExceptionsType = ExceptionHandling::WinEH;
+ PrivateGlobalPrefix = ".L";
+ PrivateLabelPrefix = ".L";
AllowAtInName = true;
}
diff --git a/llvm/test/CodeGen/Mips/private-global-prefix.ll b/llvm/test/CodeGen/Mips/private-global-prefix.ll
new file mode 100644
index 0000000000000..e60b9c1d7eba5
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/private-global-prefix.ll
@@ -0,0 +1,24 @@
+; RUN: llc -mtriple=mipsel-w64-windows-gnu < %s | FileCheck %s -check-prefix=MIPSEL
+
+define void @f() {
+; MIPSEL-LABEL: f:
+; MIPSEL: # %bb.0: # %entry
+; MIPSEL-NEXT: addiu $sp, $sp, -24
+; MIPSEL-NEXT: sw $ra, 20($sp)
+; MIPSEL-NEXT: jal LeaveFoo
+; MIPSEL-NEXT: nop
+; MIPSEL-NEXT: jal LocalBar
+; MIPSEL-NEXT: nop
+; MIPSEL-NEXT: lw $ra, 20($sp)
+; MIPSEL-NEXT: jr $ra
+; MIPSEL-NEXT: addiu $sp, $sp, 24
+
+entry:
+ call void @LeaveFoo()
+ call void @LocalBar()
+ ret void
+}
+
+declare void @LeaveFoo()
+declare void @LocalBar()
+
More information about the llvm-commits
mailing list