blob: 244aa53aa477215f464c44c591be2b31899bedfe [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
Alexey Samsonov8000e272014-06-09 21:53:47 +000047; CHECK-NEXT: DW_AT_name [DW_FORM_strp]{{.*}}"a"
Eric Christopher384f3fe2014-03-20 19:16:16 +000048; CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000)
Alexey Samsonov8000e272014-06-09 21:53:47 +000049
50; CHECK: DW_TAG_variable
51; CHECK: DW_AT_location [DW_FORM_exprloc]
Eric Christopher384f3fe2014-03-20 19:16:16 +000052; CHECK-NOT: DW_AT_location
53
54; CHECK: .debug_loc contents:
55; CHECK: 0x00000000: Beginning address offset: 0x0000000000000000
Alexey Samsonov8000e272014-06-09 21:53:47 +000056; CHECK: Ending address offset: 0x000000000000001a
Eric Christopher384f3fe2014-03-20 19:16:16 +000057
Alexey Samsonov8000e272014-06-09 21:53:47 +000058%struct.A = type { i32 (...)**, i32 }
Eric Christopher384f3fe2014-03-20 19:16:16 +000059
60; Function Attrs: nounwind
61define i32 @_Z3bari(i32 %b) #0 {
62entry:
63 %b.addr = alloca i32, align 4
64 store i32 %b, i32* %b.addr, align 4
Alexey Samsonov8000e272014-06-09 21:53:47 +000065 call void @llvm.dbg.declare(metadata !{i32* %b.addr}, metadata !21), !dbg !22
66 %0 = load i32* %b.addr, align 4, !dbg !23
67 %add = add nsw i32 %0, 4, !dbg !23
68 ret i32 %add, !dbg !23
Eric Christopher384f3fe2014-03-20 19:16:16 +000069}
70
71; Function Attrs: nounwind readnone
72declare void @llvm.dbg.declare(metadata, metadata) #1
73
Alexey Samsonov8000e272014-06-09 21:53:47 +000074define void @_Z3baz1A(%struct.A* %a) #2 {
Eric Christopher384f3fe2014-03-20 19:16:16 +000075entry:
Alexey Samsonov8000e272014-06-09 21:53:47 +000076 %z = alloca i32, align 4
77 call void @llvm.dbg.declare(metadata !{%struct.A* %a}, metadata !24), !dbg !25
78 call void @llvm.dbg.declare(metadata !{i32* %z}, metadata !26), !dbg !27
79 store i32 2, i32* %z, align 4, !dbg !27
80 %var = getelementptr inbounds %struct.A* %a, i32 0, i32 1, !dbg !28
81 %0 = load i32* %var, align 4, !dbg !28
82 %cmp = icmp sgt i32 %0, 2, !dbg !28
83 br i1 %cmp, label %if.then, label %if.end, !dbg !28
84
85if.then: ; preds = %entry
86 %1 = load i32* %z, align 4, !dbg !30
87 %inc = add nsw i32 %1, 1, !dbg !30
88 store i32 %inc, i32* %z, align 4, !dbg !30
89 br label %if.end, !dbg !30
90
91if.end: ; preds = %if.then, %entry
92 %call = call signext i8 @_ZN1A3fooEv(%struct.A* %a), !dbg !31
93 %conv = sext i8 %call to i32, !dbg !31
94 %cmp1 = icmp eq i32 %conv, 97, !dbg !31
95 br i1 %cmp1, label %if.then2, label %if.end4, !dbg !31
96
97if.then2: ; preds = %if.end
98 %2 = load i32* %z, align 4, !dbg !33
99 %inc3 = add nsw i32 %2, 1, !dbg !33
100 store i32 %inc3, i32* %z, align 4, !dbg !33
101 br label %if.end4, !dbg !33
102
103if.end4: ; preds = %if.then2, %if.end
104 ret void, !dbg !34
Eric Christopher384f3fe2014-03-20 19:16:16 +0000105}
106
Alexey Samsonov8000e272014-06-09 21:53:47 +0000107declare signext i8 @_ZN1A3fooEv(%struct.A*) #2
108
Eric Christopher384f3fe2014-03-20 19:16:16 +0000109attributes #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" }
110attributes #1 = { nounwind readnone }
Alexey Samsonov8000e272014-06-09 21:53:47 +0000111attributes #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 +0000112
113!llvm.dbg.cu = !{!0, !9}
Alexey Samsonov8000e272014-06-09 21:53:47 +0000114!llvm.module.flags = !{!18, !19}
115!llvm.ident = !{!20, !20}
Eric Christopher384f3fe2014-03-20 19:16:16 +0000116
Alexey Samsonov8000e272014-06-09 21:53:47 +0000117!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5.0 (210479)", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/llvm_cmake_gcc/debug-loc-offset1.cc] [DW_LANG_C_plus_plus]
118!1 = metadata !{metadata !"debug-loc-offset1.cc", metadata !"/llvm_cmake_gcc"}
Eric Christopher384f3fe2014-03-20 19:16:16 +0000119!2 = metadata !{}
120!3 = metadata !{metadata !4}
121!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"bar", metadata !"bar", metadata !"_Z3bari", i32 1, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z3bari, null, null, metadata !2, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [bar]
Alexey Samsonov8000e272014-06-09 21:53:47 +0000122!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/llvm_cmake_gcc/debug-loc-offset1.cc]
Eric Christopher384f3fe2014-03-20 19:16:16 +0000123!6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
124!7 = metadata !{metadata !8, metadata !8}
125!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
Alexey Samsonov8000e272014-06-09 21:53:47 +0000126!9 = metadata !{i32 786449, metadata !10, i32 4, metadata !"clang version 3.5.0 (210479)", i1 false, metadata !"", i32 0, metadata !2, metadata !11, metadata !13, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/llvm_cmake_gcc/debug-loc-offset2.cc] [DW_LANG_C_plus_plus]
127!10 = metadata !{metadata !"debug-loc-offset2.cc", metadata !"/llvm_cmake_gcc"}
Eric Christopher384f3fe2014-03-20 19:16:16 +0000128!11 = metadata !{metadata !12}
Alexey Samsonov8000e272014-06-09 21:53:47 +0000129!12 = metadata !{i32 786451, metadata !10, null, metadata !"A", i32 1, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 1, size 0, align 0, offset 0] [decl] [from ]
130!13 = metadata !{metadata !14}
131!14 = metadata !{i32 786478, metadata !10, metadata !15, metadata !"baz", metadata !"baz", metadata !"_Z3baz1A", i32 6, metadata !16, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (%struct.A*)* @_Z3baz1A, null, null, metadata !2, i32 6} ; [ DW_TAG_subprogram ] [line 6] [def] [baz]
132!15 = metadata !{i32 786473, metadata !10} ; [ DW_TAG_file_type ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
133!16 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !17, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
134!17 = metadata !{null, metadata !12}
135!18 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
136!19 = metadata !{i32 2, metadata !"Debug Info Version", i32 1}
137!20 = metadata !{metadata !"clang version 3.5.0 (210479)"}
138!21 = metadata !{i32 786689, metadata !4, metadata !"b", metadata !5, i32 16777217, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [b] [line 1]
139!22 = metadata !{i32 1, i32 0, metadata !4, null}
140!23 = metadata !{i32 2, i32 0, metadata !4, null}
141!24 = metadata !{i32 786689, metadata !14, metadata !"a", metadata !15, i32 16777222, metadata !"_ZTS1A", i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [a] [line 6]
142!25 = metadata !{i32 6, i32 0, metadata !14, null}
143!26 = metadata !{i32 786688, metadata !14, metadata !"z", metadata !15, i32 7, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [z] [line 7]
144!27 = metadata !{i32 7, i32 0, metadata !14, null}
145!28 = metadata !{i32 8, i32 0, metadata !29, null} ; [ DW_TAG_imported_declaration ]
146!29 = metadata !{i32 786443, metadata !10, metadata !14, i32 8, i32 0, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
147!30 = metadata !{i32 9, i32 0, metadata !29, null}
148!31 = metadata !{i32 10, i32 0, metadata !32, null}
149!32 = metadata !{i32 786443, metadata !10, metadata !14, i32 10, i32 0, i32 0, i32 1} ; [ DW_TAG_lexical_block ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
150!33 = metadata !{i32 11, i32 0, metadata !32, null}
151!34 = metadata !{i32 12, i32 0, metadata !14, null}