Skip to content

Commit d245bcf

Browse files
Amanieutstellar
authored andcommitted
[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 54b909d)
1 parent 0372676 commit d245bcf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

llvm/lib/IR/Mangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
144144

145145
// Mangle functions with Microsoft calling conventions specially. Only do
146146
// this mangling for x86_64 vectorcall and 32-bit x86.
147-
const Function *MSFunc = dyn_cast<Function>(GV);
147+
const Function *MSFunc = dyn_cast_or_null<Function>(GV->getAliaseeObject());
148148

149149
// Don't add byte count suffixes when '\01' or '?' are in the first
150150
// character.

llvm/test/CodeGen/X86/fastcall-correct-mangling.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ define private x86_fastcallcc void @dontCrash() {
3131
; CHECK64-LABEL: {{^}}.LdontCrash:
3232
ret void
3333
}
34+
35+
@alias = alias void(i64, i8, i8, i16), void(i64, i8, i8, i16)* @func
36+
; CHECK32-LABEL: {{^}}.set @alias@20, @func@20
37+
; CHECK64-LABEL: {{^}}.set alias, func

0 commit comments

Comments
 (0)