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