1 ; Check that debug info for nested types is generated correctly.
2 ; With full LTO we may end up in several compilation units sharing
3 ; single object file. In such case it's possible that nested type DIE
4 ; is created on behalf of CU#1 and parent type DIE is created on
5 ; behalf of CU#2. In such case we may end up with broken source line
6 ; attributes, because file ids don't coincide in CU#1 and CU#2
8 ; Sources used to generate this sample (C++)
12 ; typedef int NestedTypedef;
28 ; S::NestedTypedef n2;
31 ; RUN: llc -filetype=obj %s -o %t
32 ; RUN: llvm-dwarfdump %t | FileCheck %s
34 ; CHECK: DW_AT_name ("Nested")
35 ; CHECK-NEXT: DW_AT_byte_size (0x01)
36 ; CHECK-NEXT: DW_AT_decl_file ("{{.*}}inc1.h")
37 ; CHECK-NEXT: DW_AT_decl_line (2)
39 ; CHECK: DW_AT_name ("NestedTypedef")
40 ; CHECK-NEXT: DW_AT_decl_file ("{{.*}}inc1.h")
41 ; CHECK-NEXT: DW_AT_decl_line (3)
43 source_filename = "llvm-link"
44 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45 target triple = "x86_64-unknown-linux-gnu"
47 %struct.S = type { i8 }
49 @s = dso_local global %struct.S zeroinitializer, align 1, !dbg !0
50 @x = dso_local global i32 0, align 4, !dbg !8
52 ; Function Attrs: noinline nounwind optnone uwtable
53 define dso_local void @_Z2f3v() !dbg !19 {
55 %n = alloca %struct.S, align 1
56 %n2 = alloca i32, align 4
57 call void @llvm.dbg.declare(metadata %struct.S* %n, metadata !22, metadata !DIExpression()), !dbg !24
58 call void @llvm.dbg.declare(metadata i32* %n2, metadata !25, metadata !DIExpression()), !dbg !27
62 ; Function Attrs: nounwind readnone speculatable
63 declare void @llvm.dbg.declare(metadata, metadata, metadata)
65 !llvm.dbg.cu = !{!2, !10}
66 !llvm.ident = !{!15, !15}
67 !llvm.module.flags = !{!16, !17, !18}
69 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
70 !1 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
71 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 9.0.0 (trunk 354767)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
72 !3 = !DIFile(filename: "foo.cpp", directory: "/home/evgeny/work/cpp_lexer/sample3")
75 !6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !7, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !4, identifier: "_ZTS1S")
76 !7 = !DIFile(filename: "./inc1.h", directory: "/home/evgeny/work/cpp_lexer/sample3")
77 !8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression())
78 !9 = distinct !DIGlobalVariable(name: "x", scope: !10, file: !13, line: 2, type: !14, isLocal: false, isDefinition: true)
79 !10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !11, producer: "clang version 9.0.0 (trunk 354767)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !12, nameTableKind: None)
80 !11 = !DIFile(filename: "bar.cpp", directory: "/home/evgeny/work/cpp_lexer/sample3")
82 !13 = !DIFile(filename: "./inc2.h", directory: "/home/evgeny/work/cpp_lexer/sample3")
83 !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
84 !15 = !{!"clang version 9.0.0 (trunk 354767)"}
85 !16 = !{i32 2, !"Dwarf Version", i32 4}
86 !17 = !{i32 2, !"Debug Info Version", i32 3}
87 !18 = !{i32 1, !"wchar_size", i32 4}
88 !19 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !11, file: !11, line: 3, type: !20, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !4)
89 !20 = !DISubroutineType(types: !21)
91 !22 = !DILocalVariable(name: "n", scope: !19, file: !11, line: 4, type: !23)
92 !23 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", scope: !6, file: !7, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !4, identifier: "_ZTSN1S6NestedE")
93 !24 = !DILocation(line: 4, column: 13, scope: !19)
94 !25 = !DILocalVariable(name: "n2", scope: !19, file: !11, line: 5, type: !26)
95 !26 = !DIDerivedType(tag: DW_TAG_typedef, name: "NestedTypedef", scope: !6, file: !7, line: 3, baseType: !14)
96 !27 = !DILocation(line: 5, column: 20, scope: !19)
97 !28 = !DILocation(line: 6, column: 1, scope: !19)