[llvm-branch-commits] [llvm] d245bcf - [Mangler] Mangle aliases to fastcall/vectorcall functions correctly

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 1 14:24:24 PST 2022


Author: Amanieu d'Antras
Date: 2022-03-01T14:20:23-08:00
New Revision: d245bcf536a36430a0354bd90a7ef00c39ccbcb1

URL: https://github.com/llvm/llvm-project/commit/d245bcf536a36430a0354bd90a7ef00c39ccbcb1
DIFF: https://github.com/llvm/llvm-project/commit/d245bcf536a36430a0354bd90a7ef00c39ccbcb1.diff

LOG: [Mangler] Mangle aliases to fastcall/vectorcall functions correctly

These aliases are produced by MergeFunctions and need to be mangled according to the calling convention of the function they are pointing to instead of defaulting to the C calling convention.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D120382

(cherry picked from commit 54b909de682bfa4e3389b680b0916ab18c99952a)

Added: 
    

Modified: 
    llvm/lib/IR/Mangler.cpp
    llvm/test/CodeGen/X86/fastcall-correct-mangling.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Mangler.cpp b/llvm/lib/IR/Mangler.cpp
index 2399ea27ee9d4..b8e3e40e4c1d5 100644
--- a/llvm/lib/IR/Mangler.cpp
+++ b/llvm/lib/IR/Mangler.cpp
@@ -144,7 +144,7 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
 
   // Mangle functions with Microsoft calling conventions specially.  Only do
   // this mangling for x86_64 vectorcall and 32-bit x86.
-  const Function *MSFunc = dyn_cast<Function>(GV);
+  const Function *MSFunc = dyn_cast_or_null<Function>(GV->getAliaseeObject());
 
   // Don't add byte count suffixes when '\01' or '?' are in the first
   // character.

diff  --git a/llvm/test/CodeGen/X86/fastcall-correct-mangling.ll b/llvm/test/CodeGen/X86/fastcall-correct-mangling.ll
index 00dc44e75e8f5..dd8ce0f0ef505 100644
--- a/llvm/test/CodeGen/X86/fastcall-correct-mangling.ll
+++ b/llvm/test/CodeGen/X86/fastcall-correct-mangling.ll
@@ -31,3 +31,7 @@ define private x86_fastcallcc void @dontCrash() {
 ; CHECK64-LABEL: {{^}}.LdontCrash:
   ret void
 }
+
+ at alias = alias void(i64, i8, i8, i16), void(i64, i8, i8, i16)* @func
+; CHECK32-LABEL: {{^}}.set @alias at 20, @func at 20
+; CHECK64-LABEL: {{^}}.set alias, func


        


More information about the llvm-branch-commits mailing list