Skip to content

Commit

Permalink
[Mangler] Mangle aliases to fastcall/vectorcall functions correctly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Amanieu committed Feb 25, 2022
1 parent 1e8c9e7 commit 54b909d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/IR/Mangler.cpp
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/X86/fastcall-correct-mangling.ll
Expand Up @@ -31,3 +31,7 @@ define private x86_fastcallcc void @dontCrash() {
; CHECK64-LABEL: {{^}}.LdontCrash:
ret void
}

@alias = alias void(i64, i8, i8, i16), void(i64, i8, i8, i16)* @func
; CHECK32-LABEL: {{^}}.set @alias@20, @func@20
; CHECK64-LABEL: {{^}}.set alias, func

0 comments on commit 54b909d

Please sign in to comment.