Skip to content

[AArch64] Add MSVC-style mangling for SVE types. #141887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

efriedma-quic
Copy link
Collaborator

No released version of MSVC supports these types, so make up a mangling that's unlikely to conflict, for now.

No released version of MSVC supports these types, so make up a mangling
that's unlikely to conflict, for now.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels May 29, 2025
@llvmbot
Copy link
Member

llvmbot commented May 29, 2025

@llvm/pr-subscribers-clang

Author: Eli Friedman (efriedma-quic)

Changes

No released version of MSVC supports these types, so make up a mangling that's unlikely to conflict, for now.


Full diff: https://github.com/llvm/llvm-project/pull/141887.diff

2 Files Affected:

  • (modified) clang/lib/AST/MicrosoftMangle.cpp (+7)
  • (modified) clang/test/CodeGenCXX/aarch64-mangle-sve-vectors-msvc.cpp (+9-3)
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 290521a9bd531..d6339029a65c9 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -2828,6 +2828,13 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers,
     break;
 #include "clang/Basic/HLSLIntangibleTypes.def"
 
+#define SVE_TYPE(Name, Id, SingletonId)                                        \
+  case BuiltinType::Id:                                                        \
+    mangleArtificialTagType(TagTypeKind::Struct, #Name, {"__clang"});          \
+    break;
+#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits)
+#include "clang/Basic/AArch64ACLETypes.def"
+
     // Issue an error for any type not explicitly handled.
   default:
     Error(Range.getBegin(), "built-in type: ",
diff --git a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors-msvc.cpp b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors-msvc.cpp
index 435feec774ece..3ed75b9494c2a 100644
--- a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors-msvc.cpp
+++ b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors-msvc.cpp
@@ -1,7 +1,13 @@
-// RUN: not %clang_cc1 -triple aarch64-unknown-windows-msvc %s -emit-llvm \
-// RUN:   -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc %s -emit-llvm \
+// RUN:   -o - | FileCheck %s
 
 template<typename T> struct S {};
 
-// CHECK: cannot mangle this built-in type: __SVInt8_t yet
+// CHECK: void @"?f1@@YAXU?$S@U__SVInt8_t@__clang@@@@@Z"
 void f1(S<__SVInt8_t>) {}
+// CHECK: void @"?f2@@YAXU?$S@U__SVInt32_t@__clang@@@@@Z"
+void f2(S<__SVInt32_t>) {}
+// CHECK: void @"?f3@@YAXU?$S@U__SVBool_t@__clang@@@@@Z"
+void f3(S<__SVBool_t>) {}
+// CHECK: void @"?f4@@YAXU?$S@U__clang_svfloat64x4_t@__clang@@@@@Z"
+void f4(S<__clang_svfloat64x4_t>) {}

@efriedma-quic
Copy link
Collaborator Author

Ping

Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@efriedma-quic efriedma-quic merged commit 12f8bf3 into llvm:main Jun 3, 2025
14 checks passed
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
No released version of MSVC supports these types, so make up a mangling
that's unlikely to conflict, for now.
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
No released version of MSVC supports these types, so make up a mangling
that's unlikely to conflict, for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants