Index: llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -28,6 +28,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/ADT/Twine.h" +#include "llvm/BinaryFormat/COFF.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFunction.h" @@ -109,12 +110,33 @@ AU.setPreservesAll(); } - bool runOnMachineFunction(MachineFunction &F) override { - AArch64FI = F.getInfo(); - STI = static_cast(&F.getSubtarget()); - bool Result = AsmPrinter::runOnMachineFunction(F); + bool runOnMachineFunction(MachineFunction &MF) override { + AArch64FI = MF.getInfo(); + STI = static_cast(&MF.getSubtarget()); + + SetupMachineFunction(MF); + + if (STI->isTargetCOFF()) { + bool Internal = MF.getFunction().hasInternalLinkage(); + COFF::SymbolStorageClass Scl = Internal ? COFF::IMAGE_SYM_CLASS_STATIC + : COFF::IMAGE_SYM_CLASS_EXTERNAL; + int Type = + COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT; + + OutStreamer->BeginCOFFSymbolDef(CurrentFnSym); + OutStreamer->EmitCOFFSymbolStorageClass(Scl); + OutStreamer->EmitCOFFSymbolType(Type); + OutStreamer->EndCOFFSymbolDef(); + } + + // Emit the rest of the function body. + EmitFunctionBody(); + + // Emit the XRay table for this function. emitXRayTable(); - return Result; + + // We didn't modify anything. + return false; } private: Index: llvm/trunk/test/MC/AArch64/coff-function-type-info.ll =================================================================== --- llvm/trunk/test/MC/AArch64/coff-function-type-info.ll +++ llvm/trunk/test/MC/AArch64/coff-function-type-info.ll @@ -0,0 +1,45 @@ +; RUN: llc -mtriple arm64-windows -filetype asm -o - %s \ +; RUN: | FileCheck %s -check-prefix CHECK-ASM + +; RUN: llc -mtriple arm64-windows -filetype obj -o - %s \ +; RUN: | llvm-readobj -t | FileCheck %s -check-prefix CHECK-OBJECT + +define arm_aapcs_vfpcc void @external() { +entry: + ret void +} + +; CHECK-ASM: .def external +; CHECK-ASM: .scl 2 +; CHECK-ASM: .type 32 +; CHECK-ASM: .endef +; CHECK-ASM: .globl external + +define internal arm_aapcs_vfpcc void @internal() { +entry: + ret void +} + +; CHECK-ASM: .def internal +; CHECK-ASM: .scl 3 +; CHECK-ASM: .type 32 +; CHECK-ASM: .endef +; CHECK-ASM-NOT: .globl internal + +; CHECK-OBJECT: Symbol { +; CHECK-OBJECT: Name: external +; CHECK-OBJECT: Section: .text +; CHECK-OBJECT: BaseType: Null +; CHECK-OBJECT: ComplexType: Function +; CHECK-OBJECT: StorageClass: External +; CHECK-OBJECT: AuxSymbolCount: 0 +; CHECK-OBJECT: } +; CHECK-OBJECT: Symbol { +; CHECK-OBJECT: Name: internal +; CHECK-OBJECT: Section: .text +; CHECK-OBJECT: BaseType: Null +; CHECK-OBJECT: ComplexType: Function +; CHECK-OBJECT: StorageClass: Static +; CHECK-OBJECT: AuxSymbolCount: 0 +; CHECK-OBJECT: } +