[llvm] f972e4d - [MC,ELF] .section: unconditionally print section flag 'G' after 'o'
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 9 10:48:31 PST 2024
Author: Fangrui Song
Date: 2024-01-09T10:48:23-08:00
New Revision: f972e4d3434364718899f974e4d1c8e60aea91fa
URL: https://github.com/llvm/llvm-project/commit/f972e4d3434364718899f974e4d1c8e60aea91fa
DIFF: https://github.com/llvm/llvm-project/commit/f972e4d3434364718899f974e4d1c8e60aea91fa.diff
LOG: [MC,ELF] .section: unconditionally print section flag 'G' after 'o'
* 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.
Added:
Modified:
llvm/lib/MC/MCSectionELF.cpp
llvm/test/CodeGen/Mips/ehframe-indirect.ll
llvm/test/CodeGen/PowerPC/ppc32-pic-large.ll
llvm/test/CodeGen/SPARC/constructor.ll
llvm/test/CodeGen/X86/constructor.ll
llvm/test/CodeGen/X86/elf-comdat.ll
llvm/test/CodeGen/X86/elf-comdat2.ll
llvm/test/CodeGen/X86/elf-group.ll
llvm/test/CodeGen/X86/explicit-section-mergeable.ll
llvm/test/CodeGen/X86/global-sections-comdat.ll
llvm/test/DebugInfo/SystemZ/eh_frame_personality.ll
llvm/test/DebugInfo/SystemZ/eh_frame_personality.s
llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_basic.s
llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_large_static_personality_encodings.s
llvm/test/MC/ELF/alias-to-local.s
llvm/test/MC/ELF/relocation.s
llvm/test/tools/llvm-symbolizer/frame.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index 1e1b5edb94d761..b1efb839ba75f6 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -90,10 +90,6 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
OS << 'e';
if (Flags & ELF::SHF_EXECINSTR)
OS << 'x';
- // TODO: Always print G after o to be clear that the 'G' argument is parsed
- // after the 'o' argument.
- if ((Flags & ELF::SHF_GROUP) && !(Flags & ELF::SHF_LINK_ORDER))
- OS << 'G';
if (Flags & ELF::SHF_WRITE)
OS << 'w';
if (Flags & ELF::SHF_MERGE)
@@ -104,7 +100,7 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
OS << 'T';
if (Flags & ELF::SHF_LINK_ORDER)
OS << 'o';
- if ((Flags & ELF::SHF_GROUP) && (Flags & ELF::SHF_LINK_ORDER))
+ if (Flags & ELF::SHF_GROUP)
OS << 'G';
if (Flags & ELF::SHF_GNU_RETAIN)
OS << 'R';
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", at progbits,DW.ref.__gxx_personality_v0,comdat
+; ALL: .section .data.DW.ref.__gxx_personality_v0,"awG", at progbits,DW.ref.__gxx_personality_v0,comdat
; O32: .p2align 2
; N32: .p2align 2
; N64: .p2align 3
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 at l
; LARGE-SECUREPLT: bl call_foo at PLT+32768
-; LARGE: .section .bss.bar1,"aGw", at nobits,bar1,comdat
+; LARGE: .section .bss.bar1,"awG", at nobits,bar1,comdat
; LARGE: bar1:
-; LARGE: .section .bss.bar2,"aGw", at nobits,bar1,comdat
+; LARGE: .section .bss.bar2,"awG", at nobits,bar1,comdat
; LARGE: bar2:
; LARGE: .section .got2,"aw", at progbits
; LARGE-NEXT: .p2align 2
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", at 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", at 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/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", at progbits,v,comdat
+; CTOR-NEXT: .section .ctors.09980,"awG", at progbits,v,comdat
; CTOR-NEXT: .p2align 3
; CTOR-NEXT: .quad h
-; CTOR-NEXT: .section .ctors.65520,"aGw", at progbits,v,comdat
+; CTOR-NEXT: .section .ctors.65520,"awG", at progbits,v,comdat
; CTOR-NEXT: .p2align 3
; CTOR-NEXT: .quad g
-; INIT-ARRAY: .section .init_array.15,"aGw", at init_array,v,comdat
+; INIT-ARRAY: .section .init_array.15,"awG", at init_array,v,comdat
; INIT-ARRAY-NEXT: .p2align 3
; INIT-ARRAY-NEXT: .quad g
-; INIT-ARRAY-NEXT: .section .init_array.55555,"aGw", at init_array,v,comdat
+; INIT-ARRAY-NEXT: .section .init_array.55555,"awG", at init_array,v,comdat
; INIT-ARRAY-NEXT: .p2align 3
; INIT-ARRAY-NEXT: .quad h
; INIT-ARRAY-NEXT: .section .init_array,"aw", at init_array
@@ -62,10 +62,10 @@ entry:
; INIT-ARRAY-NEXT: .quad i
; INIT-ARRAY-NEXT: .quad j
-; NACL: .section .init_array.15,"aGw", at init_array,v,comdat
+; NACL: .section .init_array.15,"awG", at init_array,v,comdat
; NACL-NEXT: .p2align 2
; NACL-NEXT: .long g
-; NACL-NEXT: .section .init_array.55555,"aGw", at init_array,v,comdat
+; NACL-NEXT: .section .init_array.55555,"awG", at init_array,v,comdat
; NACL-NEXT: .p2align 2
; NACL-NEXT: .long h
; NACL-NEXT: .section .init_array,"aw", at 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", at progbits,f,comdat
; CHECK: .globl f
-; CHECK: .section .bss.v,"aGw", at nobits,f,comdat
+; CHECK: .section .bss.v,"awG", at 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, at object
-; CHECK-NEXT: .section .data.bar,"aGw", at progbits,foo,comdat
+; CHECK-NEXT: .section .data.bar,"awG", at progbits,foo,comdat
; CHECK-NEXT: .globl bar
; CHECK: .type foo, at 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", at progbits,f1{{$}}
; CHECK: .section .text.f2,"axG", at progbits,f1{{$}}
-; CHECK: .section .bss.g1,"aGw", at nobits,f1{{$}}
+; CHECK: .section .bss.g1,"awG", at 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", at progbits,4,f,comdat,unique,[[#U+7]]
+; CHECK: .section .rodata.cst4,"aMG", at progbits,4,f,comdat,unique,[[#U+7]]
; CHECK: implicit_rodata_cst4_comdat:
-; CHECK: .section .rodata.cst8,"aGM", at progbits,8,g,comdat,unique,[[#U+8]]
+; CHECK: .section .rodata.cst8,"aMG", at 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", at progbits,4,unique,[[#U+9]]
; CHECK: explicit_comdat_distinct_supply_uid:
-; CHECK: .section .explicit_comdat_distinct,"aGM", at progbits,4,f,comdat,unique,[[#U+10]]
+; CHECK: .section .explicit_comdat_distinct,"aMG", at progbits,4,f,comdat,unique,[[#U+10]]
; CHECK: explicit_comdat_distinct1:
-; CHECK: .section .explicit_comdat_distinct,"aGM", at progbits,4,g,comdat,unique,[[#U+10]]
+; CHECK: .section .explicit_comdat_distinct,"aMG", at progbits,4,g,comdat,unique,[[#U+10]]
; CHECK: explicit_comdat_distinct2:
-; CHECK: .section .explicit_comdat_distinct,"aGM", at progbits,8,h,comdat,unique,[[#U+11]]
+; CHECK: .section .explicit_comdat_distinct,"aMG", at 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", at progbits,4,i,comdat,unique,[[#U+12]]
+; CHECK: .section .rodata.cst4,"aMG", at progbits,4,i,comdat,unique,[[#U+12]]
; CHECK: implicit_rodata_cst4_same_comdat:
-; CHECK: .section .rodata.cst8,"aGM", at progbits,8,i,comdat,unique,[[#U+13]]
+; CHECK: .section .rodata.cst8,"aMG", at 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", at progbits,4,unique,[[#U+14]]
; CHECK: explicit_comdat_same_supply_uid:
-; CHECK: .section .explicit_comdat_same,"aGM", at progbits,4,i,comdat,unique,[[#U+15]]
+; CHECK: .section .explicit_comdat_same,"aMG", at progbits,4,i,comdat,unique,[[#U+15]]
; CHECK: explicit_comdat_same1:
; CHECK: explicit_comdat_same2:
-; CHECK: .section .explicit_comdat_same,"aGM", at progbits,8,i,comdat,unique,[[#U+16]]
+; CHECK: .section .explicit_comdat_same,"aMG", at progbits,8,i,comdat,unique,[[#U+16]]
; CHECK: explicit_comdat_same3:
$i = comdat any
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", at progbits,4,G16,comdat
-; LINUX-SECTIONS: .section .rodata.cst4.G16,"aGM", at progbits,4,G16,comdat
-; LINUX-SECTIONS-SHORT: .section .rodata.cst4,"aGM", at progbits,4,G16,comdat
+; LINUX: .section .rodata.cst4.G16,"aMG", at progbits,4,G16,comdat
+; LINUX-SECTIONS: .section .rodata.cst4.G16,"aMG", at progbits,4,G16,comdat
+; LINUX-SECTIONS-SHORT: .section .rodata.cst4,"aMG", at progbits,4,G16,comdat
diff --git a/llvm/test/DebugInfo/SystemZ/eh_frame_personality.ll b/llvm/test/DebugInfo/SystemZ/eh_frame_personality.ll
index e1c656c4b3eb7d..002da2f0e7f2e2 100644
--- a/llvm/test/DebugInfo/SystemZ/eh_frame_personality.ll
+++ b/llvm/test/DebugInfo/SystemZ/eh_frame_personality.ll
@@ -39,7 +39,7 @@ clean:
; CHECK-REF: .cfi_lsda 27, .Lexception0
; CHECK-REF: .hidden DW.ref.__gxx_personality_v0
; CHECK-REF: .weak DW.ref.__gxx_personality_v0
-; CHECK-REF: .section .data.DW.ref.__gxx_personality_v0,"aGw", at progbits,DW.ref.__gxx_personality_v0,comdat
+; CHECK-REF: .section .data.DW.ref.__gxx_personality_v0,"awG", at progbits,DW.ref.__gxx_personality_v0,comdat
; CHECK-REF-NEXT: .p2align 3
; CHECK-REF-NEXT: .type DW.ref.__gxx_personality_v0, at object
; CHECK-REF-NEXT: .size DW.ref.__gxx_personality_v0, 8
diff --git a/llvm/test/DebugInfo/SystemZ/eh_frame_personality.s b/llvm/test/DebugInfo/SystemZ/eh_frame_personality.s
index c452951941a16c..0c99361b4acf1d 100644
--- a/llvm/test/DebugInfo/SystemZ/eh_frame_personality.s
+++ b/llvm/test/DebugInfo/SystemZ/eh_frame_personality.s
@@ -25,7 +25,7 @@ foo: # @foo
.hidden DW.ref.__gxx_personality_v0
.weak DW.ref.__gxx_personality_v0
- .section .data.DW.ref.__gxx_personality_v0,"aGw", at progbits,DW.ref.__gxx_personality_v0,comdat
+ .section .data.DW.ref.__gxx_personality_v0,"awG", at progbits,DW.ref.__gxx_personality_v0,comdat
.align 8
.type DW.ref.__gxx_personality_v0, at object
.size DW.ref.__gxx_personality_v0, 8
diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_basic.s b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_basic.s
index 1b3ff16ea1495f..c01ced5d0523b4 100644
--- a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_basic.s
+++ b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_basic.s
@@ -106,7 +106,7 @@ GCC_except_table1:
.quad _ZTIi
.hidden DW.ref.__gxx_personality_v0
.weak DW.ref.__gxx_personality_v0
- .section .data.DW.ref.__gxx_personality_v0,"aGw", at progbits,DW.ref.__gxx_personality_v0,comdat
+ .section .data.DW.ref.__gxx_personality_v0,"awG", at progbits,DW.ref.__gxx_personality_v0,comdat
.p2align 3
.type DW.ref.__gxx_personality_v0, at object
.size DW.ref.__gxx_personality_v0, 8
diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_large_static_personality_encodings.s b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_large_static_personality_encodings.s
index 02538442d9d9ec..64990b5d38f079 100644
--- a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_large_static_personality_encodings.s
+++ b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_ehframe_large_static_personality_encodings.s
@@ -190,7 +190,7 @@ GCC_except_table1:
.hidden DW.ref.__gxx_personality_v0
.weak DW.ref.__gxx_personality_v0
- .section .data.DW.ref.__gxx_personality_v0,"aGw", at progbits,DW.ref.__gxx_personality_v0,comdat
+ .section .data.DW.ref.__gxx_personality_v0,"awG", at progbits,DW.ref.__gxx_personality_v0,comdat
.p2align 3
.type DW.ref.__gxx_personality_v0, at object
.size DW.ref.__gxx_personality_v0, 8
diff --git a/llvm/test/MC/ELF/alias-to-local.s b/llvm/test/MC/ELF/alias-to-local.s
index 5b6ac058c1e81c..beff230a8db30d 100644
--- a/llvm/test/MC/ELF/alias-to-local.s
+++ b/llvm/test/MC/ELF/alias-to-local.s
@@ -10,7 +10,7 @@ foo:
movl $zed, %eax
- .section .data.bar,"aGw", at progbits,zed,comdat
+ .section .data.bar,"awG", at progbits,zed,comdat
bar:
.byte 42
diff --git a/llvm/test/MC/ELF/relocation.s b/llvm/test/MC/ELF/relocation.s
index 797e31f529b3db..80b671aa2c859e 100644
--- a/llvm/test/MC/ELF/relocation.s
+++ b/llvm/test/MC/ELF/relocation.s
@@ -4,7 +4,7 @@
// Test that we produce the correct relocation.
- .section .pr23272,"aGw", at progbits,pr23272,comdat
+ .section .pr23272,"awG", at progbits,pr23272,comdat
.globl pr23272
pr23272:
pr23272_2:
diff --git a/llvm/test/tools/llvm-symbolizer/frame.s b/llvm/test/tools/llvm-symbolizer/frame.s
index 28cbd493182e0d..741132ad32d752 100644
--- a/llvm/test/tools/llvm-symbolizer/frame.s
+++ b/llvm/test/tools/llvm-symbolizer/frame.s
@@ -203,7 +203,7 @@ hwasan.module_ctor: // @hwasan.module_ctor
.size hwasan.module_ctor, .Lfunc_end1-hwasan.module_ctor
.cfi_endproc
// -- End function
- .section .init_array.0,"aGw", at init_array,hwasan.module_ctor,comdat
+ .section .init_array.0,"awG", at init_array,hwasan.module_ctor,comdat
.p2align 3
.xword hwasan.module_ctor
.section .debug_str,"MS", at progbits,1
More information about the llvm-commits
mailing list