1*0a6a1f1dSLionel Sambuc; REQUIRES: object-emission
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4*0a6a1f1dSLionel Sambuc
5*0a6a1f1dSLionel Sambuc; Built from source:
6*0a6a1f1dSLionel Sambuc; $ clang++ a.cpp b.cpp -g -c -emit-llvm
7*0a6a1f1dSLionel Sambuc; $ llvm-link a.bc b.bc -o ab.bc
8*0a6a1f1dSLionel Sambuc; $ cat a.cpp
9*0a6a1f1dSLionel Sambuc; # 1 "func.h"
10*0a6a1f1dSLionel Sambuc; inline int func(int i) {
11*0a6a1f1dSLionel Sambuc;   return i * 2;
12*0a6a1f1dSLionel Sambuc; }
13*0a6a1f1dSLionel Sambuc; int (*x)(int) = &func;
14*0a6a1f1dSLionel Sambuc; $ cat b.cpp
15*0a6a1f1dSLionel Sambuc; # 1 "func.h"
16*0a6a1f1dSLionel Sambuc; inline int func(int i) {
17*0a6a1f1dSLionel Sambuc;   return i * 2;
18*0a6a1f1dSLionel Sambuc; }
19*0a6a1f1dSLionel Sambuc; int (*y)(int) = &func;
20*0a6a1f1dSLionel Sambuc
21*0a6a1f1dSLionel Sambuc; CHECK: DW_TAG_compile_unit
22*0a6a1f1dSLionel Sambuc; CHECK:   DW_TAG_subprogram
23*0a6a1f1dSLionel Sambuc; CHECK-NOT: DW_TAG
24*0a6a1f1dSLionel Sambuc; CHECK:     DW_AT_name {{.*}} "func"
25*0a6a1f1dSLionel Sambuc; CHECK: DW_TAG_compile_unit
26*0a6a1f1dSLionel Sambuc; CHECK-NOT: DW_TAG_subprogram
27*0a6a1f1dSLionel Sambuc
28*0a6a1f1dSLionel Sambuc@x = global i32 (i32)* @_Z4funci, align 8
29*0a6a1f1dSLionel Sambuc@y = global i32 (i32)* @_Z4funci, align 8
30*0a6a1f1dSLionel Sambuc
31*0a6a1f1dSLionel Sambuc; Function Attrs: inlinehint nounwind uwtable
32*0a6a1f1dSLionel Sambucdefine linkonce_odr i32 @_Z4funci(i32 %i) #0 {
33*0a6a1f1dSLionel Sambuc  %1 = alloca i32, align 4
34*0a6a1f1dSLionel Sambuc  store i32 %i, i32* %1, align 4
35*0a6a1f1dSLionel Sambuc  call void @llvm.dbg.declare(metadata i32* %1, metadata !20, metadata !{!"0x102"}), !dbg !21
36*0a6a1f1dSLionel Sambuc  %2 = load i32* %1, align 4, !dbg !22
37*0a6a1f1dSLionel Sambuc  %3 = mul nsw i32 %2, 2, !dbg !22
38*0a6a1f1dSLionel Sambuc  ret i32 %3, !dbg !22
39*0a6a1f1dSLionel Sambuc}
40*0a6a1f1dSLionel Sambuc
41*0a6a1f1dSLionel Sambuc; Function Attrs: nounwind readnone
42*0a6a1f1dSLionel Sambucdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
43*0a6a1f1dSLionel Sambuc
44*0a6a1f1dSLionel Sambucattributes #0 = { inlinehint nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
45*0a6a1f1dSLionel Sambucattributes #1 = { nounwind readnone }
46*0a6a1f1dSLionel Sambuc
47*0a6a1f1dSLionel Sambuc!llvm.dbg.cu = !{!0, !13}
48*0a6a1f1dSLionel Sambuc!llvm.module.flags = !{!17, !18}
49*0a6a1f1dSLionel Sambuc!llvm.ident = !{!19, !19}
50*0a6a1f1dSLionel Sambuc
51*0a6a1f1dSLionel Sambuc!0 = !{!"0x11\004\00clang version 3.5.0 \000\00\000\00\001", !1, !2, !2, !3, !10, !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/a.cpp] [DW_LANG_C_plus_plus]
52*0a6a1f1dSLionel Sambuc!1 = !{!"a.cpp", !"/tmp/dbginfo"}
53*0a6a1f1dSLionel Sambuc!2 = !{}
54*0a6a1f1dSLionel Sambuc!3 = !{!4}
55*0a6a1f1dSLionel Sambuc!4 = !{!"0x2e\00func\00func\00_Z4funci\001\000\001\000\006\00256\000\001", !5, !6, !7, null, i32 (i32)* @_Z4funci, null, null, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [func]
56*0a6a1f1dSLionel Sambuc!5 = !{!"func.h", !"/tmp/dbginfo"}
57*0a6a1f1dSLionel Sambuc!6 = !{!"0x29", !5}          ; [ DW_TAG_file_type ] [/tmp/dbginfo/func.h]
58*0a6a1f1dSLionel Sambuc!7 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !8, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
59*0a6a1f1dSLionel Sambuc!8 = !{!9, !9}
60*0a6a1f1dSLionel Sambuc!9 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
61*0a6a1f1dSLionel Sambuc!10 = !{!11}
62*0a6a1f1dSLionel Sambuc!11 = !{!"0x34\00x\00x\00\004\000\001", null, !6, !12, i32 (i32)** @x, null} ; [ DW_TAG_variable ] [x] [line 4] [def]
63*0a6a1f1dSLionel Sambuc!12 = !{!"0xf\00\000\0064\0064\000\000", null, null, !7} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
64*0a6a1f1dSLionel Sambuc!13 = !{!"0x11\004\00clang version 3.5.0 \000\00\000\00\001", !14, !2, !2, !3, !15, !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/b.cpp] [DW_LANG_C_plus_plus]
65*0a6a1f1dSLionel Sambuc!14 = !{!"b.cpp", !"/tmp/dbginfo"}
66*0a6a1f1dSLionel Sambuc!15 = !{!16}
67*0a6a1f1dSLionel Sambuc!16 = !{!"0x34\00y\00y\00\004\000\001", null, !6, !12, i32 (i32)** @y, null} ; [ DW_TAG_variable ] [y] [line 4] [def]
68*0a6a1f1dSLionel Sambuc!17 = !{i32 2, !"Dwarf Version", i32 4}
69*0a6a1f1dSLionel Sambuc!18 = !{i32 1, !"Debug Info Version", i32 2}
70*0a6a1f1dSLionel Sambuc!19 = !{!"clang version 3.5.0 "}
71*0a6a1f1dSLionel Sambuc!20 = !{!"0x101\00i\0016777217\000", !4, !6, !9} ; [ DW_TAG_arg_variable ] [i] [line 1]
72*0a6a1f1dSLionel Sambuc!21 = !MDLocation(line: 1, scope: !4)
73*0a6a1f1dSLionel Sambuc!22 = !MDLocation(line: 2, scope: !4)
74