1 Pull in r195391 from upstream llvm trunk (by Eric Christopher):
3 In Dwarf 3 (and Dwarf 2) attributes whose value are offsets into a
4 section use the form DW_FORM_data4 whilst in Dwarf 4 and later they
5 use the form DW_FORM_sec_offset.
7 This patch updates the places where such attributes are generated to
8 use the appropriate form depending on the Dwarf version. The DIE entries
9 affected have the following tags:
10 DW_AT_stmt_list, DW_AT_ranges, DW_AT_location, DW_AT_GNU_pubnames,
11 DW_AT_GNU_pubtypes, DW_AT_GNU_addr_base, DW_AT_GNU_ranges_base
13 It also adds a hidden command line option "--dwarf-version=<uint>"
14 to llc which allows the version of Dwarf to be generated to override
15 what is specified in the metadata; this makes it possible to update
16 existing tests to check the debugging information generated for both
17 Dwarf 4 (the default) and Dwarf 3 using the same metadata.
19 Patch (slightly modified) by Keith Walker!
21 Introduced here: http://svnweb.freebsd.org/changeset/base/261991
23 Index: lib/CodeGen/AsmPrinter/DIE.cpp
24 ===================================================================
25 --- lib/CodeGen/AsmPrinter/DIE.cpp
26 +++ lib/CodeGen/AsmPrinter/DIE.cpp
27 @@ -338,6 +338,7 @@ void DIEDelta::EmitValue(AsmPrinter *AP, dwarf::Fo
29 unsigned DIEDelta::SizeOf(AsmPrinter *AP, dwarf::Form Form) const {
30 if (Form == dwarf::DW_FORM_data4) return 4;
31 + if (Form == dwarf::DW_FORM_sec_offset) return 4;
32 if (Form == dwarf::DW_FORM_strp) return 4;
33 return AP->getDataLayout().getPointerSize();
35 Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
36 ===================================================================
37 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
38 +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
39 @@ -105,6 +105,11 @@ DwarfPubSections("generate-dwarf-pub-sections", cl
40 clEnumVal(Disable, "Disabled"), clEnumValEnd),
43 +static cl::opt<unsigned>
44 +DwarfVersionNumber("dwarf-version", cl::Hidden,
45 + cl::desc("Generate DWARF for dwarf version."),
48 static const char *const DWARFGroupName = "DWARF Emission";
49 static const char *const DbgTimerName = "DWARF Debug Writer";
51 @@ -215,7 +220,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
53 HasDwarfPubSections = DwarfPubSections == Enable;
55 - DwarfVersion = getDwarfVersionFromModule(MMI->getModule());
56 + DwarfVersion = DwarfVersionNumber
57 + ? DwarfVersionNumber
58 + : getDwarfVersionFromModule(MMI->getModule());
61 NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled);
62 @@ -470,9 +477,9 @@ DIE *DwarfDebug::constructLexicalScopeDIE(CompileU
63 // .debug_range section has not been laid out yet. Emit offset in
64 // .debug_range as a uint, size 4, for now. emitDIE will handle
65 // DW_AT_ranges appropriately.
66 - TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4,
67 - DebugRangeSymbols.size()
68 - * Asm->getDataLayout().getPointerSize());
69 + TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges,
70 + DebugRangeSymbols.size() *
71 + Asm->getDataLayout().getPointerSize());
72 for (SmallVectorImpl<InsnRange>::const_iterator RI = Ranges.begin(),
73 RE = Ranges.end(); RI != RE; ++RI) {
74 DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
75 @@ -525,9 +532,9 @@ DIE *DwarfDebug::constructInlinedScopeDIE(CompileU
76 // .debug_range section has not been laid out yet. Emit offset in
77 // .debug_range as a uint, size 4, for now. emitDIE will handle
78 // DW_AT_ranges appropriately.
79 - TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4,
80 - DebugRangeSymbols.size()
81 - * Asm->getDataLayout().getPointerSize());
82 + TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges,
83 + DebugRangeSymbols.size() *
84 + Asm->getDataLayout().getPointerSize());
85 for (SmallVectorImpl<InsnRange>::const_iterator RI = Ranges.begin(),
86 RE = Ranges.end(); RI != RE; ++RI) {
87 DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
88 @@ -758,14 +765,15 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICo
89 // The line table entries are not always emitted in assembly, so it
90 // is not okay to use line_table_start here.
91 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
92 - NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
93 - UseTheFirstCU ? Asm->GetTempSymbol("section_line")
94 - : LineTableStartSym);
95 + NewCU->addSectionLabel(
96 + Die, dwarf::DW_AT_stmt_list,
97 + UseTheFirstCU ? Asm->GetTempSymbol("section_line")
98 + : LineTableStartSym);
99 else if (UseTheFirstCU)
100 - NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0);
101 + NewCU->addSectionOffset(Die, dwarf::DW_AT_stmt_list, 0);
103 - NewCU->addDelta(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4,
104 - LineTableStartSym, DwarfLineSectionSym);
105 + NewCU->addSectionDelta(Die, dwarf::DW_AT_stmt_list,
106 + LineTableStartSym, DwarfLineSectionSym);
108 // If we're using split dwarf the compilation dir is going to be in the
109 // skeleton CU and so we don't need to duplicate it here.
110 @@ -776,26 +784,24 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICo
111 // emit it here if we don't have a skeleton CU for split dwarf.
112 if (GenerateGnuPubSections) {
113 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
114 - NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubnames,
115 - dwarf::DW_FORM_sec_offset,
116 - Asm->GetTempSymbol("gnu_pubnames",
117 - NewCU->getUniqueID()));
118 + NewCU->addSectionLabel(
119 + Die, dwarf::DW_AT_GNU_pubnames,
120 + Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()));
122 - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4,
123 - Asm->GetTempSymbol("gnu_pubnames",
124 - NewCU->getUniqueID()),
125 - DwarfGnuPubNamesSectionSym);
126 + NewCU->addSectionDelta(
127 + Die, dwarf::DW_AT_GNU_pubnames,
128 + Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()),
129 + DwarfGnuPubNamesSectionSym);
131 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
132 - NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubtypes,
133 - dwarf::DW_FORM_sec_offset,
134 - Asm->GetTempSymbol("gnu_pubtypes",
135 - NewCU->getUniqueID()));
136 + NewCU->addSectionLabel(
137 + Die, dwarf::DW_AT_GNU_pubtypes,
138 + Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()));
140 - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4,
141 - Asm->GetTempSymbol("gnu_pubtypes",
142 - NewCU->getUniqueID()),
143 - DwarfGnuPubTypesSectionSym);
144 + NewCU->addSectionDelta(
145 + Die, dwarf::DW_AT_GNU_pubtypes,
146 + Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()),
147 + DwarfGnuPubTypesSectionSym);
151 @@ -2956,11 +2962,10 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const
152 // Relocate to the beginning of the addr_base section, else 0 for the
153 // beginning of the one for this compile unit.
154 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
155 - NewCU->addLabel(Die, dwarf::DW_AT_GNU_addr_base, dwarf::DW_FORM_sec_offset,
156 - DwarfAddrSectionSym);
157 + NewCU->addSectionLabel(Die, dwarf::DW_AT_GNU_addr_base,
158 + DwarfAddrSectionSym);
160 - NewCU->addUInt(Die, dwarf::DW_AT_GNU_addr_base,
161 - dwarf::DW_FORM_sec_offset, 0);
162 + NewCU->addSectionOffset(Die, dwarf::DW_AT_GNU_addr_base, 0);
164 // 2.17.1 requires that we use DW_AT_low_pc for a single entry point
165 // into an entity. We're using 0, or a NULL label for this.
166 @@ -2970,10 +2975,10 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const
167 // compile unit in debug_line section.
168 // FIXME: Should handle multiple compile units.
169 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
170 - NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
171 - DwarfLineSectionSym);
172 + NewCU->addSectionLabel(Die, dwarf::DW_AT_stmt_list,
173 + DwarfLineSectionSym);
175 - NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, 0);
176 + NewCU->addSectionOffset(Die, dwarf::DW_AT_stmt_list, 0);
178 if (!CompilationDir.empty())
179 NewCU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
180 @@ -2981,27 +2986,31 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const
181 // Flags to let the linker know we have emitted new style pubnames.
182 if (GenerateGnuPubSections) {
183 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
184 - NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_sec_offset,
185 - Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()));
186 + NewCU->addSectionLabel(
187 + Die, dwarf::DW_AT_GNU_pubnames,
188 + Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()));
190 - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4,
191 - Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()),
192 - DwarfGnuPubNamesSectionSym);
193 + NewCU->addSectionDelta(
194 + Die, dwarf::DW_AT_GNU_pubnames,
195 + Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()),
196 + DwarfGnuPubNamesSectionSym);
198 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
199 - NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_sec_offset,
200 - Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()));
201 + NewCU->addSectionLabel(
202 + Die, dwarf::DW_AT_GNU_pubtypes,
203 + Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()));
205 - NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4,
206 - Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()),
207 - DwarfGnuPubTypesSectionSym);
208 + NewCU->addSectionDelta(
209 + Die, dwarf::DW_AT_GNU_pubtypes,
210 + Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()),
211 + DwarfGnuPubTypesSectionSym);
214 // Flag if we've emitted any ranges and their location for the compile unit.
215 if (DebugRangeSymbols.size()) {
216 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
217 - NewCU->addLabel(Die, dwarf::DW_AT_GNU_ranges_base,
218 - dwarf::DW_FORM_sec_offset, DwarfDebugRangeSectionSym);
219 + NewCU->addSectionLabel(Die, dwarf::DW_AT_GNU_ranges_base,
220 + DwarfDebugRangeSectionSym);
222 NewCU->addUInt(Die, dwarf::DW_AT_GNU_ranges_base, dwarf::DW_FORM_data4,
224 Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
225 ===================================================================
226 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
227 +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
228 @@ -227,6 +227,26 @@ void CompileUnit::addLabel(DIEBlock *Die, dwarf::F
229 addLabel(Die, (dwarf::Attribute)0, Form, Label);
232 +/// addSectionLabel - Add a Dwarf section label attribute data and value.
234 +void CompileUnit::addSectionLabel(DIE *Die, dwarf::Attribute Attribute,
235 + const MCSymbol *Label) {
236 + if (DD->getDwarfVersion() >= 4)
237 + addLabel(Die, Attribute, dwarf::DW_FORM_sec_offset, Label);
239 + addLabel(Die, Attribute, dwarf::DW_FORM_data4, Label);
242 +/// addSectionOffset - Add an offset into a section attribute data and value.
244 +void CompileUnit::addSectionOffset(DIE *Die, dwarf::Attribute Attribute,
245 + uint64_t Integer) {
246 + if (DD->getDwarfVersion() >= 4)
247 + addUInt(Die, Attribute, dwarf::DW_FORM_sec_offset, Integer);
249 + addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
252 /// addLabelAddress - Add a dwarf label attribute data and value using
253 /// DW_FORM_addr or DW_FORM_GNU_addr_index.
255 @@ -264,13 +284,15 @@ void CompileUnit::addOpAddress(DIEBlock *Die, cons
259 -/// addDelta - Add a label delta attribute data and value.
260 +/// addSectionDelta - Add a section label delta attribute data and value.
262 -void CompileUnit::addDelta(DIE *Die, dwarf::Attribute Attribute,
263 - dwarf::Form Form, const MCSymbol *Hi,
264 - const MCSymbol *Lo) {
265 +void CompileUnit::addSectionDelta(DIE *Die, dwarf::Attribute Attribute,
266 + const MCSymbol *Hi, const MCSymbol *Lo) {
267 DIEValue *Value = new (DIEValueAllocator) DIEDelta(Hi, Lo);
268 - Die->addValue(Attribute, Form, Value);
269 + if (DD->getDwarfVersion() >= 4)
270 + Die->addValue(Attribute, dwarf::DW_FORM_sec_offset, Value);
272 + Die->addValue(Attribute, dwarf::DW_FORM_data4, Value);
275 /// addDIEEntry - Add a DIE attribute data and value.
276 @@ -1768,10 +1790,8 @@ DIE *CompileUnit::constructVariableDIE(DbgVariable
278 unsigned Offset = DV.getDotDebugLocOffset();
280 - addLabel(VariableDie, dwarf::DW_AT_location,
281 - DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
282 - : dwarf::DW_FORM_data4,
283 - Asm->GetTempSymbol("debug_loc", Offset));
284 + addSectionLabel(VariableDie, dwarf::DW_AT_location,
285 + Asm->GetTempSymbol("debug_loc", Offset));
286 DV.setDIE(VariableDie);
289 Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
290 ===================================================================
291 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
292 +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
293 @@ -209,6 +209,14 @@ class CompileUnit {
295 void addLabel(DIEBlock *Die, dwarf::Form Form, const MCSymbol *Label);
297 + /// addSectionLabel - Add a Dwarf section label attribute data and value.
299 + void addSectionLabel(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Label);
301 + /// addSectionOffset - Add an offset into a section attribute data and value.
303 + void addSectionOffset(DIE *Die, dwarf::Attribute Attribute, uint64_t Integer);
305 /// addLabelAddress - Add a dwarf label attribute data and value using
306 /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
308 @@ -219,10 +227,9 @@ class CompileUnit {
310 void addOpAddress(DIEBlock *Die, const MCSymbol *Label);
312 - /// addDelta - Add a label delta attribute data and value.
314 - void addDelta(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Hi,
315 - const MCSymbol *Lo);
316 + /// addSectionDelta - Add a label delta attribute data and value.
317 + void addSectionDelta(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
318 + const MCSymbol *Lo);
320 /// addDIEEntry - Add a DIE attribute data and value.
322 Index: test/DebugInfo/X86/gnu-public-names.ll
323 ===================================================================
324 --- test/DebugInfo/X86/gnu-public-names.ll
325 +++ test/DebugInfo/X86/gnu-public-names.ll
327 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections < %s | FileCheck -check-prefix=ASM %s
328 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s
329 +; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj -dwarf-version=3 < %s | llvm-dwarfdump - | FileCheck %s -check-prefix=DWARF3
330 ; ModuleID = 'dwarf-public-names.cpp'
334 ; CHECK-DAG: [[D]] EXTERNAL TYPE "ns::D"
335 ; CHECK-DAG: [[INT]] STATIC TYPE "int"
337 +; DWARF3: .debug_info contents:
338 +; DWARF3: DW_AT_GNU_pubnames [DW_FORM_data4] (0x00000000)
339 +; DWARF3: DW_AT_GNU_pubtypes [DW_FORM_data4] (0x00000000)
341 +; DWARF3: [[C:[0-9a-f]+]]: DW_TAG_structure_type
342 +; DWARF3-NEXT: DW_AT_name {{.*}} "C"
344 +; DWARF3: [[STATIC_MEM_DECL:[0-9a-f]+]]: DW_TAG_member
345 +; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_variable"
347 +; DWARF3: [[MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram
348 +; DWARF3-NEXT: DW_AT_MIPS_linkage_name
349 +; DWARF3-NEXT: DW_AT_name {{.*}} "member_function"
351 +; DWARF3: [[STATIC_MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram
352 +; DWARF3-NEXT: DW_AT_MIPS_linkage_name
353 +; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_function"
355 +; DWARF3: [[INT:[0-9a-f]+]]: DW_TAG_base_type
356 +; DWARF3-NEXT: DW_AT_name {{.*}} "int"
358 +; DWARF3: [[STATIC_MEM_VAR:[0-9a-f]+]]: DW_TAG_variable
359 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_DECL]]
361 +; DWARF3: [[GLOB_VAR:[0-9a-f]+]]: DW_TAG_variable
362 +; DWARF3-NEXT: DW_AT_name {{.*}} "global_variable"
364 +; DWARF3: [[NS:[0-9a-f]+]]: DW_TAG_namespace
365 +; DWARF3-NEXT: DW_AT_name {{.*}} "ns"
367 +; DWARF3: [[GLOB_NS_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
368 +; DWARF3-NEXT: DW_AT_name {{.*}} "global_namespace_variable"
370 +; DWARF3: [[D_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
371 +; DWARF3-NEXT: DW_AT_name {{.*}} "d"
373 +; DWARF3: [[D:[0-9a-f]+]]: DW_TAG_structure_type
374 +; DWARF3-NEXT: DW_AT_name {{.*}} "D"
376 +; DWARF3: [[GLOB_NS_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
377 +; DWARF3-NEXT: DW_AT_MIPS_linkage_name
378 +; DWARF3-NEXT: DW_AT_name {{.*}} "global_namespace_function"
380 +; DWARF3: [[GLOB_NS_VAR:[0-9a-f]+]]: DW_TAG_variable
381 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[GLOB_NS_VAR_DECL]]
383 +; DWARF3: [[D_VAR:[0-9a-f]+]]: DW_TAG_variable
384 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[D_VAR_DECL]]
386 +; DWARF3: [[MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
387 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[MEM_FUNC_DECL]]
389 +; DWARF3: [[STATIC_MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
390 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_FUNC_DECL]]
392 +; DWARF3: [[GLOBAL_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
393 +; DWARF3-NEXT: DW_AT_MIPS_linkage_name
394 +; DWARF3-NEXT: DW_AT_name {{.*}} "global_function"
396 +; DWARF3-LABEL: .debug_gnu_pubnames contents:
397 +; DWARF3-NEXT: length = 0x000000e7 version = 0x0002 unit_offset = 0x00000000 unit_size = 0x0000018b
398 +; DWARF3-NEXT: Offset Linkage Kind Name
399 +; DWARF3-DAG: [[GLOBAL_FUNC]] EXTERNAL FUNCTION "global_function"
400 +; DWARF3-DAG: [[NS]] EXTERNAL TYPE "ns"
401 +; DWARF3-DAG: [[MEM_FUNC]] EXTERNAL FUNCTION "C::member_function"
402 +; DWARF3-DAG: [[GLOB_VAR]] EXTERNAL VARIABLE "global_variable"
403 +; DWARF3-DAG: [[GLOB_NS_VAR]] EXTERNAL VARIABLE "ns::global_namespace_variable"
404 +; DWARF3-DAG: [[GLOB_NS_FUNC]] EXTERNAL FUNCTION "ns::global_namespace_function"
405 +; DWARF3-DAG: [[D_VAR]] EXTERNAL VARIABLE "ns::d"
406 +; DWARF3-DAG: [[STATIC_MEM_VAR]] EXTERNAL VARIABLE "C::static_member_variable"
407 +; DWARF3-DAG: [[STATIC_MEM_FUNC]] EXTERNAL FUNCTION "C::static_member_function"
410 +; DWARF3-LABEL: debug_gnu_pubtypes contents:
411 +; DWARF3: Offset Linkage Kind Name
412 +; DWARF3-DAG: [[C]] EXTERNAL TYPE "C"
413 +; DWARF3-DAG: [[D]] EXTERNAL TYPE "ns::D"
414 +; DWARF3-DAG: [[INT]] STATIC TYPE "int"
416 %struct.C = type { i8 }
417 %"struct.ns::D" = type { i32 }
419 Index: test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
420 ===================================================================
421 --- test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
422 +++ test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
424 ; RUN: llc -O0 %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t
425 ; RUN: llvm-dwarfdump %t | FileCheck %s
426 +; RUN: llc -O0 %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t -dwarf-version=3
427 +; RUN: llvm-dwarfdump %t | FileCheck %s -check-prefix=DWARF3
428 ; RUN: llc < %s -O0 -mtriple=x86_64-apple-macosx10.7 | FileCheck %s -check-prefix=ASM
432 ; CHECK: .debug_info contents:
433 ; CHECK: DW_TAG_compile_unit
434 ; CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
435 -; CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000)
436 +; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
438 ; CHECK: DW_TAG_compile_unit
439 ; CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
440 -; CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x0000003c)
441 +; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset] (0x0000003c)
443 ; CHECK: .debug_line contents:
444 ; CHECK-NEXT: Line table prologue:
446 ; CHECK: file_names[ 1] 0 0x00000000 0x00000000 simple2.c
447 ; CHECK-NOT: file_names
449 +; DWARF3: .debug_info contents:
450 +; DWARF3: DW_TAG_compile_unit
451 +; DWARF3: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
452 +; DWARF3: DW_AT_stmt_list [DW_FORM_data4] (0x00000000)
454 +; DWARF3: DW_TAG_compile_unit
455 +; DWARF3: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
456 +; DWARF3: DW_AT_stmt_list [DW_FORM_data4] (0x0000003c)
458 +; DWARF3: .debug_line contents:
459 +; DWARF3-NEXT: Line table prologue:
460 +; DWARF3-NEXT: total_length: 0x00000038
461 +; DWARF3: file_names[ 1] 0 0x00000000 0x00000000 simple.c
462 +; DWARF3: Line table prologue:
463 +; DWARF3-NEXT: total_length: 0x00000039
464 +; DWARF3: file_names[ 1] 0 0x00000000 0x00000000 simple2.c
465 +; DWARF3-NOT: file_names
468 ; ASM: L__DWARF__debug_info_begin0:
469 ; ASM: .long 0 ## DW_AT_stmt_list
470 Index: test/DebugInfo/X86/block-capture.ll
471 ===================================================================
472 --- test/DebugInfo/X86/block-capture.ll
473 +++ test/DebugInfo/X86/block-capture.ll
475 ; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
476 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
477 +; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj -dwarf-version=3
478 +; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DWARF3
480 ; Checks that we emit debug info for the block variable declare.
481 ; CHECK: DW_TAG_subprogram [3]
483 ; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "block")
484 ; CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}})
486 +; DWARF3: DW_TAG_subprogram [3]
487 +; DWARF3: DW_TAG_variable [5]
488 +; DWARF3: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "block")
489 +; DWARF3: DW_AT_location [DW_FORM_data4] ({{.*}})
491 %struct.__block_descriptor = type { i64, i64 }
492 %struct.__block_literal_generic = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
494 Index: test/DebugInfo/X86/op_deref.ll
495 ===================================================================
496 --- test/DebugInfo/X86/op_deref.ll
497 +++ test/DebugInfo/X86/op_deref.ll
499 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
500 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DW-CHECK
501 +; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj -dwarf-version=3
502 +; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DWARF3
504 ; DW-CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla")
505 ; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle
507 ; DW_AT_location lists yet.
508 ; DW-CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000)
510 +; DWARF3: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla")
511 +; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle
512 +; DW_AT_location lists yet.
513 +; DWARF3: DW_AT_location [DW_FORM_data4] (0x00000000)
515 ; Unfortunately llvm-dwarfdump can't unparse a list of DW_AT_locations
516 ; right now, so we check the asm output:
517 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s -check-prefix=ASM-CHECK
518 Index: test/DebugInfo/X86/DW_AT_stmt_list_sec_offset.ll
519 ===================================================================
520 --- test/DebugInfo/X86/DW_AT_stmt_list_sec_offset.ll
521 +++ test/DebugInfo/X86/DW_AT_stmt_list_sec_offset.ll
523 ; RUN: llc -mtriple=i686-w64-mingw32 -o %t -filetype=obj %s
524 ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s
525 +; RUN: llc -mtriple=i686-w64-mingw32 -o %t -filetype=obj -dwarf-version=3 %s
526 +; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s -check-prefix=DWARF3
528 ; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]
529 +; DWARF3: DW_AT_stmt_list [DW_FORM_data4]
532 ; clang -g -S -emit-llvm test.c -o test.ll
533 @@ -36,6 +39,6 @@ attributes #0 = { nounwind "less-precise-fpmad"="f
534 !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 ]
535 !7 = metadata !{metadata !8}
536 !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]
537 -!9 = metadata !{i32 2, metadata !"Dwarf Version", i32 3}
538 +!9 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
539 !10 = metadata !{i32 3, i32 0, metadata !4, null}
540 !11 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}