blob: 008b52f7ba7518678f1c777cc8bae8b0fe5c1077 [file] [log] [blame]
David Blaikie76fd43c2014-10-30 20:20:11 +00001; REQUIRES: object-emission
2
3; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4
5; Built with clang from the following source:
6; void f1(int);
7; __attribute__((always_inline)) inline void f2(int i) { f1(i); }
8;
9; #define MULTICALL \
10; f2(x); \
11; f2(y);
12;
13; void f3(int x, int y) { MULTICALL; }
14
15; FIXME: This produces only one inlined_subroutine, with two formal_parameters
16; (both named "this"), one for each of the actual inlined subroutines. ;
17; Inlined scopes are differentiated by the combination of 'inlined at' (call)
18; location and the location within the function. If two calls to the same
19; function occur at the same location the scopes end up conflated and there
20; appears to be only one inlined function.
21; To fix this, we'd need to add some kind of unique metadata per call site, possibly something like:
22;
23; !42 = metadata !{i32 1, i32 0, metadata !43, metadata !44}
24; !44 = metadata !{i32 2, i32 0, metadata !45, null}
25;
26; ->
27;
28; !42 = metadata !{i32 1, i32 0, metadata !43, metadata !44}
29; !44 = metadata !{metadata !45, metadata !44}
30; !45 = metadata !{i32 2, i32 0, metadata !45, null}
31;
32; since cycles in metadata are not uniqued, the !44 node would not be shared
33; between calls to the same function from the same location, ensuring separate
34; inlined subroutines would be generated.
35;
36; Once this is done, the (insufficient) hack in clang that adds column
37; information to call sites to differentiate inlined callers can be removed as it
38; will no longer be necessary.
39;
40; While it might be nice to omit the duplicate parameter in this case (while
41; we wait/work on the real fix), it's actually better to leave it in because it
42; allows us to hold the invariant that every DbgVariable has a DIE, every time.
43; This has proved valuable in finding other bugs, so I want to avoid removing the
44; invariant/assertion. Besides, we don't know which one's the right one anyway...
45
46; CHECK: DW_TAG_subprogram
47; CHECK: DW_TAG_inlined_subroutine
48; CHECK: DW_TAG_formal_parameter
49; CHECK-NOT: DW_TAG
50; CHECK: DW_TAG_formal_parameter
51; CHECK-NOT: DW_TAG
52; CHECK: NULL
53; CHECK-NOT: DW_TAG
54; CHECK: NULL
55
56; Function Attrs: uwtable
57define void @_Z2f3ii(i32 %x, i32 %y) #0 {
58entry:
59 %i.addr.i1 = alloca i32, align 4
60 %i.addr.i = alloca i32, align 4
61 %x.addr = alloca i32, align 4
62 %y.addr = alloca i32, align 4
63 store i32 %x, i32* %x.addr, align 4
64 call void @llvm.dbg.declare(metadata !{i32* %x.addr}, metadata !15, metadata !16), !dbg !17
65 store i32 %y, i32* %y.addr, align 4
66 call void @llvm.dbg.declare(metadata !{i32* %y.addr}, metadata !18, metadata !16), !dbg !19
67 %0 = load i32* %x.addr, align 4, !dbg !20
68 store i32 %0, i32* %i.addr.i, align 4, !dbg !20
69 call void @llvm.dbg.declare(metadata !{i32* %i.addr.i}, metadata !21, metadata !16), !dbg !22
70 %1 = load i32* %i.addr.i, align 4, !dbg !23
71 call void @_Z2f1i(i32 %1), !dbg !23
72 %2 = load i32* %y.addr, align 4, !dbg !20
73 store i32 %2, i32* %i.addr.i1, align 4, !dbg !20
74 call void @llvm.dbg.declare(metadata !{i32* %i.addr.i1}, metadata !21, metadata !16), !dbg !22
75 %3 = load i32* %i.addr.i1, align 4, !dbg !23
76 call void @_Z2f1i(i32 %3), !dbg !23
77 ret void, !dbg !24
78}
79
80; Function Attrs: nounwind readnone
81declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
82
83declare void @_Z2f1i(i32) #2
84
85attributes #0 = { 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" }
86attributes #1 = { nounwind readnone }
87attributes #2 = { "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" }
88
89!llvm.dbg.cu = !{!0}
90!llvm.module.flags = !{!12, !13}
91!llvm.ident = !{!14}
92
93!0 = metadata !{metadata !"0x11\004\00clang version 3.6.0 \000\00\000\00\001", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/duplicate_inline.cpp] [DW_LANG_C_plus_plus]
94!1 = metadata !{metadata !"duplicate_inline.cpp", metadata !"/tmp/dbginfo"}
95!2 = metadata !{}
96!3 = metadata !{metadata !4, metadata !9}
97!4 = metadata !{metadata !"0x2e\00f3\00f3\00_Z2f3ii\008\000\001\000\000\00256\000\008", metadata !1, metadata !5, metadata !6, null, void (i32, i32)* @_Z2f3ii, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 8] [def] [f3]
98!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/duplicate_inline.cpp]
99!6 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", null, null, null, metadata !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
100!7 = metadata !{null, metadata !8, metadata !8}
101!8 = metadata !{metadata !"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]
102!9 = metadata !{metadata !"0x2e\00f2\00f2\00_Z2f2i\002\000\001\000\000\00256\000\002", metadata !1, metadata !5, metadata !10, null, null, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 2] [def] [f2]
103!10 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", null, null, null, metadata !11, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
104!11 = metadata !{null, metadata !8}
105!12 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
106!13 = metadata !{i32 2, metadata !"Debug Info Version", i32 2}
107!14 = metadata !{metadata !"clang version 3.6.0 "}
108!15 = metadata !{metadata !"0x101\00x\0016777224\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [x] [line 8]
109!16 = metadata !{metadata !"0x102"} ; [ DW_TAG_expression ]
110!17 = metadata !{i32 8, i32 13, metadata !4, null}
111!18 = metadata !{metadata !"0x101\00y\0033554440\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [y] [line 8]
112!19 = metadata !{i32 8, i32 20, metadata !4, null}
113!20 = metadata !{i32 8, i32 25, metadata !4, null}
114!21 = metadata !{metadata !"0x101\00i\0016777218\000", metadata !9, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [i] [line 2]
115!22 = metadata !{i32 2, i32 51, metadata !9, metadata !20}
116!23 = metadata !{i32 2, i32 56, metadata !9, metadata !20}
117!24 = metadata !{i32 8, i32 36, metadata !4, null}