1 ; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s -check-prefix=LINUX
2 ; RUN: llc < %s -mtriple=i386-apple-darwin9.7 | FileCheck %s -check-prefix=DARWIN
3 ; RUN: llc < %s -mtriple=i386-apple-darwin10 -relocation-model=static | FileCheck %s -check-prefix=DARWIN-STATIC
4 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s -check-prefix=DARWIN64
5 ; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -data-sections -function-sections | FileCheck %s -check-prefix=LINUX-SECTIONS
6 ; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -function-sections | FileCheck %s -check-prefix=LINUX-FUNC-SECTIONS
7 ; RUN: llc < %s -mtriple=x86_64-pc-linux -data-sections -function-sections -relocation-model=pic | FileCheck %s -check-prefix=LINUX-SECTIONS-PIC
8 ; RUN: llc < %s -mtriple=i686-pc-win32 -data-sections -function-sections | FileCheck %s -check-prefix=WIN32-SECTIONS
9 ; RUN: llc < %s -mtriple=i686-pc-win32 -function-sections | FileCheck %s -check-prefix=WIN32-FUNC-SECTIONS
15 ; WIN32-SECTIONS: .section .text,"xr",one_only,_F1
16 ; WIN32-SECTIONS: .globl _F1
18 define void @F2(i32 %y) {
20 switch i32 %y, label %bb5 [
39 ; LINUX-NEX: .cfi_endproc
40 ; LINUX-NEX: .section .rodata,"a",@progbits
42 ; LINUX-SECTIONS: .section .text.F2,"ax",@progbits
43 ; LINUX-SECTIONS: .size F2,
44 ; LINUX-SECTIONS-NEXT: .cfi_endproc
45 ; LINUX-SECTIONS-NEXT: .section .rodata.F2,"a",@progbits
47 ; LINUX-FUNC-SECTIONS: .section .text.F2,"ax",@progbits
48 ; LINUX-FUNC-SECTIONS: .size F2,
49 ; LINUX-FUNC-SECTIONS-NEXT: .cfi_endproc
50 ; LINUX-FUNC-SECTIONS-NEXT: .section .rodata.F2,"a",@progbits
52 ; WIN32-FUNC-SECTIONS: .section .text,"xr",one_only,_F2
53 ; WIN32-FUNC-SECTIONS-NOT: .section
54 ; WIN32-FUNC-SECTIONS: .section .rdata,"dr",associative,_F2
57 ; LINUX-SECTIONS-PIC: .section .text.F2,"ax",@progbits
58 ; LINUX-SECTIONS-PIC: .size F2,
59 ; LINUX-SECTIONS-PIC-NEXT: .cfi_endproc
60 ; LINUX-SECTIONS-PIC-NEXT: .section .rodata.F2,"a",@progbits
64 define void @F3(i32 %y) personality i8* bitcast (void ()* @G to i8*) {
67 to label %bb2 unwind label %bb1
69 landingpad { i8*, i32 }
74 switch i32 %y, label %bb7 [
94 ; DARWIN64-NEXT: .cfi_endproc
95 ; DARWIN64-NOT: .section
96 ; DARWIN64: .data_region jt32
97 ; DARWIN64: LJTI{{.*}}:
98 ; DARWIN64-NEXT: .long
99 ; DARWIN64-NEXT: .long
100 ; DARWIN64-NEXT: .long
101 ; DARWIN64-NEXT: .long
102 ; DARWIN64-NEXT: .end_data_region
103 ; DARWIN64-NEXT: .section __TEXT,__gcc_except_tab
106 @G1 = common global i32 0
108 ; LINUX: .type G1,@object
109 ; LINUX: .comm G1,4,4
111 ; DARWIN: .comm _G1,4,2
116 ; const int G2 __attribute__((weak)) = 42;
117 @G2 = weak_odr unnamed_addr constant i32 42
120 ; TODO: linux drops this into .rodata, we drop it into ".gnu.linkonce.r.G2"
122 ; DARWIN: .section __TEXT,__const{{$}}
127 ; int * const G3 = &G1;
128 @G3 = unnamed_addr constant i32* @G1
130 ; DARWIN: .section __DATA,__const
135 ; LINUX: .section .rodata,"a",@progbits
138 ; LINUX-SECTIONS: .section .rodata.G3,"a",@progbits
139 ; LINUX-SECTIONS: .globl G3
141 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G3
142 ; WIN32-SECTIONS: .globl _G3
145 ; _Complex long long const G4 = 34;
146 @G4 = private unnamed_addr constant {i64,i64} { i64 34, i64 0 }
148 ; DARWIN: .section __TEXT,__literal16,16byte_literals
152 ; DARWIN-STATIC: .section __TEXT,__literal16,16byte_literals
153 ; DARWIN-STATIC: L_G4:
154 ; DARWIN-STATIC: .long 34
156 ; DARWIN64: .section __TEXT,__literal16,16byte_literals
168 ; DARWIN: .section __DATA,__data
175 @"foo bar" = linkonce global i32 42
177 ; LINUX: .type "foo bar",@object
178 ; LINUX: .weak "foo bar"
181 ; DARWIN: .globl "_foo bar"
182 ; DARWIN: .weak_definition "_foo bar"
183 ; DARWIN: "_foo bar":
186 @G6 = weak_odr unnamed_addr constant [1 x i8] c"\01"
188 ; LINUX: .type G6,@object
194 ; DARWIN: .section __TEXT,__const{{$}}
196 ; DARWIN: .weak_definition _G6
201 @G7 = unnamed_addr constant [10 x i8] c"abcdefghi\00"
203 ; DARWIN: __TEXT,__cstring,cstring_literals
206 ; DARWIN: .asciz "abcdefghi"
208 ; LINUX: .section .rodata.str1.1,"aMS",@progbits,1
211 ; LINUX: .asciz "abcdefghi"
213 ; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1
214 ; LINUX-SECTIONS: .globl G7
216 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G7
217 ; WIN32-SECTIONS: .globl _G7
220 @G8 = unnamed_addr constant [4 x i16] [ i16 1, i16 2, i16 3, i16 0 ]
222 ; DARWIN: .section __TEXT,__const
226 ; LINUX: .section .rodata.str2.2,"aMS",@progbits,2
230 @G9 = unnamed_addr constant [4 x i32] [ i32 1, i32 2, i32 3, i32 0 ]
235 ; LINUX: .section .rodata.str4.4,"aMS",@progbits,4
240 @G10 = weak global [100 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=0]
243 ; DARWIN: .section __DATA,__data{{$}}
244 ; DARWIN: .globl _G10
245 ; DARWIN: .weak_definition _G10
258 ;; Zero sized objects should round up to 1 byte in zerofill directives.
260 @G11 = global [0 x i32] zeroinitializer
261 @G12 = global {} zeroinitializer
262 @G13 = global { [0 x {}] } zeroinitializer
264 ; DARWIN: .globl _G11
265 ; DARWIN: .zerofill __DATA,__common,_G11,1,2
266 ; DARWIN: .globl _G12
267 ; DARWIN: .zerofill __DATA,__common,_G12,1,3
268 ; DARWIN: .globl _G13
269 ; DARWIN: .zerofill __DATA,__common,_G13,1,3
271 @G14 = private unnamed_addr constant [4 x i8] c"foo\00", align 1
273 ; LINUX-SECTIONS: .type .LG14,@object # @G14
274 ; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1
275 ; LINUX-SECTIONS: .LG14:
276 ; LINUX-SECTIONS: .asciz "foo"
277 ; LINUX-SECTIONS: .size .LG14, 4
279 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G14
280 ; WIN32-SECTIONS: _G14:
281 ; WIN32-SECTIONS: .asciz "foo"
283 ; cannot be merged on MachO, but can on other formats.
284 @G15 = unnamed_addr constant i64 0
286 ; LINUX: .section .rodata.cst8,"aM",@progbits,8
289 ; DARWIN: .section __TEXT,__const
292 ; DARWIN-STATIC: .section __TEXT,__const
293 ; DARWIN-STATIC: _G15:
295 ; DARWIN64: .section __TEXT,__const
298 ; LINUX-SECTIONS: .section .rodata.cst8,"aM",@progbits,8
299 ; LINUX-SECTIONS: G15:
301 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G15
302 ; WIN32-SECTIONS: _G15:
304 @G16 = unnamed_addr constant i256 0
306 ; LINUX: .section .rodata.cst32,"aM",@progbits,32
309 ; LINUX-SECTIONS: .section .rodata.cst32,"aM",@progbits,32
310 ; LINUX-SECTIONS: G16:
312 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G16
313 ; WIN32-SECTIONS: _G16:
317 @G17 = internal global i8 0
318 ; LINUX: .type G17,@object
320 ; LINUX: .comm G17,1,1
322 ; DARWIN: .zerofill __DATA,__bss,_G17,1,0
324 ; LINUX-SECTIONS: .type G17,@object
325 ; LINUX-SECTIONS: .section .bss.G17,"aw",@nobits
326 ; LINUX-SECTIONS: .byte 0
327 ; LINUX-SECTIONS: .size G17, 1
329 ; WIN32-SECTIONS: .section .bss,"bw",one_only,_G17
330 ; WIN32-SECTIONS: _G17:
331 ; WIN32-SECTIONS:.byte 0
333 ; check weak ReadOnlyWithRel globals.
334 @G18 = linkonce_odr unnamed_addr constant i64* @G15
335 ; DARWIN64: .section __DATA,__const