diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1647,8 +1647,18 @@ // Set the symbol type to function if the alias has a function type. // This affects codegen when the aliasee is not a function. - if (IsFunction) + if (IsFunction) { OutStreamer->emitSymbolAttribute(Name, MCSA_ELF_TypeFunction); + if (TM.getTargetTriple().isOSBinFormatCOFF()) { + OutStreamer->BeginCOFFSymbolDef(Name); + OutStreamer->EmitCOFFSymbolStorageClass( + GA.hasLocalLinkage() ? COFF::IMAGE_SYM_CLASS_STATIC + : COFF::IMAGE_SYM_CLASS_EXTERNAL); + OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION + << COFF::SCT_COMPLEX_TYPE_SHIFT); + OutStreamer->EndCOFFSymbolDef(); + } + } emitVisibility(Name, GA.getVisibility()); diff --git a/llvm/test/CodeGen/X86/coff-alias-type.ll b/llvm/test/CodeGen/X86/coff-alias-type.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/coff-alias-type.ll @@ -0,0 +1,24 @@ +; RUN: llc -mtriple=x86_64-windows-gnu -o - %s | FileCheck %s + +%struct.MyStruct = type { i8 } + +@_ZN8MyStructC1Ev = dso_local alias void (%struct.MyStruct*), void (%struct.MyStruct*)* @_ZN8MyStructC2Ev + +define dso_local void @_ZN8MyStructC2Ev(%struct.MyStruct* %this) { +entry: + ret void +} + +; CHECK: .def _ZN8MyStructC2Ev +; CHECK-NEXT: .scl 2 +; CHECK-NEXT: .type 32 +; CHECK-NEXT: .endef +; CHECK-NEXT: .globl _ZN8MyStructC2Ev +; CHECK: {{^}}_ZN8MyStructC2Ev: + +; CHECK: .globl _ZN8MyStructC1Ev +; CHECK-NEXT: .def _ZN8MyStructC1Ev +; CHECK-NEXT: .scl 2 +; CHECK-NEXT: .type 32 +; CHECK-NEXT: .endef +; CHECK-NEXT: .set _ZN8MyStructC1Ev, _ZN8MyStructC2Ev