[PATCH] D128654: [MC] Allow annotating custom sections as zerofill

Egor Zhdan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 08:29:19 PDT 2022


egorzhdan created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
egorzhdan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is already possible for e.g. `cstring_literals`, but the entry for zerofill was unnamed.

rdar://90336380


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128654

Files:
  llvm/lib/MC/MCSectionMachO.cpp
  llvm/test/CodeGen/AArch64/clang-section-macho.ll


Index: llvm/test/CodeGen/AArch64/clang-section-macho.ll
===================================================================
--- llvm/test/CodeGen/AArch64/clang-section-macho.ll
+++ llvm/test/CodeGen/AArch64/clang-section-macho.ll
@@ -9,3 +9,14 @@
 
 ; CHECK:      .section	__TEXT,__mytext
 ; CHECK-NEXT: .globl	_foo
+
+
+define dso_local void @bar() #1 {
+entry:
+  ret void
+}
+
+attributes #1 = { "implicit-section-name"="__EDATA,zerofill" }
+
+; CHECK:      .section	__EDATA,zerofill
+; CHECK-NEXT: .globl	_bar
Index: llvm/lib/MC/MCSectionMachO.cpp
===================================================================
--- llvm/lib/MC/MCSectionMachO.cpp
+++ llvm/lib/MC/MCSectionMachO.cpp
@@ -26,7 +26,7 @@
   StringLiteral AssemblerName, EnumName;
 } SectionTypeDescriptors[MachO::LAST_KNOWN_SECTION_TYPE + 1] = {
     {StringLiteral("regular"), StringLiteral("S_REGULAR")}, // 0x00
-    {StringLiteral(""), StringLiteral("S_ZEROFILL")},       // 0x01
+    {StringLiteral("zerofill"), StringLiteral("S_ZEROFILL")}, // 0x01
     {StringLiteral("cstring_literals"),
      StringLiteral("S_CSTRING_LITERALS")}, // 0x02
     {StringLiteral("4byte_literals"),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128654.440239.patch
Type: text/x-patch
Size: 1157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220627/8383b6ae/attachment.bin>


More information about the llvm-commits mailing list