f000691411a25769d10f2c155966cd7eafcdef4c
[oota-llvm.git] / test / DebugInfo / X86 / bitfields.ll
1 ; RUN: %llc_dwarf -mtriple x86_64-apple-macosx -O0 -filetype=obj -o %t_le.o %s
2 ; RUN: llvm-dwarfdump -debug-dump=info %t_le.o | FileCheck %s
3 ; REQUIRES: object-emission
4
5 ; Produced at -O0 from:
6 ; struct bitfield {
7 ;   int a : 2;
8 ;   int b : 32;
9 ;   int c : 1;
10 ;   int d : 28;
11 ; };
12 ; struct bitfield b;
13
14 ; Note that DWARF 2 counts bit offsets backwards from the high end of
15 ; the storage unit to the high end of the bit field.
16
17 ; CHECK: DW_TAG_member
18 ; CHECK-NEXT: DW_AT_name{{.*}}"a"
19 ; CHECK-NOT: DW_TAG_member
20 ; CHECK:      DW_AT_byte_size  {{.*}} (0x04)
21 ; CHECK-NEXT: DW_AT_bit_size   {{.*}} (0x02)
22 ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x1e)
23 ; CHECK-NEXT: DW_AT_data_member_location {{.*}} 00
24
25 ; CHECK: DW_TAG_member
26 ; CHECK-NEXT: DW_AT_name{{.*}}"b"
27 ; CHECK-NOT: DW_TAG_member
28 ; CHECK:      DW_AT_data_member_location {{.*}} 04
29
30 ; CHECK: DW_TAG_member
31 ; CHECK-NEXT: DW_AT_name{{.*}}"c"
32 ; CHECK-NOT: DW_TAG_member
33 ; CHECK:      DW_AT_byte_size  {{.*}} (0x04)
34 ; CHECK-NEXT: DW_AT_bit_size   {{.*}} (0x01)
35 ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x1f)
36 ; CHECK-NEXT: DW_AT_data_member_location {{.*}} 08
37
38 ; CHECK: DW_TAG_member
39 ; CHECK-NEXT: DW_AT_name{{.*}}"d"
40 ; CHECK-NOT: DW_TAG_member
41 ; CHECK:      DW_AT_byte_size  {{.*}} (0x04)
42 ; CHECK-NEXT: DW_AT_bit_size   {{.*}} (0x1c)
43 ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x03)
44 ; CHECK-NEXT: DW_AT_data_member_location {{.*}} 08
45
46 ; ModuleID = 'bitfields.c'
47 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
48 target triple = "x86_64-apple-macosx"
49
50 %struct.bitfield = type <{ i8, [3 x i8], i64 }>
51
52 @b = common global %struct.bitfield zeroinitializer, align 4
53
54 !llvm.dbg.cu = !{!0}
55 !llvm.module.flags = !{!13, !14, !15}
56 !llvm.ident = !{!16}
57
58 !0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 240548) (llvm/trunk 240554)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !3, imports: !2)
59 !1 = !DIFile(filename: "bitfields.c", directory: "/")
60 !2 = !{}
61 !3 = !{!4}
62 !4 = !DIGlobalVariable(name: "b", scope: !0, file: !5, line: 8, type: !6, isLocal: false, isDefinition: true, variable: %struct.bitfield* @b)
63 !5 = !DIFile(filename: "bitfields.c", directory: "/")
64 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "bitfield", file: !5, line: 1, size: 96, align: 32, elements: !7)
65 !7 = !{!8, !10, !11, !12}
66 !8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !5, line: 2, baseType: !9, size: 2, align: 32)
67 !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
68 !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !5, line: 3, baseType: !9, size: 32, align: 32, offset: 32)
69 !11 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !6, file: !5, line: 4, baseType: !9, size: 1, align: 32, offset: 64)
70 !12 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !5, line: 5, baseType: !9, size: 28, align: 32, offset: 65)
71 !13 = !{i32 2, !"Dwarf Version", i32 2}
72 !14 = !{i32 2, !"Debug Info Version", i32 3}
73 !15 = !{i32 1, !"PIC Level", i32 2}
74 !16 = !{!"clang version 3.7.0 (trunk 240548) (llvm/trunk 240554)"}