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:  BitField ([[S1_u:.*]]) {
67; CHECK:    TypeLeafKind: LF_BITFIELD (0x1205)
68; CHECK:    Type: short (0x11)
69; CHECK:    BitSize: 3
70; CHECK:    BitOffset: 0
71; CHECK:  }
72; CHECK:  FieldList ([[S1_fl:.*]]) {
73; CHECK:    TypeLeafKind: LF_FIELDLIST (0x1203)
74; CHECK:    DataMember {
75; CHECK:      FieldOffset: 0x0
76; CHECK:      Name: x1
77; CHECK:    }
78; CHECK:    DataMember {
79; CHECK:      Type: char (0x70)
80; CHECK:      FieldOffset: 0x2
81; CHECK:      Name: x2
82; CHECK:    }
83; CHECK:    DataMember {
84; CHECK:      Type: [[S1_y_z]]
85; CHECK:      FieldOffset: 0x3
86; CHECK:      Name: y
87; CHECK:    }
88; CHECK:    DataMember {
89; CHECK:      Type: [[S1_y_z]]
90; CHECK:      FieldOffset: 0x7
91; CHECK:      Name: z
92; CHECK:    }
93; CHECK:    DataMember {
94; CHECK:      Type: [[S1_w]]
95; CHECK:      FieldOffset: 0x7
96; CHECK:      Name: w
97; CHECK:    }
98; CHECK:    DataMember {
99; CHECK:      FieldOffset: 0xB
100; CHECK:      Name: v
101; CHECK:    }
102; CHECK:    DataMember {
103; CHECK:      Type: [[S1_u]]
104; CHECK:      FieldOffset: 0xE
105; CHECK:      Name: u
106; CHECK:    }
107; CHECK:  }
108; CHECK:  Struct ({{.*}}) {
109; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
110; CHECK:    MemberCount: 7
111; CHECK:    Properties [ (0x0)
112; CHECK:    ]
113; CHECK:    FieldList: <field list> ([[S1_fl]])
114; CHECK:    SizeOf: 16
115; CHECK:    Name: S1
116; CHECK:  }
117; CHECK:  FieldList ([[anon_fl:.*]]) {
118; CHECK:    TypeLeafKind: LF_FIELDLIST (0x1203)
119; CHECK:    DataMember {
120; CHECK:      Type: char (0x70)
121; CHECK:      FieldOffset: 0x0
122; CHECK:      Name: c
123; CHECK:    }
124; CHECK:    DataMember {
125; CHECK:      Type: short (0x11)
126; CHECK:      FieldOffset: 0x1
127; CHECK:      Name: s
128; CHECK:    }
129; CHECK:  }
130; CHECK:  Struct ({{.*}}) {
131; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
132; CHECK:    MemberCount: 2
133; CHECK:    Properties [ (0x0)
134; CHECK:    ]
135; CHECK:    FieldList: <field list> ([[anon_fl]])
136; CHECK:    SizeOf: 3
137; CHECK:    Name: S1::
138; CHECK:  }
139; CHECK:  BitField ([[S2_y:.*]]) {
140; CHECK:    TypeLeafKind: LF_BITFIELD (0x1205)
141; CHECK:    Type: int (0x74)
142; CHECK:    BitSize: 1
143; CHECK:    BitOffset: 0
144; CHECK:  }
145; CHECK:  FieldList ([[S2_fl:.*]]) {
146; CHECK:    TypeLeafKind: LF_FIELDLIST (0x1203)
147; CHECK:    DataMember {
148; CHECK:      Type: [[S2_y]]
149; CHECK:      FieldOffset: 0x0
150; CHECK:      Name: y
151; CHECK:    }
152; CHECK:  }
153; CHECK:  Struct ({{.*}}) {
154; CHECK:    TypeLeafKind: LF_STRUCTURE (0x1505)
155; CHECK:    MemberCount: 1
156; CHECK:    Properties [ (0x0)
157; CHECK:    ]
158; CHECK:    FieldList: <field list> ([[S2_fl]])
159; CHECK:    SizeOf: 4
160; CHECK:    Name: S2
161; CHECK:  }
162
163target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
164target triple = "x86_64-pc-windows-msvc18.0.0"
165
166%struct.S0 = type <{ i8, i16 }>
167%struct.S1 = type <{ [2 x i8], i8, i32, i32, %struct.anon, i16 }>
168%struct.anon = type <{ i8, i16 }>
169%struct.S2 = type { i32 }
170
171@s0 = common global %struct.S0 zeroinitializer, align 1
172@s1 = common global %struct.S1 zeroinitializer, align 1
173@s2 = common global %struct.S2 zeroinitializer, align 1
174
175!llvm.dbg.cu = !{!0}
176!llvm.module.flags = !{!33, !34, !35}
177!llvm.ident = !{!36}
178
179!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 273812) (llvm/trunk 273843)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
180!1 = !DIFile(filename: "-", directory: "/usr/local/google/home/majnemer/llvm/src")
181!2 = !{}
182!3 = !{!4, !10, !29}
183!4 = distinct !DIGlobalVariable(name: "s0", scope: !0, file: !5, line: 7, type: !6, isLocal: false, isDefinition: true, variable: %struct.S0* @s0)
184!5 = !DIFile(filename: "<stdin>", directory: "/usr/local/google/home/majnemer/llvm/src")
185!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !5, line: 3, size: 24, align: 8, elements: !7)
186!7 = !{!8}
187!8 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !6, file: !5, line: 6, baseType: !9, size: 8, align: 16, offset: 16, flags: DIFlagBitField, extraData: i64 8)
188!9 = !DIBasicType(name: "short", size: 16, align: 16, encoding: DW_ATE_signed)
189!10 = distinct !DIGlobalVariable(name: "s1", scope: !0, file: !5, line: 18, type: !11, isLocal: false, isDefinition: true, variable: %struct.S1* @s1)
190!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S1", file: !5, line: 10, size: 128, align: 8, elements: !12)
191!12 = !{!13, !18, !19, !21, !22, !23, !28}
192!13 = !DIDerivedType(tag: DW_TAG_member, name: "x1", scope: !11, file: !5, line: 11, baseType: !14, size: 16, align: 8)
193!14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !15, size: 16, align: 8, elements: !16)
194!15 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
195!16 = !{!17}
196!17 = !DISubrange(count: 2)
197!18 = !DIDerivedType(tag: DW_TAG_member, name: "x2", scope: !11, file: !5, line: 12, baseType: !15, size: 8, align: 8, offset: 16)
198!19 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !5, line: 13, baseType: !20, size: 23, align: 32, offset: 24, flags: DIFlagBitField, extraData: i64 24)
199!20 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
200!21 = !DIDerivedType(tag: DW_TAG_member, name: "z", scope: !11, file: !5, line: 14, baseType: !20, size: 23, align: 32, offset: 56, flags: DIFlagBitField, extraData: i64 56)
201!22 = !DIDerivedType(tag: DW_TAG_member, name: "w", scope: !11, file: !5, line: 15, baseType: !20, size: 2, align: 32, offset: 79, flags: DIFlagBitField, extraData: i64 56)
202!23 = !DIDerivedType(tag: DW_TAG_member, name: "v", scope: !11, file: !5, line: 16, baseType: !24, size: 24, align: 8, offset: 88)
203!24 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !11, file: !5, line: 16, size: 24, align: 8, elements: !25)
204!25 = !{!26, !27}
205!26 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !24, file: !5, line: 16, baseType: !15, size: 8, align: 8)
206!27 = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: !24, file: !5, line: 16, baseType: !9, size: 16, align: 16, offset: 8)
207!28 = !DIDerivedType(tag: DW_TAG_member, name: "u", scope: !11, file: !5, line: 17, baseType: !9, size: 3, align: 16, offset: 112, flags: DIFlagBitField, extraData: i64 112)
208!29 = distinct !DIGlobalVariable(name: "s2", scope: !0, file: !5, line: 24, type: !30, isLocal: false, isDefinition: true, variable: %struct.S2* @s2)
209!30 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S2", file: !5, line: 21, size: 32, align: 8, elements: !31)
210!31 = !{!32}
211!32 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !30, file: !5, line: 23, baseType: !20, size: 1, align: 32, flags: DIFlagBitField, extraData: i64 0)
212!33 = !{i32 2, !"CodeView", i32 1}
213!34 = !{i32 2, !"Debug Info Version", i32 3}
214!35 = !{i32 1, !"PIC Level", i32 2}
215!36 = !{!"clang version 3.9.0 (trunk 273812) (llvm/trunk 273843)"}
216