1; RUN: llc -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu < %s \
2; RUN:     | llvm-dwarfdump -debug-info -debug-types - | FileCheck %s
3
4; Test that a type unit referencing a non-type unit (in this case, it's
5; bordering on an ODR violation - a type with linkage references a type without
6; linkage, so there's no way for the first type to be defined in more than one
7; translation unit, so there's no need for it to be in a type unit - but this
8; is quirky/rare and an easy way to test a broader issue). The type unit should
9; not end up with a whole definition of the referenced type - instead it should
10; have a declaration of the type, while the definition remains in the primary
11; CU.
12; (again, arguably in this instance - since the type is only referenced once, it
13; could go in the TU only - but that requires tracking usage & then deciding
14; where to put types, which isn't worthwhile right now)
15
16; CHECK: Type Unit:
17
18; CHECK: DW_TAG_structure_type
19; CHECK-NEXT: DW_AT_name {{.*}}"bar"
20
21; CHECK: DW_TAG_namespace
22; CHECK-NOT: {{DW_AT_name|DW_TAG}}
23; CHECK: DW_TAG_structure_type
24; CHECK-NEXT: DW_AT_declaration
25; CHECK-NEXT: DW_AT_name {{.*}}"foo"
26
27; CHECK: Compile Unit:
28
29; CHECK: DW_TAG_structure_type
30; CHECK-NEXT: DW_AT_declaration
31; CHECK-NEXT: DW_AT_signature
32
33; CHECK: DW_TAG_namespace
34; CHECK-NOT: {{DW_AT_name|DW_TAG}}
35; CHECK: DW_TAG_structure_type
36; CHECK-NEXT: DW_AT_name {{.*}}"foo"
37; CHECK-NEXT: DW_AT_byte_size
38
39%struct.bar = type { %"struct.(anonymous namespace)::foo" }
40%"struct.(anonymous namespace)::foo" = type { i8 }
41
42@b = global %struct.bar zeroinitializer, align 1, !dbg !0
43
44!llvm.dbg.cu = !{!2}
45!llvm.module.flags = !{!11, !13}
46!llvm.ident = !{!12}
47
48!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
49!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true)
50!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 5.0.0 (trunk 294954) (llvm/trunk 294959)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "tu-to-non-tu.dwo", emissionKind: FullDebug, enums: !4, globals: !5)
51!3 = !DIFile(filename: "tu.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
52!4 = !{}
53!5 = !{!0}
54!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "bar", file: !3, line: 5, size: 8, elements: !7, identifier: "_ZTS3bar")
55!7 = !{!8}
56!8 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !6, file: !3, line: 6, baseType: !9, size: 8)
57!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !10, file: !3, line: 2, size: 8, elements: !4)
58!10 = !DINamespace(scope: null)
59!11 = !{i32 2, !"Debug Info Version", i32 3}
60!12 = !{!"clang version 5.0.0 (trunk 294954) (llvm/trunk 294959)"}
61!13 = !{i32 2, !"Dwarf Version", i32 5}
62