xref: /llvm-project/llvm/test/DebugInfo/X86/bitfields-dwarf4.ll (revision dd881c9dbf5d940eedff7d23395141454c5a26b9)
1; RUN: llc -mtriple x86_64-apple-macosx -O0 -filetype=obj -o - %s \
2; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s
3; RUN: llc -mtriple x86_64-gnu-linux -O0 -filetype=obj -o - %s \
4; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s
5; RUN: llc -mtriple x86_64-gnu-linux -O0 -debugger-tune=gdb -filetype=obj -o - %s \
6; RUN: | llvm-dwarfdump -v -debug-info - | FileCheck %s
7;
8; Generated from:
9;   #include <stdint.h>
10;   #pragma pack(1)
11;      struct PackedBits
12;      {
13;        char a;
14;        uint32_t b : 5,
15;        c : 27
16;      } s;
17;   #pragma pack()
18
19source_filename = "bitfield.c"
20target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
21target triple = "x86_64-apple-macosx"
22
23%struct.PackedBits = type <{ i8, i32 }>
24
25@s = common global %struct.PackedBits zeroinitializer, align 1, !dbg !0
26
27!llvm.dbg.cu = !{!2}
28!llvm.module.flags = !{!15, !16, !17}
29!llvm.ident = !{!18}
30
31!0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
32!1 = !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true)
33!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.9.0 (trunk 267633)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
34!3 = !DIFile(filename: "bitfield.c", directory: "/Volumes/Data/llvm")
35!4 = !{}
36!5 = !{!0}
37!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "PackedBits", file: !3, line: 3, size: 40, elements: !7)
38!7 = !{!8, !10, !14}
39!8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !3, line: 5, baseType: !9, size: 8)
40; CHECK: DW_TAG_member
41; CHECK-NEXT: DW_AT_name{{.*}}"a"
42; CHECK-NOT:  DW_TAG
43; CHECK-NOT:  DW_AT_bit_offset
44; CHECK-NOT:  DW_AT_data_bit_offset
45; CHECK:      DW_AT_data_member_location [DW_FORM_data1]	(0x00)
46!9 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
47!10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !3, line: 6, baseType: !11, size: 5, offset: 8, flags: DIFlagBitField)
48!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !12, line: 183, baseType: !13)
49!12 = !DIFile(filename: "/Volumes/Data/llvm/_build.ninja.release/bin/../lib/clang/3.9.0/include/stdint.h", directory: "/Volumes/Data/llvm")
50!13 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
51; CHECK: DW_TAG_member
52; CHECK-NEXT: DW_AT_name{{.*}}"b"
53; CHECK-NOT:  DW_TAG
54; CHECK-NOT:  DW_AT_bit_offset
55; CHECK-NOT:  DW_AT_byte_size
56; CHECK:      DW_AT_bit_size             [DW_FORM_data1]	(0x05)
57; CHECK-NOT:  DW_AT_byte_size
58; CHECK-NEXT: DW_AT_data_bit_offset      [DW_FORM_data1]	(0x08)
59; CHECK-NOT:  DW_AT_data_member_location
60!14 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !6, file: !3, line: 7, baseType: !11, size: 27, offset: 13, flags: DIFlagBitField)
61!15 = !{i32 2, !"Dwarf Version", i32 4}
62!16 = !{i32 2, !"Debug Info Version", i32 3}
63!17 = !{i32 1, !"PIC Level", i32 2}
64; CHECK: DW_TAG_member
65; CHECK-NEXT: DW_AT_name{{.*}}"c"
66; CHECK-NOT:  DW_TAG
67; CHECK-NOT:  DW_AT_bit_offset
68; CHECK-NOT:  DW_AT_byte_size
69; CHECK:      DW_AT_bit_size             [DW_FORM_data1]	(0x1b)
70; CHECK-NEXT: DW_AT_data_bit_offset      [DW_FORM_data1]	(0x0d)
71; CHECK-NOT:  DW_AT_data_member_location
72; CHECK: DW_TAG
73!18 = !{!"clang version 3.9.0 (trunk 267633)"}
74
75