Skip to content

[MC,ELF] .section: unconditionally print section flag 'G' after 'o' #77422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented Jan 9, 2024

  • Placing 'G' before 'M' (SHF_MERGE) can be misleading as the sh_entsize
    argument goes before the section group name, if a reader doesn't know
    that the order of extra arguments is not affected by the order of flags.
  • 'a', 'w', and 'x' indicate basic permission-related flags. Separating
    them with 'G' is kinda ugly.

Simplify code and move 'G' after 'o'. The new output is more similar to
GCC.

@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2024

@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-mc
@llvm/pr-subscribers-backend-loongarch
@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-llvm-binary-utilities

Author: Fangrui Song (MaskRay)

Changes
  • [MC] Parse SHF_LINK_ORDER argument before section group name
  • [MC,ELF] .section: unconditionally print section flag 'G' after 'o'

Patch is 26.35 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/77422.diff

30 Files Affected:

  • (modified) llvm/lib/MC/MCParser/ELFAsmParser.cpp (+3-3)
  • (modified) llvm/lib/MC/MCSectionELF.cpp (+9-9)
  • (modified) llvm/test/CodeGen/AArch64/patchable-function-entry.ll (+2-2)
  • (modified) llvm/test/CodeGen/LoongArch/patchable-function-entry.ll (+1-1)
  • (modified) llvm/test/CodeGen/Mips/ehframe-indirect.ll (+1-1)
  • (modified) llvm/test/CodeGen/Mips/xray-section-group.ll (+1-1)
  • (modified) llvm/test/CodeGen/PowerPC/ppc32-pic-large.ll (+2-2)
  • (modified) llvm/test/CodeGen/RISCV/patchable-function-entry.ll (+1-1)
  • (modified) llvm/test/CodeGen/SPARC/constructor.ll (+2-2)
  • (modified) llvm/test/CodeGen/X86/basic-block-sections-labels-functions-sections.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/constructor.ll (+6-6)
  • (modified) llvm/test/CodeGen/X86/elf-comdat.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/elf-comdat2.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/elf-group.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/explicit-section-mergeable.ll (+9-9)
  • (modified) llvm/test/CodeGen/X86/gcc_except_table-multi.ll (+2-2)
  • (modified) llvm/test/CodeGen/X86/global-sections-comdat.ll (+3-3)
  • (modified) llvm/test/CodeGen/X86/patchable-function-entry.ll (+2-2)
  • (modified) llvm/test/CodeGen/X86/stack-size-section-function-sections.ll (+2-2)
  • (modified) llvm/test/CodeGen/X86/stack-size-section.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/xray-section-group.ll (+1-1)
  • (modified) llvm/test/DebugInfo/SystemZ/eh_frame_personality.ll (+1-1)
  • (modified) llvm/test/DebugInfo/SystemZ/eh_frame_personality.s (+1-1)
  • (modified) llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_basic.s (+1-1)
  • (modified) llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_large_static_personality_encodings.s (+1-1)
  • (modified) llvm/test/MC/ELF/alias-to-local.s (+1-1)
  • (modified) llvm/test/MC/ELF/relocation.s (+1-1)
  • (modified) llvm/test/MC/ELF/section-combine.s (+3-3)
  • (modified) llvm/test/MC/ELF/section.s (+16)
  • (modified) llvm/test/tools/llvm-symbolizer/frame.s (+1-1)
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 93e1d2f44b8c56..d4c4bcb8564889 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -616,12 +616,12 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
     if (Mergeable)
       if (parseMergeSize(Size))
         return true;
-    if (Group)
-      if (parseGroup(GroupName, IsComdat))
-        return true;
     if (Flags & ELF::SHF_LINK_ORDER)
       if (parseLinkedToSym(LinkedToSym))
         return true;
+    if (Group)
+      if (parseGroup(GroupName, IsComdat))
+        return true;
     if (maybeParseUniqueID(UniqueID))
       return true;
   }
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index 95fdf33522076e..b1efb839ba75f6 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -90,8 +90,6 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
     OS << 'e';
   if (Flags & ELF::SHF_EXECINSTR)
     OS << 'x';
