xref: /llvm-project/llvm/test/DebugInfo/X86/debug-info-packed-struct.ll (revision dd881c9dbf5d940eedff7d23395141454c5a26b9)
1; Generated from tools/clang/test/CodeGen/debug-info-packed-struct.c
2; ModuleID = 'llvm/tools/clang/test/CodeGen/debug-info-packed-struct.c'
3source_filename = "test/DebugInfo/X86/debug-info-packed-struct.ll"
4target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-apple-darwin"
6; RUN: llc -O0 -filetype=obj -o %t.o %s
7; RUN: llvm-dwarfdump -v -debug-info %t.o | FileCheck %s
8
9;  // ---------------------------------------------------------------------
10;  // Not packed.
11;  // ---------------------------------------------------------------------
12;  struct size8 {
13;    int i : 4;
14;    long long l : 60;
15;  };
16;  struct layout0 {
17;    char l0_ofs0;
18;    struct size8 l0_ofs8;
19;    int l0_ofs16 : 1;
20;  } l0;
21
22%struct.layout0 = type { i8, %struct.size8, i8 }
23%struct.size8 = type { i64 }
24%struct.layout1 = type <{ i8, %struct.size8_anon, i8, [2 x i8] }>
25%struct.size8_anon = type { i64 }
26; CHECK:  DW_TAG_structure_type
27; CHECK:      DW_AT_name {{.*}} "layout0"
28; CHECK:      DW_AT_byte_size {{.*}} (0x18)
29; CHECK:      DW_TAG_member
30; CHECK:          DW_AT_name {{.*}} "l0_ofs0"
31; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x0)
32; CHECK:      DW_TAG_member
33; CHECK:          DW_AT_name {{.*}} "l0_ofs8"
34; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x8)
35; CHECK:      DW_TAG_member
36; CHECK:          DW_AT_name {{.*}} "l0_ofs16"
37; CHECK:          DW_AT_bit_size   {{.*}} (0x01)
38; CHECK:          DW_AT_bit_offset {{.*}} (0x1f)
39; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x10)
40
41; // ---------------------------------------------------------------------
42; // Implicitly packed.
43; // ---------------------------------------------------------------------
44; struct size8_anon {
45;   int : 4;
46;   long long : 60;
47; };
48; struct layout1 {
49;   char l1_ofs0;
50;   struct size8_anon l1_ofs1;
51;   int l1_ofs9 : 1;
52; } l1;
53
54%struct.layout2 = type <{ i8, %struct.size8_pack1, i8 }>
55%struct.size8_pack1 = type { i64 }
56%struct.layout3 = type <{ i8, [3 x i8], %struct.size8_pack4, i8, [3 x i8] }>
57%struct.size8_pack4 = type { i64 }
58
59; CHECK:  DW_TAG_structure_type
60; CHECK:      DW_AT_name {{.*}} "layout1"
61; CHECK:      DW_AT_byte_size {{.*}} (0x0c)
62; CHECK:      DW_TAG_member
63; CHECK:          DW_AT_name {{.*}} "l1_ofs0"
64; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x0)
65; CHECK:      DW_TAG_member
66; CHECK:          DW_AT_name {{.*}} "l1_ofs1"
67; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x1)
68; CHECK:      DW_TAG_member
69; CHECK:          DW_AT_name {{.*}} "l1_ofs9"
70; CHECK:          DW_AT_byte_size  {{.*}} (0x04)
71; CHECK:          DW_AT_bit_size   {{.*}} (0x01)
72; CHECK:          DW_AT_bit_offset {{.*}} (0x17)
73; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x8)
74
75; // ---------------------------------------------------------------------
76; // Explicitly packed.
77; // ---------------------------------------------------------------------
78; #pragma pack(1)
79; struct size8_pack1 {
80;   int i : 4;
81;   long long l : 60;
82; };
83; struct layout2 {
84;   char l2_ofs0;
85;   struct size8_pack1 l2_ofs1;
86;   int l2_ofs9 : 1;
87; } l2;
88; #pragma pack()
89
90@l0 = common global %struct.layout0 zeroinitializer, align 8, !dbg !0
91@l1 = common global %struct.layout1 zeroinitializer, align 4, !dbg !6
92; CHECK:  DW_TAG_structure_type
93; CHECK:      DW_AT_name {{.*}} "layout2"
94; CHECK:      DW_AT_byte_size {{.*}} (0x0a)
95; CHECK:      DW_TAG_member
96; CHECK:          DW_AT_name {{.*}} "l2_ofs0"
97; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x0)
98; CHECK:      DW_TAG_member
99; CHECK:          DW_AT_name {{.*}} "l2_ofs1"
100; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x1)
101; CHECK:      DW_TAG_member
102; CHECK:          DW_AT_name {{.*}} "l2_ofs9"
103; CHECK:          DW_AT_byte_size  {{.*}} (0x04)
104; CHECK:          DW_AT_bit_size   {{.*}} (0x01)
105; CHECK:          DW_AT_bit_offset {{.*}} (0x17)
106; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x8)
107
108; // ---------------------------------------------------------------------
109; // Explicitly packed with different alignment.
110; // ---------------------------------------------------------------------
111; #pragma pack(4)
112; struct size8_pack4 {
113;   int i : 4;
114;   long long l : 60;
115; };
116; struct layout3 {
117;   char l3_ofs0;
118;   struct size8_pack4 l3_ofs4;
119;   int l3_ofs12 : 1;
120; } l 3;
121; #pragma pack()
122
123@l2 = common global %struct.layout2 zeroinitializer, align 1, !dbg !17
124@l3 = common global %struct.layout3 zeroinitializer, align 4, !dbg !29
125; CHECK:  DW_TAG_structure_type
126; CHECK:      DW_AT_name {{.*}} "layout3"
127; CHECK:      DW_AT_byte_size {{.*}} (0x10)
128; CHECK:      DW_TAG_member
129; CHECK:          DW_AT_name {{.*}} "l3_ofs0"
130; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x0)
131; CHECK:      DW_TAG_member
132; CHECK:          DW_AT_name {{.*}} "l3_ofs4"
133; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x4)
134; CHECK:      DW_TAG_member
135; CHECK:          DW_AT_name {{.*}} "l3_ofs12"
136; CHECK:          DW_AT_byte_size  {{.*}} (0x04)
137; CHECK:          DW_AT_bit_size   {{.*}} (0x01)
138; CHECK:          DW_AT_bit_offset {{.*}} (0x1f)
139; CHECK:          DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0xc)
140
141!llvm.dbg.cu = !{!2}
142!llvm.module.flags = !{!49, !50}
143!llvm.ident = !{!51}
144
145!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
146!1 = !DIGlobalVariable(name: "l0", scope: !2, file: !8, line: 88, type: !40, isLocal: false, isDefinition: true)
147!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.7.0 (trunk 240791) (llvm/trunk 240790)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !5, imports: !4)
148!3 = !DIFile(filename: "/llvm/tools/clang/test/CodeGen/<stdin>", directory: "/llvm/_build.ninja.release")
149!4 = !{}
150!5 = !{!0, !6, !17, !29}
151!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
152!7 = !DIGlobalVariable(name: "l1", scope: !2, file: !8, line: 89, type: !9, isLocal: false, isDefinition: true)
153!8 = !DIFile(filename: "/llvm/tools/clang/test/CodeGen/debug-info-packed-struct.c", directory: "/llvm/_build.ninja.release")
154!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout1", file: !8, line: 34, size: 96, elements: !10)
155!10 = !{!11, !13, !15}
156!11 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs0", scope: !9, file: !8, line: 35, baseType: !12, size: 8)
157!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
158!13 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs1", scope: !9, file: !8, line: 36, baseType: !14, size: 64, offset: 8)
159!14 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_anon", file: !8, line: 30, size: 64, elements: !4)
160!15 = !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs9", scope: !9, file: !8, line: 37, baseType: !16, size: 1, offset: 72, flags: DIFlagBitField)
161!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
162!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression())
163!18 = !DIGlobalVariable(name: "l2", scope: !2, file: !8, line: 90, type: !19, isLocal: false, isDefinition: true)
164!19 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout2", file: !8, line: 54, size: 80, elements: !20)
165!20 = !{!21, !22, !28}
166!21 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs0", scope: !19, file: !8, line: 55, baseType: !12, size: 8)
167!22 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1", scope: !19, file: !8, line: 56, baseType: !23, size: 64, offset: 8)
168!23 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_pack1", file: !8, line: 50, size: 64, elements: !24)
169!24 = !{!25, !26}
170!25 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !23, file: !8, line: 51, baseType: !16, size: 4, flags: DIFlagBitField)
171!26 = !DIDerivedType(tag: DW_TAG_member, name: "l", scope: !23, file: !8, line: 52, baseType: !27, size: 60, offset: 4, flags: DIFlagBitField)
172!27 = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed)
173!28 = !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9", scope: !19, file: !8, line: 57, baseType: !16, size: 1, offset: 72, flags: DIFlagBitField)
174!29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression())
175!30 = !DIGlobalVariable(name: "l3", scope: !2, file: !8, line: 91, type: !31, isLocal: false, isDefinition: true)
176!31 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout3", file: !8, line: 76, size: 128, elements: !32)
177!32 = !{!33, !34, !39}
178!33 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs0", scope: !31, file: !8, line: 77, baseType: !12, size: 8)
179!34 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4", scope: !31, file: !8, line: 78, baseType: !35, size: 64, offset: 32)
180!35 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8_pack4", file: !8, line: 72, size: 64, elements: !36)
181!36 = !{!37, !38}
182!37 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !35, file: !8, line: 73, baseType: !16, size: 4, flags: DIFlagBitField)
183!38 = !DIDerivedType(tag: DW_TAG_member, name: "l", scope: !35, file: !8, line: 74, baseType: !27, size: 60, offset: 4, flags: DIFlagBitField)
184!39 = !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12", scope: !31, file: !8, line: 79, baseType: !16, size: 1, offset: 96, flags: DIFlagBitField)
185!40 = !DICompositeType(tag: DW_TAG_structure_type, name: "layout0", file: !8, line: 15, size: 192, elements: !41)
186!41 = !{!42, !43, !48}
187!42 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs0", scope: !40, file: !8, line: 16, baseType: !12, size: 8)
188!43 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs8", scope: !40, file: !8, line: 17, baseType: !44, size: 64, offset: 64)
189!44 = !DICompositeType(tag: DW_TAG_structure_type, name: "size8", file: !8, line: 11, size: 64, elements: !45)
190!45 = !{!46, !47}
191!46 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !44, file: !8, line: 12, baseType: !16, size: 4, flags: DIFlagBitField)
192!47 = !DIDerivedType(tag: DW_TAG_member, name: "l", scope: !44, file: !8, line: 13, baseType: !27, size: 60, offset: 4, flags: DIFlagBitField)
193!48 = !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs16", scope: !40, file: !8, line: 18, baseType: !16, size: 1, offset: 128, flags: DIFlagBitField)
194!49 = !{i32 2, !"Dwarf Version", i32 2}
195!50 = !{i32 2, !"Debug Info Version", i32 3}
196!51 = !{!"clang version 3.7.0 (trunk 240791) (llvm/trunk 240790)"}
197
198