From 49babc916aa0186ba8347d0216069a84cb67da31 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 23 Apr 2014 21:29:34 +0000 Subject: [PATCH] MC: honour IMAGE_SCN_CNT_INITIALIZED_DATA Emit the flag to indicate to the assembler that a section contains data if there is pre-populated data present. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207028 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCSectionCOFF.cpp | 3 ++- test/CodeGen/Generic/initialised-data.ll | 8 ++++++++ test/CodeGen/X86/dllexport-x86_64.ll | 6 +++--- test/CodeGen/X86/dllexport.ll | 6 +++--- test/CodeGen/X86/global-sections.ll | 6 +++--- test/DebugInfo/COFF/asm.ll | 4 ++-- test/DebugInfo/COFF/multifile.ll | 4 ++-- test/DebugInfo/COFF/multifunction.ll | 4 ++-- test/DebugInfo/COFF/simple.ll | 4 ++-- test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll | 2 +- test/DebugInfo/X86/coff_debug_info_type.ll | 2 +- test/MC/COFF/global_ctors_dtors.ll | 8 ++++---- test/MC/COFF/weak-symbol.ll | 8 ++++---- 13 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 test/CodeGen/Generic/initialised-data.ll diff --git a/lib/MC/MCSectionCOFF.cpp b/lib/MC/MCSectionCOFF.cpp index 05f0b721b86..335b8cd6121 100644 --- a/lib/MC/MCSectionCOFF.cpp +++ b/lib/MC/MCSectionCOFF.cpp @@ -62,7 +62,8 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << 'r'; if (getCharacteristics() & COFF::IMAGE_SCN_MEM_DISCARDABLE) OS << 'n'; - + if (getCharacteristics() & COFF::IMAGE_SCN_CNT_INITIALIZED_DATA) + OS << 'd'; OS << '"'; if (getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) { diff --git a/test/CodeGen/Generic/initialised-data.ll b/test/CodeGen/Generic/initialised-data.ll new file mode 100644 index 00000000000..9f428bc3fdb --- /dev/null +++ b/test/CodeGen/Generic/initialised-data.ll @@ -0,0 +1,8 @@ +; RUN: llc -mtriple i686-windows %s -o - | FileCheck %s +; RUN: llc -mtriple x86_64-windows %s -o - | FileCheck %s +; RUN: llc -mtriple thumbv7-windows %s -o - | FileCheck %s + +@data = dllexport constant [5 x i8] c"data\00", align 1 + +; CHECK: .section .rdata,"rd" + diff --git a/test/CodeGen/X86/dllexport-x86_64.ll b/test/CodeGen/X86/dllexport-x86_64.ll index a38c2d8f8ab..af0f85b00e6 100644 --- a/test/CodeGen/X86/dllexport-x86_64.ll +++ b/test/CodeGen/X86/dllexport-x86_64.ll @@ -40,18 +40,18 @@ define weak_odr dllexport void @weak1() { ; CHECK: .globl Var1 @Var1 = dllexport global i32 1, align 4 -; CHECK: .rdata,"r" +; CHECK: .rdata,"rd" ; CHECK: .globl Var2 @Var2 = dllexport unnamed_addr constant i32 1 ; CHECK: .comm Var3 @Var3 = common dllexport global i32 0, align 4 -; CHECK: .section .data,"w",discard,WeakVar1 +; CHECK: .section .data,"wd",discard,WeakVar1 ; CHECK: .globl WeakVar1 @WeakVar1 = weak_odr dllexport global i32 1, align 4 -; CHECK: .section .rdata,"r",discard,WeakVar2 +; CHECK: .section .rdata,"rd",discard,WeakVar2 ; CHECK: .globl WeakVar2 @WeakVar2 = weak_odr dllexport unnamed_addr constant i32 1 diff --git a/test/CodeGen/X86/dllexport.ll b/test/CodeGen/X86/dllexport.ll index 1b34d238693..eba6d6946e9 100644 --- a/test/CodeGen/X86/dllexport.ll +++ b/test/CodeGen/X86/dllexport.ll @@ -55,18 +55,18 @@ define weak_odr dllexport void @weak1() { ; CHECK: .globl _Var1 @Var1 = dllexport global i32 1, align 4 -; CHECK: .rdata,"r" +; CHECK: .rdata,"rd" ; CHECK: .globl _Var2 @Var2 = dllexport unnamed_addr constant i32 1 ; CHECK: .comm _Var3 @Var3 = common dllexport global i32 0, align 4 -; CHECK: .section .data,"w",discard,_WeakVar1 +; CHECK: .section .data,"wd",discard,_WeakVar1 ; CHECK: .globl _WeakVar1 @WeakVar1 = weak_odr dllexport global i32 1, align 4 -; CHECK: .section .rdata,"r",discard,_WeakVar2 +; CHECK: .section .rdata,"rd",discard,_WeakVar2 ; CHECK: .globl _WeakVar2 @WeakVar2 = weak_odr dllexport unnamed_addr constant i32 1 diff --git a/test/CodeGen/X86/global-sections.ll b/test/CodeGen/X86/global-sections.ll index 5ad504719fc..7f123c10672 100644 --- a/test/CodeGen/X86/global-sections.ll +++ b/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,"r",one_only,_G3 +; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G3 ; WIN32-SECTIONS: .globl _G3 @@ -127,7 +127,7 @@ define void @F1() { ; LINUX-SECTIONS: .section .rodata.G7,"aMS",@progbits,1 ; LINUX-SECTIONS: .globl G7 -; WIN32-SECTIONS: .section .rdata,"r",one_only,_G7 +; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G7 ; WIN32-SECTIONS: .globl _G7 @@ -190,7 +190,7 @@ define void @F1() { ; LINUX-SECTIONS: .asciz "foo" ; LINUX-SECTIONS: .size .LG14, 4 -; WIN32-SECTIONS: .section .rdata,"r" +; WIN32-SECTIONS: .section .rdata,"rd" ; WIN32-SECTIONS: L_G14: ; WIN32-SECTIONS: .asciz "foo" diff --git a/test/DebugInfo/COFF/asm.ll b/test/DebugInfo/COFF/asm.ll index 1ce3681908e..8c9dff0cdf1 100644 --- a/test/DebugInfo/COFF/asm.ll +++ b/test/DebugInfo/COFF/asm.ll @@ -21,7 +21,7 @@ ; X86-NEXT: ret ; X86-NEXT: [[END_OF_F:.*]]: ; -; X86-LABEL: .section .debug$S,"rn" +; X86-LABEL: .section .debug$S,"rnd" ; X86-NEXT: .long 4 ; X86-NEXT: .long 242 ; X86-NEXT: .long [[F2_END:.*]]-[[F2_START:.*]] @@ -90,7 +90,7 @@ ; X64-NEXT: ret ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rn" +; X64-LABEL: .section .debug$S,"rnd" ; X64-NEXT: .long 4 ; X64-NEXT: .long 242 ; X64-NEXT: .long [[F2_END:.*]]-[[F2_START:.*]] diff --git a/test/DebugInfo/COFF/multifile.ll b/test/DebugInfo/COFF/multifile.ll index 53a645ed3f7..c04bdb3b7c9 100644 --- a/test/DebugInfo/COFF/multifile.ll +++ b/test/DebugInfo/COFF/multifile.ll @@ -28,7 +28,7 @@ ; X86-NEXT: ret ; X86-NEXT: [[END_OF_F:.*]]: ; -; X86-LABEL: .section .debug$S,"rn" +; X86-LABEL: .section .debug$S,"rnd" ; X86-NEXT: .long 4 ; X86-NEXT: .long 242 ; X86-NEXT: .long [[F2_END:.*]]-[[F2_START:.*]] @@ -122,7 +122,7 @@ ; X64-NEXT: ret ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rn" +; X64-LABEL: .section .debug$S,"rnd" ; X64-NEXT: .long 4 ; X64-NEXT: .long 242 ; X64-NEXT: .long [[F2_END:.*]]-[[F2_START:.*]] diff --git a/test/DebugInfo/COFF/multifunction.ll b/test/DebugInfo/COFF/multifunction.ll index d664716e7d3..5a6555805fd 100644 --- a/test/DebugInfo/COFF/multifunction.ll +++ b/test/DebugInfo/COFF/multifunction.ll @@ -50,7 +50,7 @@ ; X86-NEXT: ret ; X86-NEXT: [[END_OF_F:.*]]: ; -; X86-LABEL: .section .debug$S,"rn" +; X86-LABEL: .section .debug$S,"rnd" ; X86-NEXT: .long 4 ; Line table subsection for x ; X86-NEXT: .long 242 @@ -200,7 +200,7 @@ ; X64-NEXT: ret ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rn" +; X64-LABEL: .section .debug$S,"rnd" ; X64-NEXT: .long 4 ; Line table subsection for x ; X64-NEXT: .long 242 diff --git a/test/DebugInfo/COFF/simple.ll b/test/DebugInfo/COFF/simple.ll index 8fa6870a54e..2613a18298d 100644 --- a/test/DebugInfo/COFF/simple.ll +++ b/test/DebugInfo/COFF/simple.ll @@ -19,7 +19,7 @@ ; X86-NEXT: ret ; X86-NEXT: [[END_OF_F:.*]]: ; -; X86-LABEL: .section .debug$S,"rn" +; X86-LABEL: .section .debug$S,"rnd" ; X86-NEXT: .long 4 ; X86-NEXT: .long 242 ; X86-NEXT: .long [[F2_END:.*]]-[[F2_START:.*]] @@ -81,7 +81,7 @@ ; X64-NEXT: ret ; X64-NEXT: [[END_OF_F:.*]]: ; -; X64-LABEL: .section .debug$S,"rn" +; X64-LABEL: .section .debug$S,"rnd" ; X64-NEXT: .long 4 ; X64-NEXT: .long 242 ; X64-NEXT: .long [[F2_END:.*]]-[[F2_START:.*]] diff --git a/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll b/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll index f5e2eae0a44..4d2e4273447 100644 --- a/test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll +++ b/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,"rn" +; X86-LABEL: .section .debug$S,"rnd" ; X86: .secrel32 "?bar@@YAXHZZ" ; X86-NEXT: .secidx "?bar@@YAXHZZ" ; X86: .long 0 diff --git a/test/DebugInfo/X86/coff_debug_info_type.ll b/test/DebugInfo/X86/coff_debug_info_type.ll index e61c8076b60..a0b8ccc6eca 100644 --- a/test/DebugInfo/X86/coff_debug_info_type.ll +++ b/test/DebugInfo/X86/coff_debug_info_type.ll @@ -4,7 +4,7 @@ ; CHECK: .section .debug_info ; RUN: llc -mtriple=i686-pc-win32 -filetype=asm -O0 < %s | FileCheck -check-prefix=WIN32 %s -; WIN32: .section .debug$S,"rn" +; WIN32: .section .debug$S,"rnd" ; generated from: ; clang -g -S -emit-llvm test.c -o test.ll diff --git a/test/MC/COFF/global_ctors_dtors.ll b/test/MC/COFF/global_ctors_dtors.ll index 2a25219a778..b95093ac88a 100644 --- a/test/MC/COFF/global_ctors_dtors.ll +++ b/test/MC/COFF/global_ctors_dtors.ll @@ -29,11 +29,11 @@ define i32 @main() nounwind { ret i32 0 } -; WIN32: .section .CRT$XCU,"r" +; WIN32: .section .CRT$XCU,"rd" ; WIN32: a_global_ctor -; WIN32: .section .CRT$XTX,"r" +; WIN32: .section .CRT$XTX,"rd" ; WIN32: a_global_dtor -; MINGW32: .section .ctors,"w" +; MINGW32: .section .ctors,"wd" ; MINGW32: a_global_ctor -; MINGW32: .section .dtors,"w" +; MINGW32: .section .dtors,"wd" ; MINGW32: a_global_dtor diff --git a/test/MC/COFF/weak-symbol.ll b/test/MC/COFF/weak-symbol.ll index c06692ed908..fd78307c1f2 100644 --- a/test/MC/COFF/weak-symbol.ll +++ b/test/MC/COFF/weak-symbol.ll @@ -28,20 +28,20 @@ define weak void @f() section ".sect" { } ; Weak global -; X86: .section .data,"r",discard,_a +; X86: .section .data,"rd",discard,_a ; X86: .globl _a ; X86: .zero 12 ; -; X64: .section .data,"r",discard,a +; X64: .section .data,"rd",discard,a ; X64: .globl a ; X64: .zero 12 @a = weak unnamed_addr constant { i32, i32, i32 } { i32 0, i32 0, i32 0}, section ".data" -; X86: .section .tls$,"w",discard,_b +; X86: .section .tls$,"wd",discard,_b ; X86: .globl _b ; X86: .long 0 ; -; X64: .section .tls$,"w",discard,b +; X64: .section .tls$,"wd",discard,b ; X64: .globl b ; X64: .long 0