1; RUN: llc -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu -split-dwarf-file=x.dwo < %s \ 2; RUN: | llvm-dwarfdump -debug-info -debug-types - \ 3; RUN: | FileCheck --implicit-check-not=Unit --implicit-check-not=contents --implicit-check-not=declaration %s 4 5; Test that an address-using-with-Split-DWARF type unit that references a 6; non-type unit is handled correctly. A NonTypeUnitContext is used to insulate 7; the type construction from being discarded when the prior/outer type has to be 8; discarded due to finding it used an address & so can't be type united under 9; Split DWARF. 10 11; The intermediate types tu and t2 are here just to test a bit more 12; thoroughly/broadly. They also demonstrate one slight limitation/sub-optimality 13; since 't2' isn't put in a type unit. 14 15 16; extern int foo; 17; namespace { 18; struct t1 { 19; }; 20; } 21; template <int *> struct t2 { 22; t1 v1; 23; }; 24; struct t3 { 25; t2<&foo> v1; 26; }; 27; t3 v1; 28 29; CHECK: .debug_info contents: 30; CHECK: Compile Unit: 31 32; CHECK: .debug_info.dwo contents: 33; CHECK: Compile Unit: 34 35; FIXME: In theory "t3" could be in a type unit - but at the moment, because it 36; references t2, which needs an address, t3 gets non-type-united. 37; But the same doesn't happen if t3 referenced an anonymous namespace type. 38 39; CHECK: DW_TAG_structure_type 40; CHECK: DW_AT_name ("t3") 41; CHECK: DW_TAG_member 42; CHECK: DW_AT_type {{.*}} "t2<&foo>" 43; CHECK: DW_TAG_namespace 44; CHECK: [[T1:0x[0-9a-f]*]]: DW_TAG_structure_type 45; CHECK: DW_AT_name ("t1") 46; CHECK: DW_TAG_structure_type 47; CHECK: DW_AT_name ("t2<&foo>") 48; CHECK: DW_TAG_member 49; CHECK: DW_AT_name ("v1") 50; CHECK: DW_AT_type ([[T1]] "t1") 51 52; CHECK: .debug_types contents: 53 54; CHECK-NOT: .debug_types.dwo contents: 55 56 57%struct.t3 = type { %struct.t2 } 58%struct.t2 = type { %"struct.(anonymous namespace)::t1" } 59%"struct.(anonymous namespace)::t1" = type { i8 } 60 61@v1 = dso_local global %struct.t3 zeroinitializer, align 1, !dbg !0 62@foo = external dso_local global i32, align 4 63 64!llvm.dbg.cu = !{!2} 65!llvm.module.flags = !{!18, !19, !20} 66!llvm.ident = !{!21} 67 68!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 69!1 = distinct !DIGlobalVariable(name: "v1", scope: !2, file: !3, line: 16, type: !6, isLocal: false, isDefinition: true) 70!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 12.0.0 (git@github.com:llvm/llvm-project.git be646ae2865371c7a4966797e88f355de5653e04)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "test.dwo", emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: GNU) 71!3 = !DIFile(filename: "test.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch") 72!4 = !{} 73!5 = !{!0} 74!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t3", file: !3, line: 12, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTS2t3") 75!7 = !{!8} 76!8 = !DIDerivedType(tag: DW_TAG_member, name: "v1", scope: !6, file: !3, line: 13, baseType: !9, size: 8) 77!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t2<&foo>", file: !3, line: 8, size: 8, flags: DIFlagTypePassByValue, elements: !10, templateParams: !14, identifier: "_ZTS2t2IXadL_Z3fooEEE") 78!10 = !{!11} 79!11 = !DIDerivedType(tag: DW_TAG_member, name: "v1", scope: !9, file: !3, line: 9, baseType: !12, size: 8) 80!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", scope: !13, file: !3, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !4) 81!13 = !DINamespace(scope: null) 82!14 = !{!15} 83!15 = !DITemplateValueParameter(type: !16, value: i32* @foo) 84!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64) 85!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 86!18 = !{i32 7, !"Dwarf Version", i32 4} 87!19 = !{i32 2, !"Debug Info Version", i32 3} 88!20 = !{i32 1, !"wchar_size", i32 4} 89!21 = !{!"clang version 12.0.0 (git@github.com:llvm/llvm-project.git be646ae2865371c7a4966797e88f355de5653e04)"} 90