1; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-line - | FileCheck %s
2; RUN: %llc_dwarf < %s -filetype=asm | FileCheck --check-prefix=ASM %s
3
4; If multiple line tables are emitted, one per CU, those line tables can
5; unambiguously rely on the comp_dir of their owning CU and use directory '0'
6; to refer to it.
7
8; CHECK: .debug_line contents:
9; CHECK-NEXT: debug_line[{{.*}}]
10; CHECK-NEXT: Line table prologue:
11; CHECK-NOT: include_directories
12; CHECK: file_names[   1]
13; CHECK: name: "a.cpp"
14; CHECK-NEXT: dir_index: 0
15; CHECK-NOT: file_names
16
17; CHECK: debug_line[{{.*}}]
18; CHECK-NEXT: Line table prologue:
19; CHECK-NOT: include_directories
20; CHECK: file_names[   1]
21; CHECK: name: "b.cpp"
22; CHECK-NEXT: dir_index: 0
23; CHECK-NOT: file_names
24
25; However, if a single line table is emitted and shared between CUs, the
26; comp_dir is ambiguous and relying on it would lead to different path
27; interpretations depending on which CU lead to the table - so ensure that
28; full paths are always emitted in this case, never comp_dir relative.
29
30; ASM: .file   1 "/tmp/dbginfo/a" "a.cpp"
31; ASM: .file   2 "/tmp/dbginfo/b" "b.cpp"
32
33; Generated from the following source compiled to bitcode from within their
34; respective directories (with debug info) and linked together with llvm-link
35
36; a/a.cpp
37; void func() {
38; }
39
40; b/b.cpp
41; void func();
42; int main() {
43;   func();
44; }
45
46; Function Attrs: nounwind uwtable
47define void @_Z4funcv() #0 !dbg !4 {
48entry:
49  ret void, !dbg !19
50}
51
52; Function Attrs: uwtable
53define i32 @main() #1 !dbg !11 {
54entry:
55  call void @_Z4funcv(), !dbg !20
56  ret i32 0, !dbg !21
57}
58
59attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
60attributes #1 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
61
62!llvm.dbg.cu = !{!0, !8}
63!llvm.module.flags = !{!16, !17}
64!llvm.ident = !{!18, !18}
65
66!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
67!1 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo/a")
68!2 = !{}
69!4 = distinct !DISubprogram(name: "func", linkageName: "_Z4funcv", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
70!5 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo/a")
71!6 = !DISubroutineType(types: !7)
72!7 = !{null}
73!8 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !9, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
74!9 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo/b")
75!11 = distinct !DISubprogram(name: "main", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !8, scopeLine: 2, file: !9, scope: !12, type: !13, retainedNodes: !2)
76!12 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo/b")
77!13 = !DISubroutineType(types: !14)
78!14 = !{!15}
79!15 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
80!16 = !{i32 2, !"Dwarf Version", i32 4}
81!17 = !{i32 1, !"Debug Info Version", i32 3}
82!18 = !{!"clang version 3.5.0 "}
83!19 = !DILocation(line: 2, scope: !4)
84!20 = !DILocation(line: 3, scope: !11)
85!21 = !DILocation(line: 4, scope: !11)
86
87