[PATCH] D118328: [CodeGen] Emit COFF symbol type for function aliases
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 28 03:06:54 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7d2afbac904: [CodeGen] Emit COFF symbol type for function aliases (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118328/new/
https://reviews.llvm.org/D118328
Files:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/test/CodeGen/X86/coff-alias-type.ll
Index: llvm/test/CodeGen/X86/coff-alias-type.ll
===================================================================
--- /dev/null
+++ 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 }
+
+ at _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
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ 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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118328.403947.patch
Type: text/x-patch
Size: 1907 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220128/3a8f720c/attachment.bin>
More information about the llvm-commits
mailing list