From 5614ea9aae25fc763d184ee4b940eac27f5ec3a7 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 7 Feb 2015 08:26:40 +0000 Subject: [PATCH] MC: Emit COFF section flags in the "proper" order COFF section flags are not idempotent: 'rd' will make a read-write section because 'd' implies write 'dr' will make a read-only section because 'r' disables write llvm-svn: 228490 --- llvm/lib/MC/MCSectionCOFF.cpp | 8 ++++---- llvm/test/CodeGen/ARM/Windows/read-only-data.ll | 2 +- llvm/test/CodeGen/ARM/Windows/structors.ll | 2 +- llvm/test/CodeGen/X86/coff-comdat.ll | 16 ++++++++-------- llvm/test/CodeGen/X86/dllexport-x86_64.ll | 2 +- llvm/test/CodeGen/X86/dllexport.ll | 2 +- llvm/test/CodeGen/X86/global-sections.ll | 8 ++++---- llvm/test/CodeGen/X86/win_cst_pool.ll | 8 ++++---- llvm/test/DebugInfo/COFF/asm.ll | 4 ++-- llvm/test/DebugInfo/COFF/multifile.ll | 4 ++-- llvm/test/DebugInfo/COFF/multifunction.ll | 4 ++-- llvm/test/DebugInfo/COFF/simple.ll | 4 ++-- .../DebugInfo/COFF/tail-call-without-lexical-scopes.ll | 2 +- llvm/test/DebugInfo/X86/coff_debug_info_type.ll | 2 +- llvm/test/MC/COFF/bss_section.ll | 2 +- llvm/test/MC/COFF/const-gv-with-rel-init.ll | 4 ++-- llvm/test/MC/COFF/global_ctors_dtors.ll | 12 ++++++------ llvm/test/MC/COFF/initialised-data.ll | 2 +- llvm/test/MC/COFF/section-passthru-flags.s | 4 ++-- 19 files changed, 46 insertions(+), 46 deletions(-) diff --git a/llvm/lib/MC/MCSectionCOFF.cpp b/llvm/lib/MC/MCSectionCOFF.cpp index e95845f0..4d6298c 100644 --- a/llvm/lib/MC/MCSectionCOFF.cpp +++ b/llvm/lib/MC/MCSectionCOFF.cpp @@ -47,6 +47,10 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, } OS << "\t.section\t" << getSectionName() << ",\""; + if (getCharacteristics() & COFF::IMAGE_SCN_CNT_INITIALIZED_DATA) + OS << 'd'; + if (getCharacteristics() & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) + OS << 'b'; if (getCharacteristics() & COFF::IMAGE_SCN_MEM_EXECUTE) OS << 'x'; if (getCharacteristics() & COFF::IMAGE_SCN_MEM_WRITE) @@ -55,10 +59,6 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << 'r'; else OS << 'y'; - if (getCharacteristics() & COFF::IMAGE_SCN_CNT_INITIALIZED_DATA) - OS << 'd'; - if (getCharacteristics() & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) - OS << 'b'; if (getCharacteristics() & COFF::IMAGE_SCN_LNK_REMOVE) OS << 'n'; if (getCharacteristics() & COFF::IMAGE_SCN_MEM_SHARED) diff --git a/llvm/test/CodeGen/ARM/Windows/read-only-data.ll b/llvm/test/CodeGen/ARM/Windows/read-only-data.ll index 0ccb5ed..0438d68 100644 --- a/llvm/test/CodeGen/ARM/Windows/read-only-data.ll +++ b/llvm/test/CodeGen/ARM/Windows/read-only-data.ll @@ -10,6 +10,6 @@ entry: ret void } -; CHECK: .section .rdata,"rd" +; CHECK: .section .rdata,"dr" ; CHECK-NOT: .section ".rodata.str1.1" diff --git a/llvm/test/CodeGen/ARM/Windows/structors.ll b/llvm/test/CodeGen/ARM/Windows/structors.ll index a1a9026..874b5bf 100644 --- a/llvm/test/CodeGen/ARM/Windows/structors.ll +++ b/llvm/test/CodeGen/ARM/Windows/structors.ll @@ -7,6 +7,6 @@ entry: ret void } -; CHECK: .section .CRT$XCU,"rd" +; CHECK: .section .CRT$XCU,"dr" ; CHECK: .long function diff --git a/llvm/test/CodeGen/X86/coff-comdat.ll b/llvm/test/CodeGen/X86/coff-comdat.ll index dcbbe10..44e1cb2 100644 --- a/llvm/test/CodeGen/X86/coff-comdat.ll +++ b/llvm/test/CodeGen/X86/coff-comdat.ll @@ -73,20 +73,20 @@ $vftable = comdat largest ; CHECK: .globl @v8@0 ; CHECK: .section .text,"xr",discard,@f8@0 ; CHECK: .globl @f8@0 -; CHECK: .section .bss,"wb",associative,_f1 +; CHECK: .section .bss,"bw",associative,_f1 ; CHECK: .globl _v1 -; CHECK: .section .bss,"wb",associative,_f2 +; CHECK: .section .bss,"bw",associative,_f2 ; CHECK: .globl _v2 -; CHECK: .section .bss,"wb",associative,_f3 +; CHECK: .section .bss,"bw",associative,_f3 ; CHECK: .globl _v3 -; CHECK: .section .bss,"wb",associative,_f4 +; CHECK: .section .bss,"bw",associative,_f4 ; CHECK: .globl _v4 -; CHECK: .section .bss,"wb",associative,_f5 +; CHECK: .section .bss,"bw",associative,_f5 ; CHECK: .globl _v5 -; CHECK: .section .bss,"wb",associative,_f6 +; CHECK: .section .bss,"bw",associative,_f6 ; CHECK: .globl _v6 -; CHECK: .section .bss,"wb",same_size,_f6 +; CHECK: .section .bss,"bw",same_size,_f6 ; CHECK: .globl _f6 -; CHECK: .section .rdata,"rd",largest,_vftable +; CHECK: .section .rdata,"dr",largest,_vftable ; CHECK: .globl _vftable ; CHECK: _vftable = L_some_name+4 diff --git a/llvm/test/CodeGen/X86/dllexport-x86_64.ll b/llvm/test/CodeGen/X86/dllexport-x86_64.ll index 25b88e5..629a557 100644 --- a/llvm/test/CodeGen/X86/dllexport-x86_64.ll +++ b/llvm/test/CodeGen/X86/dllexport-x86_64.ll @@ -37,7 +37,7 @@ define weak_odr dllexport void @weak1() { ; CHECK: .globl Var1 @Var1 = dllexport global i32 1, align 4 -; CHECK: .rdata,"rd" +; CHECK: .rdata,"dr" ; CHECK: .globl Var2 @Var2 = dllexport unnamed_addr constant i32 1 diff --git a/llvm/test/CodeGen/X86/dllexport.ll b/llvm/test/CodeGen/X86/dllexport.ll index 91e1074..02a83ae 100644 --- a/llvm/test/CodeGen/X86/dllexport.ll +++ b/llvm/test/CodeGen/X86/dllexport.ll @@ -58,7 +58,7 @@ define weak_odr dllexport void @weak1() { ; CHECK: .globl _Var1 @Var1 = dllexport global i32 1, align 4 -; CHECK: .rdata,"rd" +; CHECK: .rdata,"dr" ; CHECK: .globl _Var2 @Var2 = dllexport unnamed_addr constant i32 1 diff --git a/llvm/test/CodeGen/X86/global-sections.ll b/llvm/test/CodeGen/X86/global-sections.ll index 29bf9963b..0502582 100644 --- a/llvm/test/CodeGen/X86/global-sections.ll +++ b/llvm/test/CodeGen/X86/global-sections.ll @@ -48,7 +48,7 @@ define void @F1() { ; LINUX-SECTIONS: .section .rodata.G3,"a",@progbits ; LINUX-SECTIONS: .globl G3 -; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G3 +; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G3 ; WIN32-SECTIONS: .globl _G3 @@ -124,7 +124,7 @@ define void @F1() { ; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1 ; LINUX-SECTIONS: .globl G7 -; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G7 +; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G7 ; WIN32-SECTIONS: .globl _G7 @@ -187,7 +187,7 @@ define void @F1() { ; LINUX-SECTIONS: .asciz "foo" ; LINUX-SECTIONS: .size .LG14, 4 -; WIN32-SECTIONS: .section .rdata,"rd" +; WIN32-SECTIONS: .section .rdata,"dr" ; WIN32-SECTIONS: L_G14: ; WIN32-SECTIONS: .asciz "foo" @@ -209,5 +209,5 @@ define void @F1() { ; LINUX-SECTIONS: .section .rodata.cst8,"aM",@progbits,8 ; LINUX-SECTIONS: G15: -; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G15 +; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G15 ; WIN32-SECTIONS: _G15: diff --git a/llvm/test/CodeGen/X86/win_cst_pool.ll b/llvm/test/CodeGen/X86/win_cst_pool.ll index e8b853a..d534b12 100644 --- a/llvm/test/CodeGen/X86/win_cst_pool.ll +++ b/llvm/test/CodeGen/X86/win_cst_pool.ll @@ -6,7 +6,7 @@ define double @double() { ret double 0x0000000000800000 } ; CHECK: .globl __real@0000000000800000 -; CHECK-NEXT: .section .rdata,"rd",discard,__real@0000000000800000 +; CHECK-NEXT: .section .rdata,"dr",discard,__real@0000000000800000 ; CHECK-NEXT: .align 8 ; CHECK-NEXT: __real@0000000000800000: ; CHECK-NEXT: .quad 8388608 @@ -18,7 +18,7 @@ define <4 x i32> @vec1() { ret <4 x i32> } ; CHECK: .globl __xmm@00000000000000010000000200000003 -; CHECK-NEXT: .section .rdata,"rd",discard,__xmm@00000000000000010000000200000003 +; CHECK-NEXT: .section .rdata,"dr",discard,__xmm@00000000000000010000000200000003 ; CHECK-NEXT: .align 16 ; CHECK-NEXT: __xmm@00000000000000010000000200000003: ; CHECK-NEXT: .long 3 @@ -33,7 +33,7 @@ define <8 x i16> @vec2() { ret <8 x i16> } ; CHECK: .globl __xmm@00000001000200030004000500060007 -; CHECK-NEXT: .section .rdata,"rd",discard,__xmm@00000001000200030004000500060007 +; CHECK-NEXT: .section .rdata,"dr",discard,__xmm@00000001000200030004000500060007 ; CHECK-NEXT: .align 16 ; CHECK-NEXT: __xmm@00000001000200030004000500060007: ; CHECK-NEXT: .short 7 @@ -53,7 +53,7 @@ define <4 x float> @undef1() { ret <4 x float> ; CHECK: .globl __xmm@00000000000000003f8000003f800000 -; CHECK-NEXT: .section .rdata,"rd",discard,__xmm@00000000000000003f8000003f800000 +; CHECK-NEXT: .section .rdata,"dr",discard,__xmm@00000000000000003f8000003f800000 ; CHECK-NEXT: .align 16 ; CHECK-NEXT: __xmm@00000000000000003f8000003f800000: ; CHECK-NEXT: .long 1065353216 # float 1 diff --git a/llvm/test/DebugInfo/COFF/asm.ll b/llvm/test/DebugInfo/COFF/asm.ll index 44ee4f9..4d5cdda 100644 --- a/llvm/test/DebugInfo/COFF/asm.ll +++ b/llvm/test/DebugInfo/COFF/asm.ll @@ -22,7 +22,7 @@ ; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_F:^L.*]]: ; -; X86-LABEL: .section .debug$S,"rd" +; X86-LABEL: .section .debug$S,"dr" ; X86-NEXT: .long 4 ; Symbol subsection ; X86-NEXT: .long 241 @@ -127,7 +127,7 @@ ; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rd" +; X64-LABEL: .section .debug$S,"dr" ; X64-NEXT: .long 4 ; Symbol subsection ; X64-NEXT: .long 241 diff --git a/llvm/test/DebugInfo/COFF/multifile.ll b/llvm/test/DebugInfo/COFF/multifile.ll index 5cdd6dc..52a62d1 100644 --- a/llvm/test/DebugInfo/COFF/multifile.ll +++ b/llvm/test/DebugInfo/COFF/multifile.ll @@ -29,7 +29,7 @@ ; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_F:.*]]: ; -; X86-LABEL: .section .debug$S,"rd" +; X86-LABEL: .section .debug$S,"dr" ; X86-NEXT: .long 4 ; Symbol subsection ; X86-NEXT: .long 241 @@ -159,7 +159,7 @@ ; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rd" +; X64-LABEL: .section .debug$S,"dr" ; X64-NEXT: .long 4 ; Symbol subsection ; X64-NEXT: .long 241 diff --git a/llvm/test/DebugInfo/COFF/multifunction.ll b/llvm/test/DebugInfo/COFF/multifunction.ll index 8f9a3f8..01ba617 100644 --- a/llvm/test/DebugInfo/COFF/multifunction.ll +++ b/llvm/test/DebugInfo/COFF/multifunction.ll @@ -53,7 +53,7 @@ ; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_F:.*]]: ; -; X86-LABEL: .section .debug$S,"rd" +; X86-LABEL: .section .debug$S,"dr" ; X86-NEXT: .long 4 ; Symbol subsection for x ; X86-NEXT: .long 241 @@ -317,7 +317,7 @@ ; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rd" +; X64-LABEL: .section .debug$S,"dr" ; X64-NEXT: .long 4 ; Symbol subsection for x ; X64-NEXT: .long 241 diff --git a/llvm/test/DebugInfo/COFF/simple.ll b/llvm/test/DebugInfo/COFF/simple.ll index bcb8a69..196deef 100644 --- a/llvm/test/DebugInfo/COFF/simple.ll +++ b/llvm/test/DebugInfo/COFF/simple.ll @@ -20,7 +20,7 @@ ; X86-NEXT: L{{.*}}: ; X86-NEXT: [[END_OF_F:.*]]: ; -; X86-LABEL: .section .debug$S,"rd" +; X86-LABEL: .section .debug$S,"dr" ; X86-NEXT: .long 4 ; Symbol subsection ; X86-NEXT: .long 241 @@ -118,7 +118,7 @@ ; X64-NEXT: .L{{.*}}: ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rd" +; X64-LABEL: .section .debug$S,"dr" ; X64-NEXT: .long 4 ; Symbol subsection ; X64-NEXT: .long 241 diff --git a/llvm/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll b/llvm/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll index 181359b..83d976d 100644 --- a/llvm/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll +++ b/llvm/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll @@ -22,7 +22,7 @@ ; X86-NEXT: [[END_OF_BAR:^L.*]]:{{$}} ; X86-NOT: ret -; X86-LABEL: .section .debug$S,"rd" +; X86-LABEL: .section .debug$S,"dr" ; X86: .secrel32 "?bar@@YAXHZZ" ; X86-NEXT: .secidx "?bar@@YAXHZZ" ; X86: .long 0 diff --git a/llvm/test/DebugInfo/X86/coff_debug_info_type.ll b/llvm/test/DebugInfo/X86/coff_debug_info_type.ll index d34f50b..89859d2 100644 --- a/llvm/test/DebugInfo/X86/coff_debug_info_type.ll +++ b/llvm/test/DebugInfo/X86/coff_debug_info_type.ll @@ -6,7 +6,7 @@ ; CHECK: .section .apple_types ; RUN: llc -mtriple=i686-pc-win32 -filetype=asm -O0 < %s | FileCheck -check-prefix=WIN32 %s -; WIN32: .section .debug$S,"rd" +; WIN32: .section .debug$S,"dr" ; RUN: llc -mtriple=i686-pc-win32 -filetype=null -O0 < %s diff --git a/llvm/test/MC/COFF/bss_section.ll b/llvm/test/MC/COFF/bss_section.ll index f80a071..d3a8aec 100644 --- a/llvm/test/MC/COFF/bss_section.ll +++ b/llvm/test/MC/COFF/bss_section.ll @@ -7,4 +7,4 @@ $thingy_linkonce = comdat any @thingy_linkonce = linkonce_odr global %struct.foo zeroinitializer, comdat, align 4 -; CHECK: .section .bss,"wb",discard,_thingy_linkonce +; CHECK: .section .bss,"bw",discard,_thingy_linkonce diff --git a/llvm/test/MC/COFF/const-gv-with-rel-init.ll b/llvm/test/MC/COFF/const-gv-with-rel-init.ll index 6a89e2f..fde5a17 100644 --- a/llvm/test/MC/COFF/const-gv-with-rel-init.ll +++ b/llvm/test/MC/COFF/const-gv-with-rel-init.ll @@ -5,7 +5,7 @@ define void @f() { } @ptr = constant void ()* @f, section ".CRT$XLB", align 8 -; CHECK: .section .CRT$XLB,"rd" +; CHECK: .section .CRT$XLB,"dr" @weak_array = weak_odr unnamed_addr constant [1 x i8*] [i8* bitcast (void ()* @f to i8*)] -; CHECK: .section .rdata,"rd" +; CHECK: .section .rdata,"dr" diff --git a/llvm/test/MC/COFF/global_ctors_dtors.ll b/llvm/test/MC/COFF/global_ctors_dtors.ll index ca17f24..be92c27 100644 --- a/llvm/test/MC/COFF/global_ctors_dtors.ll +++ b/llvm/test/MC/COFF/global_ctors_dtors.ll @@ -49,17 +49,17 @@ define i32 @main() nounwind { ret i32 0 } -; WIN32: .section .CRT$XCU,"rd" +; WIN32: .section .CRT$XCU,"dr" ; WIN32: a_global_ctor -; WIN32: .section .CRT$XCU,"rd",associative,{{_?}}b +; WIN32: .section .CRT$XCU,"dr",associative,{{_?}}b ; WIN32: b_global_ctor ; WIN32-NOT: c_global_ctor -; WIN32: .section .CRT$XTX,"rd" +; WIN32: .section .CRT$XTX,"dr" ; WIN32: a_global_dtor -; MINGW32: .section .ctors,"wd" +; MINGW32: .section .ctors,"dw" ; MINGW32: a_global_ctor -; MINGW32: .section .ctors,"wd",associative,{{_?}}b +; MINGW32: .section .ctors,"dw",associative,{{_?}}b ; MINGW32: b_global_ctor ; MINGW32-NOT: c_global_ctor -; MINGW32: .section .dtors,"wd" +; MINGW32: .section .dtors,"dw" ; MINGW32: a_global_dtor diff --git a/llvm/test/MC/COFF/initialised-data.ll b/llvm/test/MC/COFF/initialised-data.ll index c428469..a2faac7 100644 --- a/llvm/test/MC/COFF/initialised-data.ll +++ b/llvm/test/MC/COFF/initialised-data.ll @@ -3,5 +3,5 @@ @data = dllexport constant [5 x i8] c"data\00", align 1 -; CHECK: .section .rdata,"rd" +; CHECK: .section .rdata,"dr" diff --git a/llvm/test/MC/COFF/section-passthru-flags.s b/llvm/test/MC/COFF/section-passthru-flags.s index 3bd061b..96e42d2 100644 --- a/llvm/test/MC/COFF/section-passthru-flags.s +++ b/llvm/test/MC/COFF/section-passthru-flags.s @@ -3,5 +3,5 @@ // CHECK: .section .klaatu,"wn" .section .barada,"y" // CHECK: .section .barada,"y" -.section .nikto,"wds" -// CHECK: .section .nikto,"wds" +.section .nikto,"dws" +// CHECK: .section .nikto,"dws" -- 2.7.4