xref: /llvm-project/llvm/test/DebugInfo/X86/debug-types-dwarf64.ll (revision 18f23b3ecc6d0cec31c655b7ae9054cf0edf630e)
1; This checks that .debug_types can be generated in the DWARF64 format.
2
3; RUN: llc -mtriple=x86_64 -dwarf-version=4 -dwarf64 -generate-type-units -filetype=obj %s -o %t
4; RUN: llvm-dwarfdump -debug-types -v %t | FileCheck %s
5
6; CHECK:      .debug_types contents:
7; CHECK-NEXT: Type Unit: {{.+}}, format = DWARF64, {{.+}}, type_offset = 0x[[OFF:.+]] (next unit at
8
9; CHECK:      0x00000027:     DW_TAG_type_unit
10
11; CHECK:      0x0000[[OFF]]:    DW_TAG_structure_type
12; CHECK-NEXT:                     DW_AT_calling_convention
13; CHECK-NEXT:                     DW_AT_name [DW_FORM_strp] ({{.+}} = "Foo")
14
15; CHECK:      0x{{.+}}:           DW_TAG_member
16; CHECK-NEXT:                       DW_AT_name [DW_FORM_strp] ({{.+}} = "bar")
17; CHECK-NEXT:                       DW_AT_type [DW_FORM_ref4] (cu + 0x[[BTOFF:.+]] => {0x0000[[BTOFF]]} "int")
18
19; CHECK:      0x{{.+}}:           NULL
20
21; CHECK:      0x0000[[BTOFF]]:  DW_TAG_base_type [4]
22; CHECK-NEXT:                     DW_AT_name [DW_FORM_strp] ({{.+}} = "int")
23
24; CHECK:      0x{{.+}}:         NULL
25
26; IR generated and reduced from:
27; $ cat foo.cc
28; struct Foo { int bar; };
29; Foo foo;
30; $ clang -g -S -emit-llvm foo.cc -o foo.ll
31
32target triple = "x86_64-unknown-linux-gnu"
33
34%struct.Foo = type { i32 }
35
36@foo = dso_local global %struct.Foo zeroinitializer, align 4, !dbg !0
37
38!llvm.dbg.cu = !{!2}
39!llvm.module.flags = !{!10, !11, !12}
40!llvm.ident = !{!13}
41
42!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
43!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
44!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
45!3 = !DIFile(filename: "foo.cc", directory: "/tmp")
46!4 = !{}
47!5 = !{!0}
48!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 1, size: 32, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTS3Foo")
49!7 = !{!8}
50!8 = !DIDerivedType(tag: DW_TAG_member, name: "bar", scope: !6, file: !3, line: 1, baseType: !9, size: 32)
51!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
52!10 = !{i32 7, !"Dwarf Version", i32 4}
53!11 = !{i32 2, !"Debug Info Version", i32 3}
54!12 = !{i32 1, !"wchar_size", i32 4}
55!13 = !{!"clang version 12.0.0"}
56