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 10 11 define void @F1() { 12 ret void 13 } 14 15 ; WIN32-SECTIONS: .section .text,"xr",one_only,_F1 16 ; WIN32-SECTIONS: .globl _F1 17 18 define void @F2(i32 %y) { 19 bb0: 20 switch i32 %y, label %bb5 [ 21 i32 1, label %bb1 22 i32 2, label %bb2 23 i32 3, label %bb3 24 i32 4, label %bb4 25 ] 26 bb1: 27 ret void 28 bb2: 29 ret void 30 bb3: 31 ret void 32 bb4: 33 ret void 34 bb5: 35 ret void 36 } 37 38 ; LINUX: .size F2, 39 ; LINUX-NEX: .cfi_endproc 40 ; LINUX-NEX: .section .rodata,"a",@progbits 41 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 46 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 51 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 55 56 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 61 62 declare void @G() 63 64 define void @F3(i32 %y) { 65 bb0: 66 invoke void @G() 67 to label %bb2 unwind label %bb1 68 bb1: 69 landingpad { i8*, i32 } personality i8* bitcast (void ()* @G to i8*) 70 catch i8* null 71 br label %bb2 72 bb2: 73 74 switch i32 %y, label %bb7 [ 75 i32 1, label %bb3 76 i32 2, label %bb4 77 i32 3, label %bb5 78 i32 4, label %bb6 79 ] 80 bb3: 81 ret void 82 bb4: 83 ret void 84 bb5: 85 ret void 86 bb6: 87 ret void 88 bb7: 89 ret void 90 } 91 92 ; DARWIN64: _F3: 93 ; DARWIN64: Lfunc_end 94 ; DARWIN64-NEXT: .cfi_endproc 95 ; DARWIN64-NOT: .section 96 ; DARWIN64: LJTI{{.*}}: 97 ; DARWIN64-NEXT: .long 98 ; DARWIN64-NEXT: .long 99 ; DARWIN64-NEXT: .long 100 ; DARWIN64-NEXT: .long 101 ; DARWIN64-NEXT: .section __TEXT,__gcc_except_tab 102 103 ; int G1; 104 @G1 = common global i32 0 105 106 ; LINUX: .type G1,@object 107 ; LINUX: .comm G1,4,4 108 109 ; DARWIN: .comm _G1,4,2 110 111 112 113 114 ; const int G2 __attribute__((weak)) = 42; 115 @G2 = weak_odr unnamed_addr constant i32 42 116 117 118 ; TODO: linux drops this into .rodata, we drop it into ".gnu.linkonce.r.G2" 119 120 ; DARWIN: .section __TEXT,__const_coal,coalesced 121 ; DARWIN: _G2: 122 ; DARWIN: .long 42 123 124 125 ; int * const G3 = &G1; 126 @G3 = unnamed_addr constant i32* @G1 127 128 ; DARWIN: .section __DATA,__const 129 ; DARWIN: .globl _G3 130 ; DARWIN: _G3: 131 ; DARWIN: .long _G1 132 133 ; LINUX: .section .rodata,"a",@progbits 134 ; LINUX: .globl G3 135 136 ; LINUX-SECTIONS: .section .rodata.G3,"a",@progbits 137 ; LINUX-SECTIONS: .globl G3 138 139 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G3 140 ; WIN32-SECTIONS: .globl _G3 141 142 143 ; _Complex long long const G4 = 34; 144 @G4 = private unnamed_addr constant {i64,i64} { i64 34, i64 0 } 145 146 ; DARWIN: .section __TEXT,__literal16,16byte_literals 147 ; DARWIN: L_G4: 148 ; DARWIN: .long 34 149 150 ; DARWIN-STATIC: .section __TEXT,__literal16,16byte_literals 151 ; DARWIN-STATIC: L_G4: 152 ; DARWIN-STATIC: .long 34 153 154 ; DARWIN64: .section __TEXT,__literal16,16byte_literals 155 ; DARWIN64: L_G4: 156 ; DARWIN64: .quad 34 157 158 ; int G5 = 47; 159 @G5 = global i32 47 160 161 ; LINUX: .data 162 ; LINUX: .globl G5 163 ; LINUX: G5: 164 ; LINUX: .long 47 165 166 ; DARWIN: .section __DATA,__data 167 ; DARWIN: .globl _G5 168 ; DARWIN: _G5: 169 ; DARWIN: .long 47 170 171 172 ; PR4584 173 @"foo bar" = linkonce global i32 42 174 175 ; LINUX: .type "foo bar",@object 176 ; LINUX: .weak "foo bar" 177 ; LINUX: "foo bar": 178 179 ; DARWIN: .section __DATA,__datacoal_nt,coalesced 180 ; DARWIN: .globl "_foo bar" 181 ; DARWIN: .weak_definition "_foo bar" 182 ; DARWIN: "_foo bar": 183 184 ; PR4650 185 @G6 = weak_odr unnamed_addr constant [1 x i8] c"\01" 186 187 ; LINUX: .type G6,@object 188 ; LINUX: .weak G6 189 ; LINUX: G6: 190 ; LINUX: .byte 1 191 ; LINUX: .size G6, 1 192 193 ; DARWIN: .section __TEXT,__const_coal,coalesced 194 ; DARWIN: .globl _G6 195 ; DARWIN: .weak_definition _G6 196 ; DARWIN:_G6: 197 ; DARWIN: .byte 1 198 199 200 @G7 = unnamed_addr constant [10 x i8] c"abcdefghi\00" 201 202 ; DARWIN: __TEXT,__cstring,cstring_literals 203 ; DARWIN: .globl _G7 204 ; DARWIN: _G7: 205 ; DARWIN: .asciz "abcdefghi" 206 207 ; LINUX: .section .rodata.str1.1,"aMS",@progbits,1 208 ; LINUX: .globl G7 209 ; LINUX: G7: 210 ; LINUX: .asciz "abcdefghi" 211 212 ; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1 213 ; LINUX-SECTIONS: .globl G7 214 215 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G7 216 ; WIN32-SECTIONS: .globl _G7 217 218 219 @G8 = unnamed_addr constant [4 x i16] [ i16 1, i16 2, i16 3, i16 0 ] 220 221 ; DARWIN: .section __TEXT,__const 222 ; DARWIN: .globl _G8 223 ; DARWIN: _G8: 224 225 ; LINUX: .section .rodata.str2.2,"aMS",@progbits,2 226 ; LINUX: .globl G8 227 ; LINUX:G8: 228 229 @G9 = unnamed_addr constant [4 x i32] [ i32 1, i32 2, i32 3, i32 0 ] 230 231 ; DARWIN: .globl _G9 232 ; DARWIN: _G9: 233 234 ; LINUX: .section .rodata.str4.4,"aMS",@progbits,4 235 ; LINUX: .globl G9 236 ; LINUX:G9 237 238 239 @G10 = weak global [100 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=0] 240 241 242 ; DARWIN: .section __DATA,__datacoal_nt,coalesced 243 ; DARWIN: .globl _G10 244 ; DARWIN: .weak_definition _G10 245 ; DARWIN: .align 5 246 ; DARWIN: _G10: 247 ; DARWIN: .space 400 248 249 ; LINUX: .bss 250 ; LINUX: .weak G10 251 ; LINUX: .align 32 252 ; LINUX: G10: 253 ; LINUX: .zero 400 254 255 256 257 ;; Zero sized objects should round up to 1 byte in zerofill directives. 258 ; rdar://7886017 259 @G11 = global [0 x i32] zeroinitializer 260 @G12 = global {} zeroinitializer 261 @G13 = global { [0 x {}] } zeroinitializer 262 263 ; DARWIN: .globl _G11 264 ; DARWIN: .zerofill __DATA,__common,_G11,1,2 265 ; DARWIN: .globl _G12 266 ; DARWIN: .zerofill __DATA,__common,_G12,1,3 267 ; DARWIN: .globl _G13 268 ; DARWIN: .zerofill __DATA,__common,_G13,1,3 269 270 @G14 = private unnamed_addr constant [4 x i8] c"foo\00", align 1 271 272 ; LINUX-SECTIONS: .type .LG14,@object # @G14 273 ; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1 274 ; LINUX-SECTIONS: .LG14: 275 ; LINUX-SECTIONS: .asciz "foo" 276 ; LINUX-SECTIONS: .size .LG14, 4 277 278 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G14 279 ; WIN32-SECTIONS: _G14: 280 ; WIN32-SECTIONS: .asciz "foo" 281 282 ; cannot be merged on MachO, but can on other formats. 283 @G15 = unnamed_addr constant i64 0 284 285 ; LINUX: .section .rodata.cst8,"aM",@progbits,8 286 ; LINUX: G15: 287 288 ; DARWIN: .section __TEXT,__const 289 ; DARWIN: _G15: 290 291 ; DARWIN-STATIC: .section __TEXT,__const 292 ; DARWIN-STATIC: _G15: 293 294 ; DARWIN64: .section __TEXT,__const 295 ; DARWIN64: _G15: 296 297 ; LINUX-SECTIONS: .section .rodata.cst8,"aM",@progbits,8 298 ; LINUX-SECTIONS: G15: 299 300 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G15 301 ; WIN32-SECTIONS: _G15: 302