-  if (Flags & ELF::SHF_GROUP)
-    OS << 'G';
   if (Flags & ELF::SHF_WRITE)
     OS << 'w';
   if (Flags & ELF::SHF_MERGE)
@@ -102,6 +100,8 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
     OS << 'T';
   if (Flags & ELF::SHF_LINK_ORDER)
     OS << 'o';
+  if (Flags & ELF::SHF_GROUP)
+    OS << 'G';
   if (Flags & ELF::SHF_GNU_RETAIN)
     OS << 'R';
 
@@ -183,13 +183,6 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
     OS << "," << EntrySize;
   }
 
-  if (Flags & ELF::SHF_GROUP) {
-    OS << ",";
-    printName(OS, Group.getPointer()->getName());
-    if (isComdat())
-      OS << ",comdat";
-  }
-
   if (Flags & ELF::SHF_LINK_ORDER) {
     OS << ",";
     if (LinkedToSym)
@@ -198,6 +191,13 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
       OS << '0';
   }
 
+  if (Flags & ELF::SHF_GROUP) {
+    OS << ",";
+    printName(OS, Group.getPointer()->getName());
+    if (isComdat())
+      OS << ",comdat";
+  }
+
   if (isUnique())
     OS << ",unique," << UniqueID;
 
diff --git a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
index 5750c1f601bdef..89a2e2bf4abbcf 100644
--- a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
+++ b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
@@ -48,7 +48,7 @@ define void @f3() "patchable-function-entry"="3" comdat {
 ; CHECK-NEXT: .Lfunc_begin3:
 ; CHECK-COUNT-3: nop
 ; CHECK-NEXT:  ret
-; CHECK:       .section __patchable_function_entries,"aGwo",@progbits,f3,comdat,f3{{$}}
+; CHECK:       .section __patchable_function_entries,"awoG",@progbits,f3,f3,comdat{{$}}
 ; CHECK-NEXT:  .p2align 3
 ; CHECK-NEXT:  .xword .Lfunc_begin3
   ret void
@@ -60,7 +60,7 @@ define void @f5() "patchable-function-entry"="5" comdat {
 ; CHECK-NEXT: .Lfunc_begin4:
 ; CHECK-COUNT-5: nop
 ; CHECK-NEXT:  sub sp, sp, #16
-; CHECK:       .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; CHECK:       .section __patchable_function_entries,"awoG",@progbits,f5,f5,comdat{{$}}
 ; CHECK:       .p2align 3
 ; CHECK-NEXT:  .xword .Lfunc_begin4
   %frame = alloca i8, i32 16
diff --git a/llvm/test/CodeGen/LoongArch/patchable-function-entry.ll b/llvm/test/CodeGen/LoongArch/patchable-function-entry.ll
index aaa3fda1ae7769..2e390d1e2c33af 100644
--- a/llvm/test/CodeGen/LoongArch/patchable-function-entry.ll
+++ b/llvm/test/CodeGen/LoongArch/patchable-function-entry.ll
@@ -31,7 +31,7 @@ define void @f5() "patchable-function-entry"="5" comdat {
 ; CHECK-NEXT:    .Lfunc_begin2:
 ; CHECK-COUNT-5:   nop
 ; CHECK-NEXT:      ret
-; CHECK:         .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; CHECK:         .section __patchable_function_entries,"awoG",@progbits,f5,f5,comdat{{$}}
 ; LA32:          .p2align 2
 ; LA32-NEXT:     .word .Lfunc_begin2
 ; LA64:          .p2align 3
diff --git a/llvm/test/CodeGen/Mips/ehframe-indirect.ll b/llvm/test/CodeGen/Mips/ehframe-indirect.ll
index b3f4b48329d7bc..e36fa2f9ce423d 100644
--- a/llvm/test/CodeGen/Mips/ehframe-indirect.ll
+++ b/llvm/test/CodeGen/Mips/ehframe-indirect.ll
@@ -62,7 +62,7 @@ declare void @foo()
 ; N64: .8byte _ZTISt9exception
 ; ALL: .hidden DW.ref.__gxx_personality_v0
 ; ALL: .weak DW.ref.__gxx_personality_v0
-; ALL: .section .data.DW.ref.__gxx_personality_v0,"aGw",@progbits,DW.ref.__gxx_personality_v0,comdat
+; ALL: .section .data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
 ; O32: .p2align 2
 ; N32: .p2align 2
 ; N64: .p2align 3
diff --git a/llvm/test/CodeGen/Mips/xray-section-group.ll b/llvm/test/CodeGen/Mips/xray-section-group.ll
index 5a208217092dd7..e9cd045d4411e1 100644
--- a/llvm/test/CodeGen/Mips/xray-section-group.ll
+++ b/llvm/test/CodeGen/Mips/xray-section-group.ll
@@ -24,7 +24,7 @@ $bar = comdat any
 define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-always" comdat($bar) {
 ; CHECK: .section .text.bar,"axG",@progbits,bar,comdat
   ret i32 1
-; CHECK: .section xray_instr_map,"aGo",@progbits,bar,comdat,bar{{$}}
+; CHECK: .section xray_instr_map,"aoG",@progbits,bar,bar,comdat{{$}}
 }
 
 ; CHECK-OBJ: Section {
diff --git a/llvm/test/CodeGen/PowerPC/ppc32-pic-large.ll b/llvm/test/CodeGen/PowerPC/ppc32-pic-large.ll
index 45aeb73b1a6ba9..025a5ad787fbe0 100644
--- a/llvm/test/CodeGen/PowerPC/ppc32-pic-large.ll
+++ b/llvm/test/CodeGen/PowerPC/ppc32-pic-large.ll
@@ -49,9 +49,9 @@ entry:
 ; LARGE-SECUREPLT:   addi 30, 30, .LTOC-.L0$pb@l
 ; LARGE-SECUREPLT:   bl call_foo@PLT+32768
 
-; LARGE:      .section .bss.bar1,"aGw",@nobits,bar1,comdat
+; LARGE:      .section .bss.bar1,"awG",@nobits,bar1,comdat
 ; LARGE:      bar1:
-; LARGE:      .section .bss.bar2,"aGw",@nobits,bar1,comdat
+; LARGE:      .section .bss.bar2,"awG",@nobits,bar1,comdat
 ; LARGE:      bar2:
 ; LARGE:      .section .got2,"aw",@progbits
 ; LARGE-NEXT: .p2align 2
diff --git a/llvm/test/CodeGen/RISCV/patchable-function-entry.ll b/llvm/test/CodeGen/RISCV/patchable-function-entry.ll
index 2804fdfc1ac9c5..4eeb1bf3138580 100644
--- a/llvm/test/CodeGen/RISCV/patchable-function-entry.ll
+++ b/llvm/test/CodeGen/RISCV/patchable-function-entry.ll
@@ -37,7 +37,7 @@ define void @f5() "patchable-function-entry"="5" comdat {
 ; NORVC-NEXT:    jalr zero, 0(ra)
 ; RVC-COUNT-5:   c.nop
 ; RVC-NEXT:      c.jr ra
-; CHECK:       .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; CHECK:       .section __patchable_function_entries,"awoG",@progbits,f5,f5,comdat{{$}}
 ; RV32:        .p2align 2
 ; RV32-NEXT:   .word .Lfunc_begin2
 ; RV64:        .p2align 3
diff --git a/llvm/test/CodeGen/SPARC/constructor.ll b/llvm/test/CodeGen/SPARC/constructor.ll
index e69ad26d09279a..dea152dd0f0892 100644
--- a/llvm/test/CodeGen/SPARC/constructor.ll
+++ b/llvm/test/CodeGen/SPARC/constructor.ll
@@ -17,11 +17,11 @@ entry:
 ; CTOR:      .section      .ctors,"aw"
 ; CTOR-NEXT: .p2align      2
 ; CTOR-NEXT: .word  f
-; CTOR-NEXT: .section      .ctors.65520,"aGw"
+; CTOR-NEXT: .section      .ctors.65520,"awG",@progbits,v,comdat{{$}}
 ; CTOR-NEXT: .p2align      2
 ; CTOR-NEXT: .word  g
 
-; INIT-ARRAY:    .section  .init_array.15,"aGw"
+; INIT-ARRAY:    .section  .init_array.15,"awG",@init_array,v,comdat{{$}}
 ; INIT-ARRAY-NEXT: .p2align  2
 ; INIT-ARRAY-NEXT: .word g
 ; INIT-ARRAY-NEXT: .section  .init_array,"aw"
diff --git a/llvm/test/CodeGen/X86/basic-block-sections-labels-functions-sections.ll b/llvm/test/CodeGen/X86/basic-block-sections-labels-functions-sections.ll
index b8217bbc00760f..3be3ab70f8a693 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-labels-functions-sections.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-labels-functions-sections.ll
@@ -35,7 +35,7 @@ define linkonce_odr dso_local i32 @_Z4fooTIiET_v() comdat {
 ; CHECK:		.section .text._Z4fooTIiET_v,"axG",@progbits,_Z4fooTIiET_v,comdat
 ; CHECK-LABEL:	_Z4fooTIiET_v:
 ; CHECK-NEXT:	[[FOOCOMDAT_BEGIN:.Lfunc_begin[0-9]+]]:
-; CHECK:		.section .llvm_bb_addr_map,"Go",@llvm_bb_addr_map,_Z4fooTIiET_v,comdat,.text._Z4fooTIiET_v{{$}}
+; CHECK:		.section .llvm_bb_addr_map,"oG",@llvm_bb_addr_map,.text._Z4fooTIiET_v,_Z4fooTIiET_v,comdat{{$}}
 ; CHECK-NEXT:		.byte 2				# version
 ; CHECK-NEXT:		.byte 0				# feature
 ; CHECK-NEXT:		.quad [[FOOCOMDAT_BEGIN]]	# function address
diff --git a/llvm/test/CodeGen/X86/constructor.ll b/llvm/test/CodeGen/X86/constructor.ll
index 0fea69b5a7bcb5..3133979b32f837 100644
--- a/llvm/test/CodeGen/X86/constructor.ll
+++ b/llvm/test/CodeGen/X86/constructor.ll
@@ -43,17 +43,17 @@ entry:
 ; CTOR-NEXT:	.quad	j
 ; CTOR-NEXT:	.quad	i
 ; CTOR-NEXT:	.quad	f
-; CTOR-NEXT:	.section	.ctors.09980,"aGw",@progbits,v,comdat
+; CTOR-NEXT:	.section	.ctors.09980,"awG",@progbits,v,comdat
 ; CTOR-NEXT:	.p2align	3
 ; CTOR-NEXT:	.quad	h
-; CTOR-NEXT:	.section	.ctors.65520,"aGw",@progbits,v,comdat
+; CTOR-NEXT:	.section	.ctors.65520,"awG",@progbits,v,comdat
 ; CTOR-NEXT:	.p2align	3
 ; CTOR-NEXT:	.quad	g
 
-; INIT-ARRAY:		.section	.init_array.15,"aGw",@init_array,v,comdat
+; INIT-ARRAY:		.section	.init_array.15,"awG",@init_array,v,comdat
 ; INIT-ARRAY-NEXT:	.p2align	3
 ; INIT-ARRAY-NEXT:	.quad	g
-; INIT-ARRAY-NEXT:	.section	.init_array.55555,"aGw",@init_array,v,comdat
+; INIT-ARRAY-NEXT:	.section	.init_array.55555,"awG",@init_array,v,comdat
 ; INIT-ARRAY-NEXT:	.p2align	3
 ; INIT-ARRAY-NEXT:	.quad	h
 ; INIT-ARRAY-NEXT:	.section	.init_array,"aw",@init_array
@@ -62,10 +62,10 @@ entry:
 ; INIT-ARRAY-NEXT:	.quad	i
 ; INIT-ARRAY-NEXT:	.quad	j
 
-; NACL:		.section	.init_array.15,"aGw",@init_array,v,comdat
+; NACL:		.section	.init_array.15,"awG",@init_array,v,comdat
 ; NACL-NEXT:	.p2align	2
 ; NACL-NEXT:	.long	g
-; NACL-NEXT:	.section	.init_array.55555,"aGw",@init_array,v,comdat
+; NACL-NEXT:	.section	.init_array.55555,"awG",@init_array,v,comdat
 ; NACL-NEXT:	.p2align	2
 ; NACL-NEXT:	.long	h
 ; NACL-NEXT:	.section	.init_array,"aw",@init_array
diff --git a/llvm/test/CodeGen/X86/elf-comdat.ll b/llvm/test/CodeGen/X86/elf-comdat.ll
index 35d8d6f2d2af9b..10770dd07409d0 100644
--- a/llvm/test/CodeGen/X86/elf-comdat.ll
+++ b/llvm/test/CodeGen/X86/elf-comdat.ll
@@ -7,5 +7,5 @@ define void @f() comdat($f) {
 }
 ; CHECK: .section        .text.f,"axG",@progbits,f,comdat
 ; CHECK: .globl  f
-; CHECK: .section        .bss.v,"aGw",@nobits,f,comdat
+; CHECK: .section        .bss.v,"awG",@nobits,f,comdat
 ; CHECK: .globl  v
diff --git a/llvm/test/CodeGen/X86/elf-comdat2.ll b/llvm/test/CodeGen/X86/elf-comdat2.ll
index 786cec78cc30f7..3e43c43b7d7419 100644
--- a/llvm/test/CodeGen/X86/elf-comdat2.ll
+++ b/llvm/test/CodeGen/X86/elf-comdat2.ll
@@ -5,7 +5,7 @@ $foo = comdat any
 @foo = global i32 42
 
 ; CHECK:      .type   bar,@object
-; CHECK-NEXT: .section        .data.bar,"aGw",@progbits,foo,comdat
+; CHECK-NEXT: .section        .data.bar,"awG",@progbits,foo,comdat
 ; CHECK-NEXT: .globl  bar
 ; CHECK:      .type   foo,@object
 ; CHECK-NEXT: .data
diff --git a/llvm/test/CodeGen/X86/elf-group.ll b/llvm/test/CodeGen/X86/elf-group.ll
index 3aaef0fa49da13..a69ba491be0ffb 100644
--- a/llvm/test/CodeGen/X86/elf-group.ll
+++ b/llvm/test/CodeGen/X86/elf-group.ll
@@ -4,7 +4,7 @@
 
 ; CHECK: .section .text.f1,"axG",@progbits,f1{{$}}
 ; CHECK: .section .text.f2,"axG",@progbits,f1{{$}}
-; CHECK: .section .bss.g1,"aGw",@nobits,f1{{$}}
+; CHECK: .section .bss.g1,"awG",@nobits,f1{{$}}
 
 $f1 = comdat nodeduplicate
 
diff --git a/llvm/test/CodeGen/X86/explicit-section-mergeable.ll b/llvm/test/CodeGen/X86/explicit-section-mergeable.ll
index 0a3a60474e1ed9..09995919d95594 100644
--- a/llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ b/llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -139,9 +139,9 @@
 !4 = !{ptr @implicit_rodata_cst4}
 
 ;; Test implicit section assignment for globals in distinct comdat groups.
-; CHECK: .section .rodata.cst4,"aGM",@progbits,4,f,comdat,unique,[[#U+7]]
+; CHECK: .section .rodata.cst4,"aMG",@progbits,4,f,comdat,unique,[[#U+7]]
 ; CHECK: implicit_rodata_cst4_comdat:
-; CHECK: .section .rodata.cst8,"aGM",@progbits,8,g,comdat,unique,[[#U+8]]
+; CHECK: .section .rodata.cst8,"aMG",@progbits,8,g,comdat,unique,[[#U+8]]
 ; CHECK: implicit_rodata_cst8_comdat:
 
 ;; Check that globals in distinct comdat groups that are explicitly assigned
@@ -153,11 +153,11 @@
 ;; are incorrect.
 ; CHECK: .section .explicit_comdat_distinct,"aM",@progbits,4,unique,[[#U+9]]
 ; CHECK: explicit_comdat_distinct_supply_uid:
-; CHECK: .section .explicit_comdat_distinct,"aGM",@progbits,4,f,comdat,unique,[[#U+10]]
+; CHECK: .section .explicit_comdat_distinct,"aMG",@progbits,4,f,comdat,unique,[[#U+10]]
 ; CHECK: explicit_comdat_distinct1:
-; CHECK: .section .explicit_comdat_distinct,"aGM",@progbits,4,g,comdat,unique,[[#U+10]]
+; CHECK: .section .explicit_comdat_distinct,"aMG",@progbits,4,g,comdat,unique,[[#U+10]]
 ; CHECK: explicit_comdat_distinct2:
-; CHECK: .section .explicit_comdat_distinct,"aGM",@progbits,8,h,comdat,unique,[[#U+11]]
+; CHECK: .section .explicit_comdat_distinct,"aMG",@progbits,8,h,comdat,unique,[[#U+11]]
 ; CHECK: explicit_comdat_distinct3:
 
 $f = comdat any
@@ -173,9 +173,9 @@ $h = comdat any
 @explicit_comdat_distinct3 = unnamed_addr constant [2 x i32] [i32 1, i32 1], section ".explicit_comdat_distinct", comdat($h)
 
 ;; Test implicit section assignment for globals in the same comdat group.
-; CHECK: .section .rodata.cst4,"aGM",@progbits,4,i,comdat,unique,[[#U+12]]
+; CHECK: .section .rodata.cst4,"aMG",@progbits,4,i,comdat,unique,[[#U+12]]
 ; CHECK: implicit_rodata_cst4_same_comdat:
-; CHECK: .section .rodata.cst8,"aGM",@progbits,8,i,comdat,unique,[[#U+13]]
+; CHECK: .section .rodata.cst8,"aMG",@progbits,8,i,comdat,unique,[[#U+13]]
 ; CHECK: implicit_rodata_cst8_same_comdat:
 
 ;; Check that globals in the same comdat group that are explicitly assigned
@@ -187,10 +187,10 @@ $h = comdat any
 ;; are incorrect.
 ; CHECK: .section .explicit_comdat_same,"aM",@progbits,4,unique,[[#U+14]]
 ; CHECK: explicit_comdat_same_supply_uid:
-; CHECK: .section .explicit_comdat_same,"aGM",@progbits,4,i,comdat,unique,[[#U+15]]
+; CHECK: .section .explicit_comdat_same,"aMG",@progbits,4,i,comdat,unique,[[#U+15]]
 ; CHECK: explicit_comdat_same1:
 ; CHECK: explicit_comdat_same2:
-; CHECK: .section .explicit_comdat_same,"aGM",@progbits,8,i,comdat,unique,[[#U+16]]
+; CHECK: .section .explicit_comdat_same,"aMG",@progbits,8,i,comdat,unique,[[#U+16]]
 ; CHECK: explicit_comdat_same3:
 
 $i = comdat any
diff --git a/llvm/test/CodeGen/X86/gcc_except_table-multi.ll b/llvm/test/CodeGen/X86/gcc_except_table-multi.ll
index 8da3ebfed2bdd7..1eb902ae90795d 100644
--- a/llvm/test/CodeGen/X86/gcc_except_table-multi.ll
+++ b/llvm/test/CodeGen/X86/gcc_except_table-multi.ll
@@ -17,7 +17,7 @@ define i32 @group() uwtable comdat personality ptr @__gxx_personality_v0 {
 ; CHECK:             .cfi_endproc
 ; NORMAL-NEXT:       .section .gcc_except_table.group,"aG",@progbits,group,comdat{{$}}
 ; SEP_BFD-NEXT:      .section .gcc_except_table.group,"aG",@progbits,group,comdat{{$}}
-; SEP-NEXT:          .section .gcc_except_table.group,"aGo",@progbits,group,comdat,group{{$}}
+; SEP-NEXT:          .section .gcc_except_table.group,"aoG",@progbits,group,group,comdat{{$}}
 ; SEP_NOUNIQUE-NEXT: .section .gcc_except_table,"aG",@progbits,group,comdat{{$}}
 ; NOUNIQUE-NEXT:     .section .gcc_except_table,"aG",@progbits,group,comdat{{$}}
 entry:
@@ -61,7 +61,7 @@ define i32 @zero() uwtable comdat personality ptr @__gxx_personality_v0 {
 ; CHECK:             .cfi_endproc
 ; NORMAL-NEXT:       .section .gcc_except_table.zero,"aG",@progbits,zero{{$}}
 ; SEP_BFD-NEXT:      .section .gcc_except_table.zero,"aG",@progbits,zero{{$}}
-; SEP-NEXT:          .section .gcc_except_table.zero,"aGo",@progbits,zero,zero{{$}}
+; SEP-NEXT:          .section .gcc_except_table.zero,"aoG",@progbits,zero,zero{{$}}
 ; SEP_NOUNIQUE-NEXT: .section .gcc_except_table,"aG",@progbits,zero{{$}}
 ; NOUNIQUE-NEXT:     .section .gcc_except_table,"aG",@progbits,zero{{$}}
 entry:
diff --git a/llvm/test/CodeGen/X86/global-sections-comdat.ll b/llvm/test/CodeGen/X86/global-sections-comdat.ll
index 730050dda5f30e..7b793815f238db 100644
--- a/llvm/test/CodeGen/X86/global-sections-comdat.ll
+++ b/llvm/test/CodeGen/X86/global-sections-comdat.ll
@@ -41,6 +41,6 @@ bb5:
 $G16 = comdat any
 @G16 = unnamed_addr constant i32 42, comdat
 
-; LINUX: .section	.rodata.cst4.G16,"aGM",@progbits,4,G16,comdat
-; LINUX-SECTIONS: .section	.rodata.cst4.G16,"aGM",@progbits,4,G16,comdat
-; LINUX-SECTIONS-SHORT: .section	.rodata.cst4,"aGM",@progbits,4,G16,comdat
+; LINUX: .section	.rodata.cst4.G16,"aMG",@progbits,4,G16,comdat
+; LINUX-SECTIONS: .section	.rodata.cst4.G16,"aMG",@progbits,4,G16,comdat
+; LINUX-SECTIONS-SHORT: .section	.rodata.cst4,"aMG",@progbits,4,G16,comdat
diff --git a/llvm/test/CodeGen/X86/patchable-function-entry.ll b/llvm/test/CodeGen/X86/patchable-function-entry.ll
index 124f5c57c74b5a..8c37f545108015 100644
--- a/llvm/test/CodeGen/X86/patchable-function-entry.ll
+++ b/llvm/test/CodeGen/X86/patchable-function-entry.ll
@@ -50,7 +50,7 @@ define void @f3() "patchable-function-entry"="3" comdat {
 ; 32-NEXT:     nop
 ; 64:          nopl (%rax)
 ; CHECK:       ret
-; CHECK:       .section __patchable_function_entries,"aGwo",@progbits,f3,comdat,f3{{$}}
+; CHECK:       .section __patchable_function_entries,"awoG",@progbits,f3,f3,comdat{{$}}
 ; 32:          .p2align 2
 ; 32-NEXT:     .long .Lfunc_begin3
 ; 64:          .p2align 3
@@ -66,7 +66,7 @@ define void @f5() "patchable-function-entry"="5" comdat {
 ; 32-NEXT:     nop
 ; 64:          nopl 8(%rax,%rax)
 ; CHECK-NEXT:  ret
-; CHECK:       .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; CHECK:       .section __patchable_function_entries,"awoG",@progbits,f5,f5,comdat{{$}}
 ; 32:          .p2align 2
 ; 32-NEXT:     .long .Lfunc_begin4
 ; 64:          .p2align 3
diff --git a/llvm/test/CodeGen/X86/stack-size-section-function-sections.ll b/llvm/test/CodeGen/X86/stack-size-section-function-sections.ll
index 92f312bd1185ce..b9606c081a90e0 100644
--- a/llvm/test/CodeGen/X86/stack-size-section-function-sections.ll
+++ b/llvm/test/CodeGen/X86/stack-size-section-function-sections.ll
@@ -15,9 +15,9 @@
 
 ; Check we add .stack_size section to a COMDAT group with the corresponding .text section if such a COMDAT exists.
 ; UNIQ:   .section        .text._Z4fooTIiET_v,"axG",@progbits,_Z4fooTIiET_v,comdat{{$}}
-; UNIQ:   .section        .stack_sizes,"Go",@progbits,_Z4fooTIiET_v,comdat,.text._Z4fooTIiET_v{{$}}
+; UNIQ:   .section        .stack_sizes,"oG",@progbits,.text._Z4fooTIiET_v,_Z4fooTIiET_v,comdat{{$}}
 ; NOUNIQ: .section        .text,"axG",@progbits,_Z4fooTIiET_v,comdat,unique,3
-; NOUNIQ: .section        .stack_sizes,"Go",@progbits,_Z4fooTIiET_v,comdat,.text,unique,3
+; NOUNIQ: .section        .stack_sizes,"oG",@progbits,.text,_Z4fooTIiET_v,comdat,unique,3
 
 $_Z4fooTIiET_v = comdat any
 
diff --git a/llvm/test/CodeGen/X86/stack-size-section.ll b/llvm/test/CodeGen/X86/stack-size-section.ll
index 3652ee845a7f34..866acbe140147e 100644
--- a/llvm/test/CodeGen/X86/stack-size-section.ll
+++ b/llvm/test/CodeGen/X86/stack-size-section.ll
@@ -29,7 +29,7 @@ define void @func2() #0 {
 
 ; Check that we still put .stack_sizes into the corresponding COMDAT group if any.
 ; CHECK: .section .text._Z4fooTIiET_v,"axG",@progbits,_Z4fooTIiET_v,comdat
-; GROUPS: .section .stack_sizes,"Go",@progbits,_Z4fooTIiET_v,comdat,.text._Z4fooTIiET_v{{$}}
+; GROUPS: .section .stack_sizes,"oG",@progbits,.text._Z4fooTIiET_v,_Z4fooTIiET_v,comdat{{$}}
 ; NOGROUPS: .section .stack_sizes,"",@progbits
 $_Z4fooTIiET_v = comdat any
 define linkonce_odr dso_local i32 @_Z4fooTIiET_v() comdat {
diff --git a/llvm/test/CodeGen/X86/xray-section-group.ll b/llvm/test/CodeGen/X86/xray-section-group.ll
index c05520adf89972..1f2855b089d22e 100644
--- a/llvm/test/CodeGen/X86/xray-section-group.ll
+++ b/llvm/test/CodeGen/X86/xray-section-group.ll
@@ -12,7 +12,7 @@ $bar = comdat any
 define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-always" comdat($bar) {
 ; CHECK: .section .text.bar,"axG",@progbits,bar,comdat
   ret i32 1
-; CHECK: .section xray_instr_map,"aGo",@progbits,bar,comdat,bar{{$}}
+; CHECK: .section xray_instr_map,"aoG",@progbits,bar,bar,comdat{{$}}
 }
 
 ; CHECK-OBJ:      section xray_instr_map:
diff --git a/llvm/test/DebugInfo/SystemZ/eh_frame_personality.ll b/l...
[truncated]

* Placing 'G' before 'M' (SHF_MERGE) can be misleading as the sh_entsize
  argument goes before the section group name (if a reader doesn't know
  that the order of extra arguments is not affected by the order of flags.
* 'a', 'w', and 'x' indicate basic permission-related flags. Separating
  them with 'G' is kinda ugly.

Simplify code and move 'G' after 'o'. The new output is more similar to
GCC.
@MaskRay
Copy link
Member Author

MaskRay commented Jan 9, 2024

Manually merged in f972e4d

(sorry about that, my stacked patch series workflow doesn't work yet.)

@MaskRay MaskRay closed this Jan 9, 2024
@MaskRay MaskRay deleted the mc-G branch January 9, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants