[llvm] be4b40d - [MC] Allow annotating custom sections as zerofill

Egor Zhdan via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 28 07:10:08 PDT 2022


Author: Egor Zhdan
Date: 2022-06-28T15:08:47+01:00
New Revision: be4b40d5bc6c1449090ff102e5f23254fd535cd4

URL: https://github.com/llvm/llvm-project/commit/be4b40d5bc6c1449090ff102e5f23254fd535cd4
DIFF: https://github.com/llvm/llvm-project/commit/be4b40d5bc6c1449090ff102e5f23254fd535cd4.diff

LOG: [MC] Allow annotating custom sections as zerofill

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

rdar://90336380

Differential Revision: https://reviews.llvm.org/D128654

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCSectionMachO.cpp b/llvm/lib/MC/MCSectionMachO.cpp
index 0c97089737501..1c210fb0f4c87 100644
--- a/llvm/lib/MC/MCSectionMachO.cpp
+++ b/llvm/lib/MC/MCSectionMachO.cpp
@@ -26,7 +26,7 @@ static constexpr struct {
   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"),

diff  --git a/llvm/test/CodeGen/AArch64/clang-section-macho.ll b/llvm/test/CodeGen/AArch64/clang-section-macho.ll
index 1c23f4c0a1443..406c584af62a9 100644
--- a/llvm/test/CodeGen/AArch64/clang-section-macho.ll
+++ b/llvm/test/CodeGen/AArch64/clang-section-macho.ll
@@ -9,3 +9,14 @@ attributes #0 = { "implicit-section-name"="__TEXT,__mytext" }
 
 ; 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


        


More information about the llvm-commits mailing list