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.

llvm-svn: 207028
This commit is contained in:
Saleem Abdulrasool 2014-04-23 21:29:34 +00:00
parent b8dcece68f
commit 11049a0fef
13 changed files with 37 additions and 28 deletions

View File

@ -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) {

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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:.*]]

View File

@ -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:.*]]

View File

@ -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

View File

@ -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:.*]]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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