1; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
2
3; C++ source to regenerate:
4; $ cat t.cpp
5; #pragma pack(1)
6; struct S0 {
7;   char : 8;
8;   short   : 8;
9;   short x : 8;
10; } s0;
11;
12; #pragma pack(1)
13; struct S1 {
14;   char x1[2];
15;   char x2;
16;   int y : 23;
17;   int z : 23;
18;   int w : 2;
19;   struct { char c; short s; } v;
20;   short u : 3;
21; } s1;
22;
23; #pragma pack(1)
24; struct S2 {
25;   char : 0;
26;   int y : 1;
27; } s2;
28; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
29
30; CHECK: CodeViewTypes [
31; CHECK:  BitField ([[S0_x:.*]]) {
32; CHECK:    TypeLeafKind: LF_BITFIELD (0x1205)
33; CHECK:    Type: short (0x11)
34; CHECK:    BitSize: 8
35; CHECK:    BitOffset: 8
36; CHECK:  }
37; CHECK:  FieldList ([[S0_fl:.*]]) {
38; CHECK:    TypeLeafKind: LF_FIELDLIST (0x1203)
39; CHECK:    DataMember {
40; CHECK:      Type: [[S0_x:.*]]
41; CHECK:      FieldOffset: 0x1
42; CHECK:      Name: x
43; CHECK:    }
44; CHECK:  }
45; CHECK:  Struct ({{.*}}) {
46; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
47; CHECK:    MemberCount: 1
48; CHECK:    Properties [ (0x0)
49; CHECK:    ]
50; CHECK:    FieldList: <field list> ([[S0_fl]])
51; CHECK:    SizeOf: 3
52; CHECK:    Name: S0
53; CHECK:  }
54; CHECK:  BitField ([[S1_y_z:.*]]) {
55; CHECK:    TypeLeafKind: LF_BITFIELD (0x1205)
56; CHECK:    Type: int (0x74)
57; CHECK:    BitSize: 23
58; CHECK:    BitOffset: 0
59; CHECK:  }
60; CHECK:  BitField ([[S1_w:.*]]) {
61; CHECK:    TypeLeafKind: LF_BITFIELD (0x1205)
62; CHECK:    Type: int (0x74)
63; CHECK:    BitSize: 2
64; CHECK:    BitOffset: 23
65; CHECK:  }
66; CHECK:  Struct ([[anon_ty:.*]]) {
67; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
68; CHECK:    MemberCount: 0
69; CHECK:    Properties [ (0x88)
70; CHECK:      ForwardReference (0x80)
71; CHECK:      Nested (0x8)
72; CHECK:    ]
73; CHECK:    FieldList: 0x0
74; CHECK:    SizeOf: 0
75; CHECK:    Name: S1::<unnamed-tag>
76; CHECK:  }
77; CHECK:  BitField ([[S1_u:.*]]) {
78; CHECK:    TypeLeafKind: LF_BITFIELD (0x1205)
79; CHECK:    Type: short (0x11)
80; CHECK:    BitSize: 3
81; CHECK:    BitOffset: 0
82; CHECK:  }
83; CHECK:  FieldList ([[S1_fl:.*]]) {
84; CHECK:    TypeLeafKind: LF_FIELDLIST (0x1203)
85; CHECK:    DataMember {
86; CHECK:      FieldOffset: 0x0
87; CHECK:      Name: x1
88; CHECK:    }
89; CHECK:    DataMember {
90; CHECK:      Type: char (0x70)
91; CHECK:      FieldOffset: 0x2
92; CHECK:      Name: x2
93; CHECK:    }
94; CHECK:    DataMember {
95; CHECK:      Type: [[S1_y_z]]
96; CHECK:      FieldOffset: 0x3
97; CHECK:      Name: y
98; CHECK:    }
99; CHECK:    DataMember {
100; CHECK:      Type: [[S1_y_z]]
101; CHECK:      FieldOffset: 0x7
102; CHECK:      Name: z
103; CHECK:    }
104; CHECK:    DataMember {
105; CHECK:      Type: [[S1_w]]
106; CHECK:      FieldOffset: 0x7
107; CHECK:      Name: w
108; CHECK:    }
109; CHECK:    DataMember {
110; CHECK:      Type: S1::<unnamed-tag> ([[anon_ty]])
111; CHECK:      FieldOffset: 0xB
112; CHECK:      Name: v
113; CHECK:    }
114; CHECK:    DataMember {
115; CHECK:      Type: [[S1_u]]
116; CHECK:      FieldOffset: 0xE
117; CHECK:      Name: u
118; CHECK:    }
119; CHECK:  }
120; CHECK:  Struct ({{.*}}) {
121; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
122; CHECK:    MemberCount: 7
123; CHECK:    Properties [ (0x0)
124; CHECK:    ]
125; CHECK:    FieldList: <field list> ([[S1_fl]])
126; CHECK:    SizeOf: 16
127; CHECK:    Name: S1
128; CHECK:  }
129; CHECK:  FieldList ([[anon_fl:.*]]) {
130; CHECK:    TypeLeafKind: LF_FIELDLIST (0x1203)
131; CHECK:    DataMember {
132; CHECK:      Type: char (0x70)
133; CHECK:      FieldOffset: 0x0
134; CHECK:      Name: c
135; CHECK:    }
136; CHECK:    DataMember {
137; CHECK:      Type: short (0x11)
138; CHECK:      FieldOffset: 0x1
139; CHECK:      Name: s
140; CHECK:    }
141; CHECK:  }
142; CHECK:  Struct ({{.*}}) {
143; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
144; CHECK:    MemberCount: 2
145; CHECK:    Properties [ (0x8)
146; CHECK:      Nested (0x8)
147; CHECK:    ]
148; CHECK:    FieldList: <field list> ([[anon_fl]])
149; CHECK:    SizeOf: 3
150; CHECK:    Name: S1::<unnamed-tag>
151; CHECK:  }
152; CHECK:  BitField ([[S2_y:.*]]) {
153; CHECK:    TypeLeafKind: LF_BITFIELD (0x1205)
154; CHECK:    Type: int (0x74)
155; CHECK:    BitSize: 1
156; CHECK:    BitOffset: 0
157; CHECK:  }
158; CHECK:  FieldList ([[S2_fl:.*]]) {
159; CHECK:    TypeLeafKind: LF_FIELDLIST (0x1203)
160; CHECK:    DataMember {
161; CHECK:      Type: [[S2_y]]
162; CHECK:      FieldOffset: 0x0
163; CHECK:      Name: y
164; CHECK:    }
165; CHECK:  }
166; CHECK:  Struct ({{.*}}) {
167; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
168; CHECK:    MemberCount: 1
169; CHECK:    Properties [ (0x0)
170; CHECK:    ]
171; CHECK:    FieldList: <field list> ([[S2_fl]])
172; CHECK:    SizeOf: 4
173; CHECK:    Name: S2
174; CHECK:  }
175
176source_filename = "test/DebugInfo/COFF/bitfields.ll"
177target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
178target triple = "x86_64-pc-windows-msvc18.0.0"
179
180%struct.S0 = type <{ i8, i16 }>
181%struct.S1 = type <{ [2 x i8], i8, i32, i32, %struct.anon, i16 }>
182%struct.anon = type <{ i8, i16 }>
183%struct.S2 = type { i32 }
184
185@s0 = common global %struct.S0 zeroinitializer, align 1, !dbg !0
186@s1 = common global %struct.S1 zeroinitializer, align 1, !dbg !6
187@s2 = common global %struct.S2 zeroinitializer, align 1, !dbg !28
188
189!llvm.dbg.cu = !{!2}
190!llvm.module.flags = !{!36, !37, !38}
191!llvm.ident = !{!39}
192
193!0 = distinct !DIGlobalVariableExpression(var: !1)
194!1 = !DIGlobalVariable(name: "s0", scope: !2, file: !8, line: 7, type: !33, isLocal: false, isDefinition: true)
195!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.9.0 (trunk 273812) (llvm/trunk 273843)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
196!3 = !DIFile(filename: "-", directory: "/usr/local/google/home/majnemer/llvm/src")
197!4 = !{}
198!5 = !{!0, !6, !28}
199!6 = distinct !DIGlobalVariableExpression(var: !7)
200!7 = !DIGlobalVariable(name: "s1", scope: !2, file: !8, line: 18, type: !9, isLocal: false, isDefinition: true)
201!8 = !DIFile(filename: "<stdin>", directory: "/usr/local/google/home/majnemer/llvm/src")
202!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S1", file: !8, line: 10, size: 128, elements: !10)
203!10 = !{!11, !16, !17, !19, !20, !21, !27}
204!11 = !DIDerivedType(tag: DW_TAG_member, name: "x1", scope: !9, file: !8, line: 11, baseType: !12, size: 16)
205!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 16, elements: !14)
206!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
207!14 = !{!15}
208!15 = !DISubrange(count: 2)
209!16 = !DIDerivedType(tag: DW_TAG_member, name: "x2", scope: !9, file: !8, line: 12, baseType: !13, size: 8, offset: 16)
210!17 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !9, file: !8, line: 13, baseType: !18, size: 23, offset: 24, flags: DIFlagBitField, extraData: i64 24)
211!18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
212!19 = !DIDerivedType(tag: DW_TAG_member, name: "z", scope: !9, file: !8, line: 14, baseType: !18, size: 23, offset: 56, flags: DIFlagBitField, extraData: i64 56)
213!20 = !DIDerivedType(tag: DW_TAG_member, name: "w", scope: !9, file: !8, line: 15, baseType: !18, size: 2, offset: 79, flags: DIFlagBitField, extraData: i64 56)
214!21 = !DIDerivedType(tag: DW_TAG_member, name: "v", scope: !9, file: !8, line: 16, baseType: !22, size: 24, offset: 88)
215!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !9, file: !8, line: 16, size: 24, elements: !23)
216!23 = !{!24, !25}
217!24 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !22, file: !8, line: 16, baseType: !13, size: 8)
218!25 = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: !22, file: !8, line: 16, baseType: !26, size: 16, offset: 8)
219!26 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
220!27 = !DIDerivedType(tag: DW_TAG_member, name: "u", scope: !9, file: !8, line: 17, baseType: !26, size: 3, offset: 112, flags: DIFlagBitField, extraData: i64 112)
221!28 = distinct !DIGlobalVariableExpression(var: !29)
222!29 = !DIGlobalVariable(name: "s2", scope: !2, file: !8, line: 24, type: !30, isLocal: false, isDefinition: true)
223!30 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S2", file: !8, line: 21, size: 32, elements: !31)
224!31 = !{!32}
225!32 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !30, file: !8, line: 23, baseType: !18, size: 1, flags: DIFlagBitField, extraData: i64 0)
226!33 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !8, line: 3, size: 24, elements: !34)
227!34 = !{!35}
228!35 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !33, file: !8, line: 6, baseType: !26, size: 8, offset: 16, flags: DIFlagBitField, extraData: i64 8)
229!36 = !{i32 2, !"CodeView", i32 1}
230!37 = !{i32 2, !"Debug Info Version", i32 3}
231!38 = !{i32 1, !"PIC Level", i32 2}
232!39 = !{!"clang version 3.9.0 (trunk 273812) (llvm/trunk 273843)"}
233
234