1 ; RUN: llc < %s -filetype=obj | llvm-dwarfdump -v - --debug-info | FileCheck %s
3 ; IR module created as follows:
4 ; clang -emit-llvm -S -O2 foo.cpp -o foo.ll -g
5 ; clang -emit-llvm -S -O2 bar.cpp -o bar.ll -gmlt
6 ; llvm-link foo.ll bar.ll -S -o linked.ll
7 ; opt -std-link-opts linked.ll -S -o opt.ll
10 ; void foo(int param) {
19 ; The point is that bar() is compiled -gmlt and calls foo() with a constant 0.
20 ; foo() is compiled -g and gets inlined into bar(); foo's body is then
21 ; optimized away, leaving only a dbg.value call describing the inlined copy
22 ; of 'param', which should be benign.
23 ; That is, the compile-unit for bar.cpp should have nothing in it.
26 ; foo.cpp's unit comes first; skip past it, second unit should be empty.
27 ; CHECK: DW_TAG_compile_unit
28 ; CHECK-NOT: {{DW_TAG|NULL}}
29 ; CHECK: DW_AT_name {{.*}} "foo.cpp"
30 ; CHECK: DW_TAG_compile_unit
33 ; ModuleID = 'linked.ll'
34 source_filename = "llvm-link"
35 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
36 target triple = "x86_64-unknown-linux-gnu"
38 ; Function Attrs: uwtable
39 define void @_Z3fooi(i32 %param) local_unnamed_addr #0 !dbg !8 {
41 tail call void @llvm.dbg.value(metadata i32 %param, metadata !13, metadata !14), !dbg !15
42 %tobool = icmp eq i32 %param, 0, !dbg !16
43 br i1 %tobool, label %if.end, label %if.then, !dbg !18
45 if.then: ; preds = %entry
46 tail call void @_Z1fv(), !dbg !19
47 br label %if.end, !dbg !19
49 if.end: ; preds = %if.then, %entry
53 ; Function Attrs: nounwind readnone
54 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
56 declare void @_Z1fv() local_unnamed_addr #2
58 ; Function Attrs: nounwind readnone uwtable
59 define void @_Z3barv() local_unnamed_addr #3 !dbg !22 {
61 tail call void @llvm.dbg.value(metadata i32 0, metadata !13, metadata !14), !dbg !24
65 attributes #0 = { uwtable }
66 attributes #1 = { nounwind readnone }
67 attributes #2 = { nounwind }
68 attributes #3 = { nounwind readnone uwtable }
70 !llvm.dbg.cu = !{!0, !3}
71 !llvm.ident = !{!5, !5}
72 !llvm.module.flags = !{!6, !7}
74 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 293745)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
75 !1 = !DIFile(filename: "foo.cpp", directory: "/home/probinson/projects/scratch/pr31437")
77 !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 5.0.0 (trunk 293745)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
78 !4 = !DIFile(filename: "bar.cpp", directory: "/home/probinson/projects/scratch/pr31437")
79 !5 = !{!"clang version 5.0.0 (trunk 293745)"}
80 !6 = !{i32 2, !"Dwarf Version", i32 4}
81 !7 = !{i32 2, !"Debug Info Version", i32 3}
82 !8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
83 !9 = !DISubroutineType(types: !10)
85 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
87 !13 = !DILocalVariable(name: "param", arg: 1, scope: !8, file: !1, line: 2, type: !11)
89 !15 = !DILocation(line: 2, column: 14, scope: !8)
90 !16 = !DILocation(line: 3, column: 7, scope: !17)
91 !17 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7)
92 !18 = !DILocation(line: 3, column: 7, scope: !8)
93 !19 = !DILocation(line: 3, column: 14, scope: !20)
94 !20 = !DILexicalBlockFile(scope: !17, file: !1, discriminator: 1)
95 !21 = !DILocation(line: 4, column: 1, scope: !8)
96 !22 = distinct !DISubprogram(name: "bar", scope: !4, file: !4, line: 2, type: !23, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !3, retainedNodes: !2)
97 !23 = !DISubroutineType(types: !2)
98 !24 = !DILocation(line: 2, column: 14, scope: !8, inlinedAt: !25)
99 !25 = distinct !DILocation(line: 3, column: 3, scope: !22)
100 !26 = !DILocation(line: 4, column: 1, scope: !22)