[llvm] [llvm][aarch64] Fix Arm64EC name mangling algorithm (PR #115567)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 10 18:32:17 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`.
----------------
efriedma-quic wrote:
I'm not confident this actually works. Consider, for example:
```
template<typename T> struct WW { struct Z{}; };
template <typename X> struct Wrapper {
int GetValue(typename WW<X>::Z) const;
};
struct A {
};
template<typename X> int Wrapper<X>::GetValue(typename WW<X>::Z) const { return 3; }
template class Wrapper<A>;
```
If we can't figure out a simple way to figure out the correct insertion point, it might end up being simpler to just compute the name in clang, using the real name mangler, and attach it using metadata, or something like that.
https://github.com/llvm/llvm-project/pull/115567
More information about the llvm-commits
mailing list