blob: 5d387326f664c17b32765a5aa37f02cff9ad6bc0 [file] [log] [blame]
Eric Christopher384f3fe2014-03-20 19:16:16 +00001; RUN: llc %s -filetype=obj -O0 -mtriple=i386-unknown-linux-gnu -dwarf-version=4 -o %t
2; RUN: llvm-dwarfdump %t | FileCheck %s
3
4; From the code:
5
Alexey Samsonov8000e272014-06-09 21:53:47 +00006; debug-loc-offset1.cc
Eric Christopher384f3fe2014-03-20 19:16:16 +00007; int bar (int b) {
8; return b+4;
9; }
10
Alexey Samsonov8000e272014-06-09 21:53:47 +000011; debug-loc-offset2.cc
Eric Christopher384f3fe2014-03-20 19:16:16 +000012; struct A {
Alexey Samsonov8000e272014-06-09 21:53:47 +000013; int var;
14; virtual char foo();
Eric Christopher384f3fe2014-03-20 19:16:16 +000015; };
16
Alexey Samsonov8000e272014-06-09 21:53:47 +000017; void baz(struct A a) {
18; int z = 2;
19; if (a.var > 2)
20; z++;
21; if (a.foo() == 'a')
22; z++;
Eric Christopher384f3fe2014-03-20 19:16:16 +000023; }
24
25; Compiled separately for i386-pc-linux-gnu and linked together.
26; This ensures that we have multiple compile units so that we can verify that
27; debug_loc entries are relative to the low_pc of the CU. The loc entry for
28; the byval argument in foo.cpp is in the second CU and so should have
29; an offset relative to that CU rather than from the beginning of the text
30; section.
31
32; Checking that we have two compile units with two sets of high/lo_pc.
33; CHECK: .debug_info contents
34; CHECK: DW_TAG_compile_unit
35; CHECK: DW_AT_low_pc
36; CHECK: DW_AT_high_pc
37
38; CHECK: DW_TAG_compile_unit
39; CHECK: DW_AT_low_pc
40; CHECK: DW_AT_high_pc
41
42; CHECK: DW_TAG_subprogram
David Blaikie2f753512014-05-23 21:11:46 +000043; CHECK-NOT: DW_TAG
Alexey Samsonov8000e272014-06-09 21:53:47 +000044; CHECK: DW_AT_MIPS_linkage_name [DW_FORM_strp]{{.*}}"_Z3baz1A"
David Blaikie2f753512014-05-23 21:11:46 +000045; CHECK-NOT: {{DW_TAG|NULL}}
Eric Christopher384f3fe2014-03-20 19:16:16 +000046; CHECK: DW_TAG_formal_parameter
David Blaikieeb1a2722014-06-13 22:18:23 +000047; CHECK-NOT: DW_TAG
Eric Christopher384f3fe2014-03-20 19:16:16 +000048; CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000)
David Blaikieeb1a2722014-06-13 22:18:23 +000049; CHECK-NOT: DW_TAG
50; CHECK: DW_AT_name [DW_FORM_strp]{{.*}}"a"
Alexey Samsonov8000e272014-06-09 21:53:47 +000051
52; CHECK: DW_TAG_variable
53; CHECK: DW_AT_location [DW_FORM_exprloc]
Eric Christopher384f3fe2014-03-20 19:16:16 +000054; CHECK-NOT: DW_AT_location
55
56; CHECK: .debug_loc contents:
57; CHECK: 0x00000000: Beginning address offset: 0x0000000000000000
Alexey Samsonov8000e272014-06-09 21:53:47 +000058; CHECK: Ending address offset: 0x000000000000001a
Eric Christopher384f3fe2014-03-20 19:16:16 +000059
Alexey Samsonov8000e272014-06-09 21:53:47 +000060%struct.A = type { i32 (...)**, i32 }
Eric Christopher384f3fe2014-03-20 19:16:16 +000061
62; Function Attrs: nounwind
63define i32 @_Z3bari(i32 %b) #0 {
64entry:
65 %b.addr = alloca i32, align 4
66 store i32 %b, i32* %b.addr, align 4
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000067 call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !21, metadata !{!"0x102"}), !dbg !22
Alexey Samsonov8000e272014-06-09 21:53:47 +000068 %0 = load i32* %b.addr, align 4, !dbg !23
69 %add = add nsw i32 %0, 4, !dbg !23
70 ret i32 %add, !dbg !23
Eric Christopher384f3fe2014-03-20 19:16:16 +000071}
72
73; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000074declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
Eric Christopher384f3fe2014-03-20 19:16:16 +000075
Alexey Samsonov8000e272014-06-09 21:53:47 +000076define void @_Z3baz1A(%struct.A* %a) #2 {
Eric Christopher384f3fe2014-03-20 19:16:16 +000077entry:
Alexey Samsonov8000e272014-06-09 21:53:47 +000078 %z = alloca i32, align 4
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000079 call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !24, metadata !{!"0x102"}), !dbg !25
80 call void @llvm.dbg.declare(metadata i32* %z, metadata !26, metadata !{!"0x102"}), !dbg !27
Alexey Samsonov8000e272014-06-09 21:53:47 +000081 store i32 2, i32* %z, align 4, !dbg !27
82 %var = getelementptr inbounds %struct.A* %a, i32 0, i32 1, !dbg !28
83 %0 = load i32* %var, align 4, !dbg !28
84 %cmp = icmp sgt i32 %0, 2, !dbg !28
85 br i1 %cmp, label %if.then, label %if.end, !dbg !28
86
87if.then: ; preds = %entry
88 %1 = load i32* %z, align 4, !dbg !30
89 %inc = add nsw i32 %1, 1, !dbg !30
90 store i32 %inc, i32* %z, align 4, !dbg !30
91 br label %if.end, !dbg !30
92
93if.end: ; preds = %if.then, %entry
94 %call = call signext i8 @_ZN1A3fooEv(%struct.A* %a), !dbg !31
95 %conv = sext i8 %call to i32, !dbg !31
96 %cmp1 = icmp eq i32 %conv, 97, !dbg !31
97 br i1 %cmp1, label %if.then2, label %if.end4, !dbg !31
98
99if.then2: ; preds = %if.end
100 %2 = load i32* %z, align 4, !dbg !33
101 %inc3 = add nsw i32 %2, 1, !dbg !33
102 store i32 %inc3, i32* %z, align 4, !dbg !33
103 br label %if.end4, !dbg !33
104
105if.end4: ; preds = %if.then2, %if.end
106 ret void, !dbg !34
Eric Christopher384f3fe2014-03-20 19:16:16 +0000107}
108
Alexey Samsonov8000e272014-06-09 21:53:47 +0000109declare signext i8 @_ZN1A3fooEv(%struct.A*) #2
110
Eric Christopher384f3fe2014-03-20 19:16:16 +0000111attributes #0 = { nounwind "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" }
112attributes #1 = { nounwind readnone }
Alexey Samsonov8000e272014-06-09 21:53:47 +0000113attributes #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" }
Eric Christopher384f3fe2014-03-20 19:16:16 +0000114
115!llvm.dbg.cu = !{!0, !9}
Alexey Samsonov8000e272014-06-09 21:53:47 +0000116!llvm.module.flags = !{!18, !19}
117!llvm.ident = !{!20, !20}
Eric Christopher384f3fe2014-03-20 19:16:16 +0000118
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000119!0 = !{!"0x11\004\00clang version 3.5.0 (210479)\000\00\000\00\001", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [/llvm_cmake_gcc/debug-loc-offset1.cc] [DW_LANG_C_plus_plus]
120!1 = !{!"debug-loc-offset1.cc", !"/llvm_cmake_gcc"}
121!2 = !{}
122!3 = !{!4}
123!4 = !{!"0x2e\00bar\00bar\00_Z3bari\001\000\001\000\006\00256\000\001", !1, !5, !6, null, i32 (i32)* @_Z3bari, null, null, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [bar]
124!5 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/llvm_cmake_gcc/debug-loc-offset1.cc]
125!6 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
126!7 = !{!8, !8}
127!8 = !{!"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]
128!9 = !{!"0x11\004\00clang version 3.5.0 (210479)\000\00\000\00\001", !10, !2, !11, !13, !2, !2} ; [ DW_TAG_compile_unit ] [/llvm_cmake_gcc/debug-loc-offset2.cc] [DW_LANG_C_plus_plus]
129!10 = !{!"debug-loc-offset2.cc", !"/llvm_cmake_gcc"}
130!11 = !{!12}
131!12 = !{!"0x13\00A\001\000\000\000\004\000", !10, null, null, null, null, null, !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 1, size 0, align 0, offset 0] [decl] [from ]
132!13 = !{!14}
133!14 = !{!"0x2e\00baz\00baz\00_Z3baz1A\006\000\001\000\006\00256\000\006", !10, !15, !16, null, void (%struct.A*)* @_Z3baz1A, null, null, !2} ; [ DW_TAG_subprogram ] [line 6] [def] [baz]
134!15 = !{!"0x29", !10} ; [ DW_TAG_file_type ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
135!16 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !17, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
136!17 = !{null, !12}
137!18 = !{i32 2, !"Dwarf Version", i32 4}
138!19 = !{i32 2, !"Debug Info Version", i32 2}
139!20 = !{!"clang version 3.5.0 (210479)"}
140!21 = !{!"0x101\00b\0016777217\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [b] [line 1]
141!22 = !{i32 1, i32 0, !4, null}
142!23 = !{i32 2, i32 0, !4, null}
143!24 = !{!"0x101\00a\0016777222\008192", !14, !15, !"_ZTS1A"} ; [ DW_TAG_arg_variable ] [a] [line 6]
144!25 = !{i32 6, i32 0, !14, null}
145!26 = !{!"0x100\00z\007\000", !14, !15, !8} ; [ DW_TAG_auto_variable ] [z] [line 7]
146!27 = !{i32 7, i32 0, !14, null}
147!28 = !{i32 8, i32 0, !29, null}
148!29 = !{!"0xb\008\000\000", !10, !14} ; [ DW_TAG_lexical_block ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
149!30 = !{i32 9, i32 0, !29, null}
150!31 = !{i32 10, i32 0, !32, null}
151!32 = !{!"0xb\0010\000\000", !10, !14} ; [ DW_TAG_lexical_block ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
152!33 = !{i32 11, i32 0, !32, null}
153!34 = !{i32 12, i32 0, !14, null}