Skip to content

Commit f17e415

Browse files
authored
[AArch64] Mangle names of all ARM64EC functions with entry thunks (#80996)
This better matches MSVC output in cases where static functions have their addresses taken.
1 parent 3b7d433 commit f17e415

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ bool AArch64Arm64ECCallLowering::processFunction(
712712
// name (emitting the definition) can grab it from the metadata.
713713
//
714714
// FIXME: Handle functions with weak linkage?
715-
if (F.hasExternalLinkage() || F.hasWeakLinkage() || F.hasLinkOnceLinkage()) {
715+
if (!F.hasLocalLinkage() || F.hasAddressTaken()) {
716716
if (std::optional<std::string> MangledName =
717717
getArm64ECMangledFunctionName(F.getName().str())) {
718718
F.setMetadata("arm64ec_unmangled_name",

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ void AArch64AsmPrinter::emitFunctionEntryLabel() {
11211121
TS->emitDirectiveVariantPCS(CurrentFnSym);
11221122
}
11231123

1124-
if (TM.getTargetTriple().isWindowsArm64EC()) {
1124+
if (TM.getTargetTriple().isWindowsArm64EC() &&
1125+
!MF->getFunction().hasLocalLinkage()) {
11251126
// For ARM64EC targets, a function definition's name is mangled differently
11261127
// from the normal symbol. We emit the alias from the unmangled symbol to
11271128
// mangled symbol name here.

llvm/test/CodeGen/AArch64/arm64ec-entry-thunks-local-linkage.ll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
; Validates when local linkage functions get a thunk generated.
44

5-
; Being called does not cause a thunk to be generated.
5+
; Being called does not cause a thunk to be generated or the symbol name to be mangled.
6+
; CHECK-NOT: "#does_not_have_addr_taken":
67
; CHECK-NOT: $ientry_thunk$cdecl$v$f;
78
define internal void @does_not_have_addr_taken(float) nounwind {
89
ret void
@@ -12,7 +13,8 @@ define void @calls_does_not_have_addr_taken() nounwind {
1213
ret void
1314
}
1415

15-
; Having an address taken does cause a thunk to be generated.
16+
; Having an address taken does cause a thunk to be generated and the symbol name to be mangled.
17+
; CHECK: "#has_addr_taken":
1618
; CHECK: $ientry_thunk$cdecl$v$i8;
1719
define internal void @has_addr_taken(i64) nounwind {
1820
ret void

0 commit comments

Comments
 (0)