17f78d471SEugene Leviant; Checks that DW_AT_decl_file attribute is correctly set for 27f78d471SEugene Leviant; template function declaration. When using full LTO we likely 37f78d471SEugene Leviant; end up having multiple CUs in a single DWARF file, and it is 47f78d471SEugene Leviant; possible that we add template function declaration DIE from 57f78d471SEugene Leviant; CU#1 to structure type DIE from CU#2. In such case we should 67f78d471SEugene Leviant; add source line attributes on behalf of CU#2, not CU#1 77f78d471SEugene Leviant 87f78d471SEugene Leviant; Example source code used to generate this sample (C++) 97f78d471SEugene Leviant; // File inc1.h 107f78d471SEugene Leviant; struct S { 117f78d471SEugene Leviant; template <typename T> static void tmpfn() {} 127f78d471SEugene Leviant; }; 137f78d471SEugene Leviant; 147f78d471SEugene Leviant; // File: inc2.h 157f78d471SEugene Leviant; extern int x; 167f78d471SEugene Leviant; int x; 177f78d471SEugene Leviant; 187f78d471SEugene Leviant; // File: foo.cpp 197f78d471SEugene Leviant; #include "inc1.h" 207f78d471SEugene Leviant; S s; 217f78d471SEugene Leviant; 227f78d471SEugene Leviant; // File: bar.cpp 237f78d471SEugene Leviant; #include "inc1.h" 247f78d471SEugene Leviant; #include "inc2.h" 257f78d471SEugene Leviant; void f3() { S::tmpfn<int>(); } 267f78d471SEugene Leviant 277f78d471SEugene Leviant; RUN: llc -filetype=obj %s -o %t 287f78d471SEugene Leviant; RUN: llvm-dwarfdump %t -o - | FileCheck %s 297f78d471SEugene Leviant 307f78d471SEugene Leviant; CHECK: DW_AT_linkage_name ("_ZN1S5tmpfnIiEEvv") 317f78d471SEugene Leviant; CHECK-NEXT: DW_AT_name ("tmpfn<int>") 327f78d471SEugene Leviant; CHECK-NEXT: DW_AT_decl_file ("{{.*}}inc1.h") 337f78d471SEugene Leviant; CHECK-NEXT: DW_AT_decl_line (2) 347f78d471SEugene Leviant 357f78d471SEugene Leviantsource_filename = "ld-temp.o" 367f78d471SEugene Levianttarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 377f78d471SEugene Levianttarget triple = "x86_64-unknown-linux-gnu" 387f78d471SEugene Leviant 397f78d471SEugene Leviant%struct.S = type { i8 } 407f78d471SEugene Leviant 417f78d471SEugene Leviant$_ZN1S5tmpfnIiEEvv = comdat any 427f78d471SEugene Leviant 437f78d471SEugene Leviant@s = dso_local global %struct.S zeroinitializer, align 1, !dbg !0 447f78d471SEugene Leviant@x = dso_local global i32 0, align 4, !dbg !8 457f78d471SEugene Leviant 467f78d471SEugene Leviant; Function Attrs: noinline optnone uwtable 477f78d471SEugene Leviantdefine dso_local void @_Z2f3v() !dbg !21 { 487f78d471SEugene Leviant call void @_ZN1S5tmpfnIiEEvv(), !dbg !24 497f78d471SEugene Leviant ret void, !dbg !25 507f78d471SEugene Leviant} 517f78d471SEugene Leviant 527f78d471SEugene Leviant; Function Attrs: noinline nounwind optnone uwtable 537f78d471SEugene Leviantdefine weak_odr dso_local void @_ZN1S5tmpfnIiEEvv() comdat align 2 !dbg !26 { 547f78d471SEugene Leviant ret void, !dbg !30 557f78d471SEugene Leviant} 567f78d471SEugene Leviant 577f78d471SEugene Leviant!llvm.dbg.cu = !{!2, !10} 587f78d471SEugene Leviant!llvm.ident = !{!15, !15} 597f78d471SEugene Leviant!llvm.module.flags = !{!16, !17, !18, !19, !20} 607f78d471SEugene Leviant 617f78d471SEugene Leviant!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 627f78d471SEugene Leviant!1 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true) 637f78d471SEugene Leviant!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 9.0.0 (trunk 354767)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None) 647f78d471SEugene Leviant!3 = !DIFile(filename: "foo.cpp", directory: "/home/evgeny/work/cpp_lexer/sample2") 657f78d471SEugene Leviant!4 = !{} 667f78d471SEugene Leviant!5 = !{!0} 67*994023a3SAaron Smith!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !7, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !4, identifier: "_ZTS1S") 687f78d471SEugene Leviant!7 = !DIFile(filename: "./inc1.h", directory: "/home/evgeny/work/cpp_lexer/sample2") 697f78d471SEugene Leviant!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression()) 707f78d471SEugene Leviant!9 = distinct !DIGlobalVariable(name: "x", scope: !10, file: !13, line: 2, type: !14, isLocal: false, isDefinition: true) 717f78d471SEugene Leviant!10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !11, producer: "clang version 9.0.0 (trunk 354767)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !12, nameTableKind: None) 727f78d471SEugene Leviant!11 = !DIFile(filename: "bar.cpp", directory: "/home/evgeny/work/cpp_lexer/sample2") 737f78d471SEugene Leviant!12 = !{!8} 747f78d471SEugene Leviant!13 = !DIFile(filename: "./inc2.h", directory: "/home/evgeny/work/cpp_lexer/sample2") 757f78d471SEugene Leviant!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 767f78d471SEugene Leviant!15 = !{!"clang version 9.0.0 (trunk 354767)"} 777f78d471SEugene Leviant!16 = !{i32 2, !"Dwarf Version", i32 4} 787f78d471SEugene Leviant!17 = !{i32 2, !"Debug Info Version", i32 3} 797f78d471SEugene Leviant!18 = !{i32 1, !"wchar_size", i32 4} 807f78d471SEugene Leviant!19 = !{i32 1, !"ThinLTO", i32 0} 817f78d471SEugene Leviant!20 = !{i32 1, !"EnableSplitLTOUnit", i32 0} 827f78d471SEugene Leviant!21 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !11, file: !11, line: 3, type: !22, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !4) 837f78d471SEugene Leviant!22 = !DISubroutineType(types: !23) 847f78d471SEugene Leviant!23 = !{null} 857f78d471SEugene Leviant!24 = !DILocation(line: 3, column: 13, scope: !21) 867f78d471SEugene Leviant!25 = !DILocation(line: 3, column: 30, scope: !21) 877f78d471SEugene Leviant!26 = distinct !DISubprogram(name: "tmpfn<int>", linkageName: "_ZN1S5tmpfnIiEEvv", scope: !6, file: !7, line: 2, type: !22, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !10, templateParams: !28, declaration: !27, retainedNodes: !4) 887f78d471SEugene Leviant!27 = !DISubprogram(name: "tmpfn<int>", linkageName: "_ZN1S5tmpfnIiEEvv", scope: !6, file: !7, line: 2, type: !22, scopeLine: 2, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: 0, templateParams: !28) 897f78d471SEugene Leviant!28 = !{!29} 907f78d471SEugene Leviant!29 = !DITemplateTypeParameter(name: "T", type: !14) 917f78d471SEugene Leviant!30 = !DILocation(line: 2, column: 46, scope: !26) 927f78d471SEugene Leviant 93