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) personality i8* bitcast (void ()* @G to i8*) { 65 bb0: 66 invoke void @G() 67 to label %bb2 unwind label %bb1 68 bb1: 69 landingpad { i8*, i32 } 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{{$}} 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: .globl "_foo bar" 180 ; DARWIN: .weak_definition "_foo bar" 181 ; DARWIN: "_foo bar": 182 183 ; PR4650 184 @G6 = weak_odr unnamed_addr constant [1 x i8] c"\01" 185 186 ; LINUX: .type G6,@object 187 ; LINUX: .weak G6 188 ; LINUX: G6: 189 ; LINUX: .byte 1 190 ; LINUX: .size G6, 1 191 192 ; DARWIN: .section __TEXT,__const{{$}} 193 ; DARWIN: .globl _G6 194 ; DARWIN: .weak_definition _G6 195 ; DARWIN:_G6: 196 ; DARWIN: .byte 1 197 198 199 @G7 = unnamed_addr constant [10 x i8] c"abcdefghi\00" 200 201 ; DARWIN: __TEXT,__cstring,cstring_literals 202 ; DARWIN: .globl _G7 203 ; DARWIN: _G7: 204 ; DARWIN: .asciz "abcdefghi" 205 206 ; LINUX: .section .rodata.str1.1,"aMS",@progbits,1 207 ; LINUX: .globl G7 208 ; LINUX: G7: 209 ; LINUX: .asciz "abcdefghi" 210 211 ; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1 212 ; LINUX-SECTIONS: .globl G7 213 214 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G7 215 ; WIN32-SECTIONS: .globl _G7 216 217 218 @G8 = unnamed_addr constant [4 x i16] [ i16 1, i16 2, i16 3, i16 0 ] 219 220 ; DARWIN: .section __TEXT,__const 221 ; DARWIN: .globl _G8 222 ; DARWIN: _G8: 223 224 ; LINUX: .section .rodata.str2.2,"aMS",@progbits,2 225 ; LINUX: .globl G8 226 ; LINUX:G8: 227 228 @G9 = unnamed_addr constant [4 x i32] [ i32 1, i32 2, i32 3, i32 0 ] 229 230 ; DARWIN: .globl _G9 231 ; DARWIN: _G9: 232 233 ; LINUX: .section .rodata.str4.4,"aMS",@progbits,4 234 ; LINUX: .globl G9 235 ; LINUX:G9 236 237 238 @G10 = weak global [100 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=0] 239 240 241 ; DARWIN: .section __DATA,__data{{$}} 242 ; DARWIN: .globl _G10 243 ; DARWIN: .weak_definition _G10 244 ; DARWIN: .align 5 245 ; DARWIN: _G10: 246 ; DARWIN: .space 400 247 248 ; LINUX: .bss 249 ; LINUX: .weak G10 250 ; LINUX: .align 32 251 ; LINUX: G10: 252 ; LINUX: .zero 400 253 254 255 256 ;; Zero sized objects should round up to 1 byte in zerofill directives. 257 ; rdar://7886017 258 @G11 = global [0 x i32] zeroinitializer 259 @G12 = global {} zeroinitializer 260 @G13 = global { [0 x {}] } zeroinitializer 261 262 ; DARWIN: .globl _G11 263 ; DARWIN: .zerofill __DATA,__common,_G11,1,2 264 ; DARWIN: .globl _G12 265 ; DARWIN: .zerofill __DATA,__common,_G12,1,3 266 ; DARWIN: .globl _G13 267 ; DARWIN: .zerofill __DATA,__common,_G13,1,3 268 269 @G14 = private unnamed_addr constant [4 x i8] c"foo\00", align 1 270 271 ; LINUX-SECTIONS: .type .LG14,@object # @G14 272 ; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1 273 ; LINUX-SECTIONS: .LG14: 274 ; LINUX-SECTIONS: .asciz "foo" 275 ; LINUX-SECTIONS: .size .LG14, 4 276 277 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G14 278 ; WIN32-SECTIONS: _G14: 279 ; WIN32-SECTIONS: .asciz "foo" 280 281 ; cannot be merged on MachO, but can on other formats. 282 @G15 = unnamed_addr constant i64 0 283 284 ; LINUX: .section .rodata.cst8,"aM",@progbits,8 285 ; LINUX: G15: 286 287 ; DARWIN: .section __TEXT,__const 288 ; DARWIN: _G15: 289 290 ; DARWIN-STATIC: .section __TEXT,__const 291 ; DARWIN-STATIC: _G15: 292 293 ; DARWIN64: .section __TEXT,__const 294 ; DARWIN64: _G15: 295 296 ; LINUX-SECTIONS: .section .rodata.cst8,"aM",@progbits,8 297 ; LINUX-SECTIONS: G15: 298 299 ; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G15 300 ; WIN32-SECTIONS: _G15: 301