1 ; REQUIRES: object-emission
3 ; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
4 ; RUN: llvm-dwarfdump %t | FileCheck %s
5 ; CHECK: debug_info contents
6 ; CHECK: [[NS1:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace
7 ; CHECK-NEXT: DW_AT_name{{.*}} = "A"
8 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1:".*debug-info-namespace.cpp"]])
9 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(3)
11 ; CHECK: [[NS2:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace
12 ; CHECK-NEXT: DW_AT_name{{.*}} = "B"
13 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2:".*foo.cpp"]])
14 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(1)
16 ; CHECK: [[I:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable
17 ; CHECK-NEXT: DW_AT_name{{.*}}= "i"
19 ; CHECK: [[FOO:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type
20 ; CHECK-NEXT: DW_AT_name{{.*}}= "foo"
21 ; CHECK-NEXT: DW_AT_declaration
23 ; CHECK: [[BAR:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type
24 ; CHECK-NEXT: DW_AT_name{{.*}}= "bar"
26 ; CHECK: [[FUNC1:.*]]: DW_TAG_subprogram
28 ; CHECK: DW_AT_MIPS_linkage_name
30 ; CHECK: DW_AT_name{{.*}}= "f1"
31 ; CHECK: DW_TAG_subprogram
33 ; CHECK: DW_AT_MIPS_linkage_name
35 ; CHECK: DW_AT_name{{.*}}= "f1"
39 ; CHECK: DW_TAG_imported_module
40 ; This is a bug, it should be in F2 but it inherits the file from its
42 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1]])
43 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(8)
44 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS2]]})
48 ; CHECK: DW_TAG_imported_module
49 ; Same bug as above, this should be F2, not F1
50 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1]])
51 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(11)
52 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]})
55 ; CHECK: DW_TAG_subprogram
57 ; CHECK: DW_AT_MIPS_linkage_name
59 ; CHECK: DW_AT_name{{.*}}= "func"
61 ; CHECK: DW_TAG_imported_module
62 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
63 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(18)
64 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]})
66 ; CHECK: DW_TAG_imported_declaration
67 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
68 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(19)
69 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[FOO]]})
71 ; CHECK: DW_TAG_imported_declaration
72 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
73 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(20)
74 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[BAR]]})
76 ; CHECK: DW_TAG_imported_declaration
77 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
78 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(21)
79 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[FUNC1]]})
81 ; CHECK: DW_TAG_imported_declaration
82 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
83 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(22)
84 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[I]]})
86 ; CHECK: [[X:0x[0-9a-f]*]]:{{ *}}DW_TAG_imported_declaration
87 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
88 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(24)
89 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]})
90 ; CHECK-NEXT: DW_AT_name{{.*}}"X"
92 ; CHECK: DW_TAG_imported_declaration
93 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
94 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(25)
95 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[X]]})
96 ; CHECK-NEXT: DW_AT_name{{.*}}"Y"
98 ; CHECK: DW_TAG_lexical_block
100 ; CHECK: DW_TAG_imported_module
101 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
102 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(15)
103 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS2]]})
108 ; IR generated from clang/test/CodeGenCXX/debug-info-namespace.cpp, file paths
109 ; changed to protect the guilty. The C++ source code is:
126 ; using namespace A::B;
137 ; return i + X::B::i + Y::B::i;
140 %"struct.A::B::bar" = type { i8 }
142 @_ZN1A1B1iE = global i32 0, align 4
144 ; Function Attrs: nounwind uwtable
145 define void @_ZN1A1B2f1Ev() #0 {
150 ; Function Attrs: nounwind uwtable
151 define void @_ZN1A1B2f1Ei(i32) #0 {
153 %.addr = alloca i32, align 4
154 store i32 %0, i32* %.addr, align 4
155 call void @llvm.dbg.declare(metadata !{i32* %.addr}, metadata !42), !dbg !43
159 ; Function Attrs: nounwind readnone
160 declare void @llvm.dbg.declare(metadata, metadata) #1
162 ; Function Attrs: nounwind uwtable
163 define i32 @_Z4funcb(i1 zeroext %b) #0 {
165 %retval = alloca i32, align 4
166 %b.addr = alloca i8, align 1
167 %x = alloca %"struct.A::B::bar", align 1
168 %frombool = zext i1 %b to i8
169 store i8 %frombool, i8* %b.addr, align 1
170 call void @llvm.dbg.declare(metadata !{i8* %b.addr}, metadata !44), !dbg !45
171 %0 = load i8* %b.addr, align 1, !dbg !46
172 %tobool = trunc i8 %0 to i1, !dbg !46
173 br i1 %tobool, label %if.then, label %if.end, !dbg !46
175 if.then: ; preds = %entry
176 %1 = load i32* @_ZN1A1B1iE, align 4, !dbg !47
177 store i32 %1, i32* %retval, !dbg !47
178 br label %return, !dbg !47
180 if.end: ; preds = %entry
181 call void @llvm.dbg.declare(metadata !{%"struct.A::B::bar"* %x}, metadata !48), !dbg !49
182 %2 = load i32* @_ZN1A1B1iE, align 4, !dbg !50
183 %3 = load i32* @_ZN1A1B1iE, align 4, !dbg !50
184 %add = add nsw i32 %2, %3, !dbg !50
185 %4 = load i32* @_ZN1A1B1iE, align 4, !dbg !50
186 %add1 = add nsw i32 %add, %4, !dbg !50
187 store i32 %add1, i32* %retval, !dbg !50
188 br label %return, !dbg !50
190 return: ; preds = %if.end, %if.then
191 %5 = load i32* %retval, !dbg !51
195 attributes #0 = { 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" "unsafe-fp-math"="false" "use-soft-float"="false" }
196 attributes #1 = { nounwind readnone }
199 !llvm.module.flags = !{!52}
201 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !19, metadata !21, metadata !""} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/blaikie/dev/llvm/build/clang/debug//usr/local/google/home/blaikie/dev/llvm/src/tools/clang/test/CodeGenCXX/debug-info-namespace.cpp] [DW_LANG_C_plus_plus]
202 !1 = metadata !{metadata !"/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/test/CodeGenCXX/debug-info-namespace.cpp", metadata !"/usr/local/google/home/blaikie/dev/llvm/build/clang/debug"}
204 !3 = metadata !{metadata !4, metadata !10, metadata !14}
205 !4 = metadata !{i32 786478, metadata !5, metadata !6, metadata !"f1", metadata !"f1", metadata !"_ZN1A1B2f1Ev", i32 3, metadata !8, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_ZN1A1B2f1Ev, null, null, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [f1]
206 !5 = metadata !{metadata !"foo.cpp", metadata !"/usr/local/google/home/blaikie/dev/llvm/build/clang/debug"}
207 !6 = metadata !{i32 786489, metadata !5, metadata !7, metadata !"B", i32 1} ; [ DW_TAG_namespace ] [B] [line 1]
208 !7 = metadata !{i32 786489, metadata !1, null, metadata !"A", i32 3} ; [ DW_TAG_namespace ] [A] [line 3]
209 !8 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !9, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
210 !9 = metadata !{null}
211 !10 = metadata !{i32 786478, metadata !5, metadata !6, metadata !"f1", metadata !"f1", metadata !"_ZN1A1B2f1Ei", i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32)* @_ZN1A1B2f1Ei, null, null, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [f1]
212 !11 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
213 !12 = metadata !{null, metadata !13}
214 !13 = 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]
215 !14 = metadata !{i32 786478, metadata !5, metadata !15, metadata !"func", metadata !"func", metadata !"_Z4funcb", i32 13, metadata !16, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i1)* @_Z4funcb, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 13] [def] [func]
216 !15 = metadata !{i32 786473, metadata !5} ; [ DW_TAG_file_type ] [/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/foo.cpp]
217 !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 ]
218 !17 = metadata !{metadata !13, metadata !18}
219 !18 = metadata !{i32 786468, null, null, metadata !"bool", i32 0, i64 8, i64 8, i64 0, i32 0, i32 2} ; [ DW_TAG_base_type ] [bool] [line 0, size 8, align 8, offset 0, enc DW_ATE_boolean]
220 !19 = metadata !{metadata !20}
221 !20 = metadata !{i32 786484, i32 0, metadata !6, metadata !"i", metadata !"i", metadata !"_ZN1A1B1iE", metadata !15, i32 2, metadata !13, i32 0, i32 1, i32* @_ZN1A1B1iE, null} ; [ DW_TAG_variable ] [i] [line 2] [def]
222 !21 = metadata !{metadata !22, metadata !23, metadata !24, metadata !26, metadata !27, metadata !29, metadata !37, metadata !38, metadata !39, metadata !40}
223 !22 = metadata !{i32 786490, metadata !7, metadata !6, i32 8} ; [ DW_TAG_imported_module ]
224 !23 = metadata !{i32 786490, metadata !0, metadata !7, i32 11} ; [ DW_TAG_imported_module ]
225 !24 = metadata !{i32 786490, metadata !25, metadata !6, i32 15} ; [ DW_TAG_imported_module ]
226 !25 = metadata !{i32 786443, metadata !5, metadata !14, i32 14, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/foo.cpp]
227 !26 = metadata !{i32 786490, metadata !14, metadata !7, i32 18} ; [ DW_TAG_imported_module ]
228 !27 = metadata !{i32 786440, metadata !14, metadata !28, i32 19} ; [ DW_TAG_imported_declaration ]
229 !28 = metadata !{i32 786451, metadata !5, metadata !6, metadata !"foo", i32 5, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [foo] [line 5, size 0, align 0, offset 0] [decl] [from ]
230 !29 = metadata !{i32 786440, metadata !14, metadata !30, i32 20} ; [ DW_TAG_imported_declaration ]
231 !30 = metadata !{i32 786451, metadata !5, metadata !6, metadata !"bar", i32 6, i64 8, i64 8, i32 0, i32 0, null, metadata !31, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [bar] [line 6, size 8, align 8, offset 0] [def] [from ]
232 !31 = metadata !{metadata !32}
233 !32 = metadata !{i32 786478, metadata !5, metadata !30, metadata !"bar", metadata !"bar", metadata !"", i32 6, metadata !33, i1 false, i1 false, i32 0, i32 0, null, i32 320, i1 false, null, null, i32 0, metadata !36, i32 6} ; [ DW_TAG_subprogram ] [line 6] [bar]
234 !33 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !34, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
235 !34 = metadata !{null, metadata !35}
236 !35 = metadata !{i32 786447, i32 0, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !30} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from bar]
237 !36 = metadata !{i32 786468}
238 !37 = metadata !{i32 786440, metadata !14, metadata !10, i32 21} ; [ DW_TAG_imported_declaration ]
239 !38 = metadata !{i32 786440, metadata !14, metadata !20, i32 22} ; [ DW_TAG_imported_declaration ]
240 !39 = metadata !{i32 786440, metadata !14, metadata !7, i32 24, metadata !"X"} ; [ DW_TAG_imported_declaration ]
241 !40 = metadata !{i32 786440, metadata !14, metadata !39, i32 25, metadata !"Y"} ; [ DW_TAG_imported_declaration ]
242 !41 = metadata !{i32 3, i32 0, metadata !4, null}
243 !42 = metadata !{i32 786689, metadata !10, metadata !"", metadata !15, i32 16777220, metadata !13, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [line 4]
244 !43 = metadata !{i32 4, i32 0, metadata !10, null}
245 !44 = metadata !{i32 786689, metadata !14, metadata !"b", metadata !15, i32 16777229, metadata !18, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [b] [line 13]
246 !45 = metadata !{i32 13, i32 0, metadata !14, null}
247 !46 = metadata !{i32 14, i32 0, metadata !14, null}
248 !47 = metadata !{i32 16, i32 0, metadata !25, null}
249 !48 = metadata !{i32 786688, metadata !14, metadata !"x", metadata !15, i32 23, metadata !30, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [x] [line 23]
250 !49 = metadata !{i32 23, i32 0, metadata !14, null}
251 !50 = metadata !{i32 26, i32 0, metadata !14, null}
252 !51 = metadata !{i32 27, i32 0, metadata !14, null}
253 !52 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}