[llvm] [llvm][aarch64] Fix Arm64EC name mangling algorithm (PR #115567)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 10:07:40 PST 2024
================
@@ -302,14 +302,23 @@ std::optional<std::string> llvm::getArm64ECMangledFunctionName(StringRef Name) {
// Insert the ARM64EC "$$h" tag after the mangled function name.
if (Name.contains("$$h"))
return std::nullopt;
- size_t InsertIdx = Name.find("@@");
- size_t ThreeAtSignsIdx = Name.find("@@@");
- if (InsertIdx != std::string::npos && InsertIdx != ThreeAtSignsIdx) {
+
+ // The last 4 characters of the symbol type may contain a `@@` if the symbol
+ // is returning a qualified type. We don't want to insert `$$h` at that point.
+ auto TrimmedName = Name.drop_back(4);
+
+ // The last `@@` is the separation between the qualified name of the symbol
+ // and its type, which is where we want to insert `$$h`.
----------------
dpaoliello wrote:
MSVC generates the mangled name in the frontend, and that's certainly the most robust choice.
Unfortunately, LLD and import library generation have both taken a dependency on this function so we'd have to detangle that first.
The other option is to use a name demangler to parse the mangled name instead of this adhoc from-the-back parsing.
https://github.com/llvm/llvm-project/pull/115567
More information about the llvm-commits
mailing list