[PATCH] D158122: [MC][COFF][AArch64] Fix the storage class for private linkage symbols.

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 14:45:51 PDT 2023


hjyamauchi created this revision.
hjyamauchi added a reviewer: compnerd.
Herald added subscribers: pengfei, hiraditya, kristof.beyls.
Herald added a project: All.
hjyamauchi requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Use IMAGE_SYM_CLASS_STATIC like X86.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158122

Files:
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/test/MC/COFF/local-sym-storage-class.ll


Index: llvm/test/MC/COFF/local-sym-storage-class.ll
===================================================================
--- /dev/null
+++ llvm/test/MC/COFF/local-sym-storage-class.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple aarch64-unknown-windows-msvc -filetype=asm %s -o - | FileCheck %s
+; RUN: llc -mtriple x86_64-unknown-windows-msvc -filetype=asm %s -o - | FileCheck %s
+
+define void @main() {
+  call void @internal()
+  call void @private()
+  ret void
+}
+
+define internal void @internal() {
+  ret void
+}
+
+define private void @private() {
+  ret void
+}
+
+; Check that the internal and private linkage symbols have IMAGE_SYM_CLASS_STATIC (3).
+; CHECK: .def    internal;
+; CHECK: .scl    3;
+; CHECK: .def    .Lprivate;
+; CHECK: .scl    3;
Index: llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -138,9 +138,9 @@
     SetupMachineFunction(MF);
 
     if (STI->isTargetCOFF()) {
-      bool Internal = MF.getFunction().hasInternalLinkage();
-      COFF::SymbolStorageClass Scl = Internal ? COFF::IMAGE_SYM_CLASS_STATIC
-                                              : COFF::IMAGE_SYM_CLASS_EXTERNAL;
+      bool Local = MF.getFunction().hasLocalLinkage();
+      COFF::SymbolStorageClass Scl = Local ? COFF::IMAGE_SYM_CLASS_STATIC
+                                           : COFF::IMAGE_SYM_CLASS_EXTERNAL;
       int Type =
         COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158122.550896.patch
Type: text/x-patch
Size: 1584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/928119a3/attachment.bin>


More information about the llvm-commits mailing list