• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc %s -filetype=obj -O0 -mtriple=i386-unknown-linux-gnu -dwarf-version=4 -o %t
2; RUN: llvm-dwarfdump -v %t | FileCheck %s
3
4; From the code:
5
6; debug-loc-offset1.cc
7; int bar (int b) {
8;   return b+4;
9; }
10
11; debug-loc-offset2.cc
12; struct A {
13;   int var;
14;   virtual char foo();
15; };
16
17; void baz(struct A a) {
18;   int z = 2;
19;   if (a.var > 2)
20;     z++;
21;   if (a.foo() == 'a')
22;     z++;
23; }
24
25; Compiled separately for i386-pc-linux-gnu and linked together.
26; This ensures that we have multiple compile units and multiple location lists
27; so that we can verify that
28; debug_loc entries are relative to the low_pc of the CU. The loc entry for
29; the byval argument in foo.cpp is in the second CU and so should have
30; an offset relative to that CU rather than from the beginning of the text
31; section.
32
33; Checking that we have two compile units with two sets of high/lo_pc.
34; CHECK: .debug_info contents
35; CHECK: DW_TAG_compile_unit
36; CHECK: DW_AT_low_pc {{.*}} (0x0000000000000020)
37; CHECK: DW_AT_high_pc
38
39; CHECK: DW_TAG_subprogram
40; CHECK-NOT: DW_TAG
41; CHECK: DW_AT_linkage_name [DW_FORM_strp]{{.*}}"_Z3baz1A"
42; CHECK-NOT: {{DW_TAG|NULL}}
43; CHECK: DW_TAG_formal_parameter
44; CHECK-NOT: DW_TAG
45; CHECK:       DW_AT_location [DW_FORM_sec_offset]   ({{.*}}
46; CHECK-NEXT:    [0x00000020, 0x00000037): DW_OP_breg0 EAX+0, DW_OP_deref
47; CHECK-NEXT:    [0x00000037, 0x00000063): DW_OP_breg5 EBP-8, DW_OP_deref, DW_OP_deref
48; CHECK-NEXT:  DW_AT_name [DW_FORM_strp]{{.*}}"a"
49
50; CHECK: DW_TAG_variable
51; CHECK: DW_AT_location [DW_FORM_exprloc]
52; CHECK-NOT: DW_AT_location
53
54; CHECK: DW_TAG_compile_unit
55; CHECK: DW_AT_low_pc {{.*}} (0x0000000000000000)
56; CHECK: DW_AT_high_pc
57
58; CHECK: DW_TAG_subprogram
59; CHECK-NOT: DW_TAG
60; CHECK: DW_AT_linkage_name [DW_FORM_strp]{{.*}}"_Z3bari"
61; CHECK-NOT: {{DW_TAG|NULL}}
62; CHECK: DW_TAG_formal_parameter
63; CHECK-NOT: DW_TAG
64; CHECK:       DW_AT_location [DW_FORM_sec_offset]   ({{.*}}
65; CHECK-NEXT:    [0x00000000, 0x0000000a): DW_OP_consts +0, DW_OP_stack_value
66; CHECK-NEXT:    [0x0000000a, 0x00000017): DW_OP_consts +1, DW_OP_stack_value)
67; CHECK-NEXT:  DW_AT_name [DW_FORM_strp]{{.*}}"b"
68
69; CHECK: .debug_loc contents:
70; CHECK:       0x00000000:
71; CHECK-NEXT:    [0x00000000, 0x0000000a): DW_OP_consts +0, DW_OP_stack_value
72; CHECK-NEXT:    [0x0000000a, 0x00000017): DW_OP_consts +1, DW_OP_stack_value
73; CHECK:       0x00000022:
74; CHECK-NEXT:    [0x00000000, 0x00000017): DW_OP_breg0 EAX+0, DW_OP_deref
75; CHECK-NEXT:    [0x00000017, 0x00000043): DW_OP_breg5 EBP-8, DW_OP_deref, DW_OP_deref
76
77%struct.A = type { i32 (...)**, i32 }
78
79; Function Attrs: nounwind
80define i32 @_Z3bari(i32 %b) #0 !dbg !4 {
81entry:
82  %b.addr = alloca i32, align 4
83  store i32 %b, i32* %b.addr, align 4
84  call void @llvm.dbg.value(metadata i32 0, metadata !21, metadata !DIExpression()), !dbg !22
85  %0 = load i32, i32* %b.addr, align 4, !dbg !23
86  call void @llvm.dbg.value(metadata i32 1, metadata !21, metadata !DIExpression()), !dbg !22
87  %add = add nsw i32 %0, 4, !dbg !23
88  ret i32 %add, !dbg !23
89}
90
91; Function Attrs: nounwind readnone
92declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
93
94declare void @llvm.dbg.value(metadata, metadata, metadata) #1
95
96define void @_Z3baz1A(%struct.A* %a) #2 !dbg !14 {
97entry:
98  %z = alloca i32, align 4
99  call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !24, metadata !DIExpression(DW_OP_deref)), !dbg !25
100  call void @llvm.dbg.declare(metadata i32* %z, metadata !26, metadata !DIExpression()), !dbg !27
101  store i32 2, i32* %z, align 4, !dbg !27
102  %var = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 1, !dbg !28
103  %0 = load i32, i32* %var, align 4, !dbg !28
104  %cmp = icmp sgt i32 %0, 2, !dbg !28
105  br i1 %cmp, label %if.then, label %if.end, !dbg !28
106
107if.then:                                          ; preds = %entry
108  %1 = load i32, i32* %z, align 4, !dbg !30
109  %inc = add nsw i32 %1, 1, !dbg !30
110  store i32 %inc, i32* %z, align 4, !dbg !30
111  br label %if.end, !dbg !30
112
113if.end:                                           ; preds = %if.then, %entry
114  %call = call signext i8 @_ZN1A3fooEv(%struct.A* %a), !dbg !31
115  %conv = sext i8 %call to i32, !dbg !31
116  %cmp1 = icmp eq i32 %conv, 97, !dbg !31
117  br i1 %cmp1, label %if.then2, label %if.end4, !dbg !31
118
119if.then2:                                         ; preds = %if.end
120  %2 = load i32, i32* %z, align 4, !dbg !33
121  %inc3 = add nsw i32 %2, 1, !dbg !33
122  store i32 %inc3, i32* %z, align 4, !dbg !33
123  br label %if.end4, !dbg !33
124
125if.end4:                                          ; preds = %if.then2, %if.end
126  ret void, !dbg !34
127}
128
129declare signext i8 @_ZN1A3fooEv(%struct.A*) #2
130
131attributes #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" }
132attributes #1 = { nounwind readnone }
133attributes #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" }
134
135!llvm.dbg.cu = !{!0, !9}
136!llvm.module.flags = !{!18, !19}
137!llvm.ident = !{!20, !20}
138
139!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (210479)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
140!1 = !DIFile(filename: "debug-loc-offset1.cc", directory: "/llvm_cmake_gcc")
141!2 = !{}
142!4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
143!5 = !DIFile(filename: "debug-loc-offset1.cc", directory: "/llvm_cmake_gcc")
144!6 = !DISubroutineType(types: !7)
145!7 = !{!8, !8}
146!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
147!9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (210479)", isOptimized: false, emissionKind: FullDebug, file: !10, enums: !2, retainedTypes: !11, globals: !2, imports: !2)
148!10 = !DIFile(filename: "debug-loc-offset2.cc", directory: "/llvm_cmake_gcc")
149!11 = !{!12}
150!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 1, flags: DIFlagFwdDecl, file: !10, identifier: "_ZTS1A")
151!14 = distinct !DISubprogram(name: "baz", linkageName: "_Z3baz1A", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !9, scopeLine: 6, file: !10, scope: !15, type: !16, retainedNodes: !2)
152!15 = !DIFile(filename: "debug-loc-offset2.cc", directory: "/llvm_cmake_gcc")
153!16 = !DISubroutineType(types: !17)
154!17 = !{null, !12}
155!18 = !{i32 2, !"Dwarf Version", i32 4}
156!19 = !{i32 2, !"Debug Info Version", i32 3}
157!20 = !{!"clang version 3.5.0 (210479)"}
158!21 = !DILocalVariable(name: "b", line: 1, arg: 1, scope: !4, file: !5, type: !8)
159!22 = !DILocation(line: 1, scope: !4)
160!23 = !DILocation(line: 2, scope: !4)
161!24 = !DILocalVariable(name: "a", line: 6, arg: 1, scope: !14, file: !15, type: !12)
162!25 = !DILocation(line: 6, scope: !14)
163!26 = !DILocalVariable(name: "z", line: 7, scope: !14, file: !15, type: !8)
164!27 = !DILocation(line: 7, scope: !14)
165!28 = !DILocation(line: 8, scope: !29)
166!29 = distinct !DILexicalBlock(line: 8, column: 0, file: !10, scope: !14)
167!30 = !DILocation(line: 9, scope: !29)
168!31 = !DILocation(line: 10, scope: !32)
169!32 = distinct !DILexicalBlock(line: 10, column: 0, file: !10, scope: !14)
170!33 = !DILocation(line: 11, scope: !32)
171!34 = !DILocation(line: 12, scope: !14)
172