blob: 500898dd2816e41810df8c5255a11bfafaf1826a [file] [log] [blame]
Benjamin Kramerd25187f2015-06-27 21:11:43 +00001; RUN: llc -mtriple x86_64-apple-macosx -O0 -filetype=obj -o %t_le.o %s
Adrian Prantl16aa4cf2017-09-11 23:05:20 +00002; RUN: llvm-dwarfdump -v -debug-info %t_le.o | FileCheck %s
Adrian Prantl09086d52015-06-25 23:38:22 +00003
4; Produced at -O0 from:
5; struct bitfield {
6; int a : 2;
7; int b : 32;
8; int c : 1;
9; int d : 28;
10; };
11; struct bitfield b;
12
13; Note that DWARF 2 counts bit offsets backwards from the high end of
14; the storage unit to the high end of the bit field.
15
16; CHECK: DW_TAG_member
17; CHECK-NEXT: DW_AT_name{{.*}}"a"
18; CHECK-NOT: DW_TAG_member
19; CHECK: DW_AT_byte_size {{.*}} (0x04)
20; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x02)
21; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x1e)
Reid Klecknera0587362017-08-29 21:41:21 +000022; CHECK-NEXT: DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x0)
Adrian Prantl09086d52015-06-25 23:38:22 +000023
24; CHECK: DW_TAG_member
25; CHECK-NEXT: DW_AT_name{{.*}}"b"
26; CHECK-NOT: DW_TAG_member
Reid Klecknera0587362017-08-29 21:41:21 +000027; CHECK: DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x4)
Adrian Prantl09086d52015-06-25 23:38:22 +000028
29; CHECK: DW_TAG_member
30; CHECK-NEXT: DW_AT_name{{.*}}"c"
31; CHECK-NOT: DW_TAG_member
32; CHECK: DW_AT_byte_size {{.*}} (0x04)
33; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x01)
34; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x1f)
Reid Klecknera0587362017-08-29 21:41:21 +000035; CHECK: DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x8)
Adrian Prantl09086d52015-06-25 23:38:22 +000036
37; CHECK: DW_TAG_member
38; CHECK-NEXT: DW_AT_name{{.*}}"d"
39; CHECK-NOT: DW_TAG_member
40; CHECK: DW_AT_byte_size {{.*}} (0x04)
41; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x1c)
42; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x03)
Reid Klecknera0587362017-08-29 21:41:21 +000043; CHECK-NEXT: DW_AT_data_member_location {{.*}} (DW_OP_plus_uconst 0x8)
Adrian Prantl09086d52015-06-25 23:38:22 +000044
45; ModuleID = 'bitfields.c'
Adrian Prantl1eadba12016-12-22 00:45:21 +000046source_filename = "test/DebugInfo/X86/bitfields.ll"
Adrian Prantl09086d52015-06-25 23:38:22 +000047target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
48target triple = "x86_64-apple-macosx"
49
50%struct.bitfield = type <{ i8, [3 x i8], i64 }>
51
Adrian Prantl1eadba12016-12-22 00:45:21 +000052@b = common global %struct.bitfield zeroinitializer, align 4, !dbg !0
Adrian Prantl09086d52015-06-25 23:38:22 +000053
Adrian Prantl1eadba12016-12-22 00:45:21 +000054!llvm.dbg.cu = !{!2}
Adrian Prantl09086d52015-06-25 23:38:22 +000055!llvm.module.flags = !{!13, !14, !15}
56!llvm.ident = !{!16}
57
Adrian Prantl05782212017-08-30 18:06:51 +000058!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
Adrian Prantl1eadba12016-12-22 00:45:21 +000059!1 = !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true)
60!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.7.0 (trunk 240548) (llvm/trunk 240554)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !5, imports: !4)
61!3 = !DIFile(filename: "bitfields.c", directory: "/")
62!4 = !{}
63!5 = !{!0}
64!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "bitfield", file: !3, line: 1, size: 96, elements: !7)
Adrian Prantl09086d52015-06-25 23:38:22 +000065!7 = !{!8, !10, !11, !12}
Adrian Prantl1eadba12016-12-22 00:45:21 +000066!8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !3, line: 2, baseType: !9, size: 2)
Victor Leschuk2ede1262016-10-20 00:13:12 +000067!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
Adrian Prantl1eadba12016-12-22 00:45:21 +000068!10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !3, line: 3, baseType: !9, size: 32, offset: 32)
69!11 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !6, file: !3, line: 4, baseType: !9, size: 1, offset: 64)
70!12 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !3, line: 5, baseType: !9, size: 28, offset: 65)
Adrian Prantl09086d52015-06-25 23:38:22 +000071!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)"}
Adrian Prantl1eadba12016-12-22 00:45:21 +000075