]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/patches/patch-r261991-llvm-r195391-fix-dwarf2.diff
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / patches / patch-r261991-llvm-r195391-fix-dwarf2.diff
1 Pull in r195391 from upstream llvm trunk (by Eric Christopher):
2
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.
6
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
12
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.
18
19   Patch (slightly modified) by Keith Walker!
20
21 Introduced here: http://svnweb.freebsd.org/changeset/base/261991
22
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
28  ///
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();
34  }
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),
41                   cl::init(Default));
42  
43 +static cl::opt<unsigned>
44 +DwarfVersionNumber("dwarf-version", cl::Hidden,
45 +                   cl::desc("Generate DWARF for dwarf version."),
46 +                   cl::init(0));
47 +
48  static const char *const DWARFGroupName = "DWARF Emission";
49  static const char *const DbgTimerName = "DWARF Debug Writer";
50  
51 @@ -215,7 +220,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
52    else
53      HasDwarfPubSections = DwarfPubSections == Enable;
54  
55 -  DwarfVersion = getDwarfVersionFromModule(MMI->getModule());
56 +  DwarfVersion = DwarfVersionNumber
57 +                     ? DwarfVersionNumber
58 +                     : getDwarfVersionFromModule(MMI->getModule());
59  
60    {
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);
102      else
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);
107  
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()));
121        else
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);
130  
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()));
139        else
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);
148      }
149    }
150  
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);
159    else
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);
163  
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);
174    else
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);
177  
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()));
189      else
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);
197  
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()));
204      else
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);
212    }
213  
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);
221      else
222        NewCU->addUInt(Die, dwarf::DW_AT_GNU_ranges_base, dwarf::DW_FORM_data4,
223                       0);
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);
230  }
231  
232 +/// addSectionLabel - Add a Dwarf section label attribute data and value.
233 +///
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);
238 +  else
239 +    addLabel(Die, Attribute, dwarf::DW_FORM_data4, Label);
240 +}
241 +
242 +/// addSectionOffset - Add an offset into a section attribute data and value.
243 +///
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);
248 +  else
249 +    addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
250 +}
251 +
252  /// addLabelAddress - Add a dwarf label attribute data and value using
253  /// DW_FORM_addr or DW_FORM_GNU_addr_index.
254  ///
255 @@ -264,13 +284,15 @@ void CompileUnit::addOpAddress(DIEBlock *Die, cons
256    }
257  }
258  
259 -/// addDelta - Add a label delta attribute data and value.
260 +/// addSectionDelta - Add a section label delta attribute data and value.
261  ///
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);
271 +  else
272 +    Die->addValue(Attribute, dwarf::DW_FORM_data4, Value);
273  }
274  
275  /// addDIEEntry - Add a DIE attribute data and value.
276 @@ -1768,10 +1790,8 @@ DIE *CompileUnit::constructVariableDIE(DbgVariable
277  
278    unsigned Offset = DV.getDotDebugLocOffset();
279    if (Offset != ~0U) {
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);
287      return VariableDie;
288    }
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 {
294  
295    void addLabel(DIEBlock *Die, dwarf::Form Form, const MCSymbol *Label);
296  
297 +  /// addSectionLabel - Add a Dwarf section label attribute data and value.
298 +  ///
299 +  void addSectionLabel(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Label);
300 +
301 +  /// addSectionOffset - Add an offset into a section attribute data and value.
302 +  ///
303 +  void addSectionOffset(DIE *Die, dwarf::Attribute Attribute, uint64_t Integer);
304 +
305    /// addLabelAddress - Add a dwarf label attribute data and value using
306    /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
307    ///
308 @@ -219,10 +227,9 @@ class CompileUnit {
309    ///
310    void addOpAddress(DIEBlock *Die, const MCSymbol *Label);
311  
312 -  /// addDelta - Add a label delta attribute data and value.
313 -  ///
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);
319  
320    /// addDIEEntry - Add a DIE attribute data and value.
321    ///
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
326 @@ -1,5 +1,6 @@
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'
331  ;
332  ; Generated from:
333 @@ -123,6 +124,85 @@
334  ; CHECK-DAG:  [[D]] EXTERNAL TYPE     "ns::D"
335  ; CHECK-DAG:  [[INT]] STATIC   TYPE     "int"
336  
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)
340 +
341 +; DWARF3: [[C:[0-9a-f]+]]: DW_TAG_structure_type
342 +; DWARF3-NEXT: DW_AT_name {{.*}} "C"
343 +
344 +; DWARF3: [[STATIC_MEM_DECL:[0-9a-f]+]]: DW_TAG_member
345 +; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_variable"
346 +
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"
350 +
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"
354 +
355 +; DWARF3: [[INT:[0-9a-f]+]]: DW_TAG_base_type
356 +; DWARF3-NEXT: DW_AT_name {{.*}} "int"
357 +
358 +; DWARF3: [[STATIC_MEM_VAR:[0-9a-f]+]]: DW_TAG_variable
359 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_DECL]]
360 +
361 +; DWARF3: [[GLOB_VAR:[0-9a-f]+]]: DW_TAG_variable
362 +; DWARF3-NEXT: DW_AT_name {{.*}} "global_variable"
363 +
364 +; DWARF3: [[NS:[0-9a-f]+]]: DW_TAG_namespace
365 +; DWARF3-NEXT: DW_AT_name {{.*}} "ns"
366 +
367 +; DWARF3: [[GLOB_NS_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
368 +; DWARF3-NEXT: DW_AT_name {{.*}} "global_namespace_variable"
369 +
370 +; DWARF3: [[D_VAR_DECL:[0-9a-f]+]]: DW_TAG_variable
371 +; DWARF3-NEXT: DW_AT_name {{.*}} "d"
372 +
373 +; DWARF3: [[D:[0-9a-f]+]]: DW_TAG_structure_type
374 +; DWARF3-NEXT: DW_AT_name {{.*}} "D"
375 +
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"
379 +
380 +; DWARF3: [[GLOB_NS_VAR:[0-9a-f]+]]: DW_TAG_variable
381 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[GLOB_NS_VAR_DECL]]
382 +
383 +; DWARF3: [[D_VAR:[0-9a-f]+]]: DW_TAG_variable
384 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[D_VAR_DECL]]
385 +
386 +; DWARF3: [[MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
387 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[MEM_FUNC_DECL]]
388 +
389 +; DWARF3: [[STATIC_MEM_FUNC:[0-9a-f]+]]: DW_TAG_subprogram
390 +; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_FUNC_DECL]]
391 +
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"
395 +
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"
408 +
409 +
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"
415 +
416  %struct.C = type { i8 }
417  %"struct.ns::D" = type { i32 }
418  
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
423 @@ -1,5 +1,7 @@
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
429  
430  ; rdar://13067005
431 @@ -6,11 +8,11 @@
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)
437  
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)
442  
443  ; CHECK: .debug_line contents:
444  ; CHECK-NEXT: Line table prologue:
445 @@ -21,6 +23,24 @@
446  ; CHECK: file_names[  1]    0 0x00000000 0x00000000 simple2.c
447  ; CHECK-NOT: file_names
448  
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)
453 +
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)
457 +
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
466 +
467  ; PR15408
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
474 @@ -1,5 +1,7 @@
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
479  
480  ; Checks that we emit debug info for the block variable declare.
481  ; CHECK: DW_TAG_subprogram [3]
482 @@ -7,6 +9,11 @@
483  ; CHECK: DW_AT_name [DW_FORM_strp]     ( .debug_str[{{.*}}] = "block")
484  ; CHECK: DW_AT_location [DW_FORM_sec_offset]        ({{.*}})
485  
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]        ({{.*}})
490 +
491  %struct.__block_descriptor = type { i64, i64 }
492  %struct.__block_literal_generic = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
493  
494 Index: test/DebugInfo/X86/op_deref.ll
495 ===================================================================
496 --- test/DebugInfo/X86/op_deref.ll
497 +++ test/DebugInfo/X86/op_deref.ll
498 @@ -1,5 +1,7 @@
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
503  
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
506 @@ -6,6 +8,11 @@
507  ; DW_AT_location lists yet.
508  ; DW-CHECK: DW_AT_location [DW_FORM_sec_offset]                      (0x00000000)
509  
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)
514 +
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
522 @@ -1,7 +1,10 @@
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
527  
528  ; CHECK:        DW_AT_stmt_list [DW_FORM_sec_offset]
529 +; DWARF3:        DW_AT_stmt_list [DW_FORM_data4]
530  ;
531  ; generated from:
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}