[CMake] export_executable_symbols also needs to add -rdynamic to the linker flags...
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DIE.cpp
1 //===--- lib/CodeGen/DIE.cpp - DWARF Info Entries -------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Data structures for DWARF info entries.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/CodeGen/DIE.h"
15 #include "DwarfCompileUnit.h"
16 #include "DwarfDebug.h"
17 #include "DwarfUnit.h"
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/CodeGen/AsmPrinter.h"
20 #include "llvm/IR/DataLayout.h"
21 #include "llvm/MC/MCAsmInfo.h"
22 #include "llvm/MC/MCContext.h"
23 #include "llvm/MC/MCStreamer.h"
24 #include "llvm/MC/MCSymbol.h"
25 #include "llvm/Support/Debug.h"
26 #include "llvm/Support/ErrorHandling.h"
27 #include "llvm/Support/Format.h"
28 #include "llvm/Support/FormattedStream.h"
29 #include "llvm/Support/LEB128.h"
30 #include "llvm/Support/MD5.h"
31 #include "llvm/Support/raw_ostream.h"
32 using namespace llvm;
33
34 //===----------------------------------------------------------------------===//
35 // DIEAbbrevData Implementation
36 //===----------------------------------------------------------------------===//
37
38 /// Profile - Used to gather unique data for the abbreviation folding set.
39 ///
40 void DIEAbbrevData::Profile(FoldingSetNodeID &ID) const {
41   // Explicitly cast to an integer type for which FoldingSetNodeID has
42   // overloads.  Otherwise MSVC 2010 thinks this call is ambiguous.
43   ID.AddInteger(unsigned(Attribute));
44   ID.AddInteger(unsigned(Form));
45 }
46
47 //===----------------------------------------------------------------------===//
48 // DIEAbbrev Implementation
49 //===----------------------------------------------------------------------===//
50
51 /// Profile - Used to gather unique data for the abbreviation folding set.
52 ///
53 void DIEAbbrev::Profile(FoldingSetNodeID &ID) const {
54   ID.AddInteger(unsigned(Tag));
55   ID.AddInteger(unsigned(Children));
56
57   // For each attribute description.
58   for (unsigned i = 0, N = Data.size(); i < N; ++i)
59     Data[i].Profile(ID);
60 }
61
62 /// Emit - Print the abbreviation using the specified asm printer.
63 ///
64 void DIEAbbrev::Emit(const AsmPrinter *AP) const {
65   // Emit its Dwarf tag type.
66   AP->EmitULEB128(Tag, dwarf::TagString(Tag));
67
68   // Emit whether it has children DIEs.
69   AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children));
70
71   // For each attribute description.
72   for (unsigned i = 0, N = Data.size(); i < N; ++i) {
73     const DIEAbbrevData &AttrData = Data[i];
74
75     // Emit attribute type.
76     AP->EmitULEB128(AttrData.getAttribute(),
77                     dwarf::AttributeString(AttrData.getAttribute()));
78
79     // Emit form type.
80     AP->EmitULEB128(AttrData.getForm(),
81                     dwarf::FormEncodingString(AttrData.getForm()));
82   }
83
84   // Mark end of abbreviation.
85   AP->EmitULEB128(0, "EOM(1)");
86   AP->EmitULEB128(0, "EOM(2)");
87 }
88
89 #ifndef NDEBUG
90 void DIEAbbrev::print(raw_ostream &O) {
91   O << "Abbreviation @"
92     << format("0x%lx", (long)(intptr_t)this)
93     << "  "
94     << dwarf::TagString(Tag)
95     << " "
96     << dwarf::ChildrenString(Children)
97     << '\n';
98
99   for (unsigned i = 0, N = Data.size(); i < N; ++i) {
100     O << "  "
101       << dwarf::AttributeString(Data[i].getAttribute())
102       << "  "
103       << dwarf::FormEncodingString(Data[i].getForm())
104       << '\n';
105   }
106 }
107 void DIEAbbrev::dump() { print(dbgs()); }
108 #endif
109
110 DIEAbbrev DIE::generateAbbrev() const {
111   DIEAbbrev Abbrev(Tag, hasChildren());
112   for (const DIEValue &V : values())
113     Abbrev.AddAttribute(V.getAttribute(), V.getForm());
114   return Abbrev;
115 }
116
117 /// Climb up the parent chain to get the unit DIE to which this DIE
118 /// belongs.
119 const DIE *DIE::getUnit() const {
120   const DIE *Cu = getUnitOrNull();
121   assert(Cu && "We should not have orphaned DIEs.");
122   return Cu;
123 }
124
125 /// Climb up the parent chain to get the unit DIE this DIE belongs
126 /// to. Return NULL if DIE is not added to an owner yet.
127 const DIE *DIE::getUnitOrNull() const {
128   const DIE *p = this;
129   while (p) {
130     if (p->getTag() == dwarf::DW_TAG_compile_unit ||
131         p->getTag() == dwarf::DW_TAG_type_unit)
132       return p;
133     p = p->getParent();
134   }
135   return nullptr;
136 }
137
138 DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const {
139   // Iterate through all the attributes until we find the one we're
140   // looking for, if we can't find it return NULL.
141   for (const auto &V : values())
142     if (V.getAttribute() == Attribute)
143       return V;
144   return DIEValue();
145 }
146
147 #ifndef NDEBUG
148 static void printValues(raw_ostream &O, const DIEValueList &Values,
149                         StringRef Type, unsigned Size, unsigned IndentCount) {
150   O << Type << ": Size: " << Size << "\n";
151
152   unsigned I = 0;
153   const std::string Indent(IndentCount, ' ');
154   for (const auto &V : Values.values()) {
155     O << Indent;
156     O << "Blk[" << I++ << "]";
157     O << "  " << dwarf::FormEncodingString(V.getForm()) << " ";
158     V.print(O);
159     O << "\n";
160   }
161 }
162
163 void DIE::print(raw_ostream &O, unsigned IndentCount) const {
164   const std::string Indent(IndentCount, ' ');
165   O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this)
166     << ", Offset: " << Offset << ", Size: " << Size << "\n";
167
168   O << Indent << dwarf::TagString(getTag()) << " "
169     << dwarf::ChildrenString(hasChildren()) << "\n";
170
171   IndentCount += 2;
172   for (const auto &V : values()) {
173     O << Indent;
174     O << dwarf::AttributeString(V.getAttribute());
175     O << "  " << dwarf::FormEncodingString(V.getForm()) << " ";
176     V.print(O);
177     O << "\n";
178   }
179   IndentCount -= 2;
180
181   for (const auto &Child : children())
182     Child.print(O, IndentCount + 4);
183
184   O << "\n";
185 }
186
187 void DIE::dump() {
188   print(dbgs());
189 }
190 #endif
191
192 void DIEValue::EmitValue(const AsmPrinter *AP) const {
193   switch (Ty) {
194   case isNone:
195     llvm_unreachable("Expected valid DIEValue");
196 #define HANDLE_DIEVALUE(T)                                                     \
197   case is##T:                                                                  \
198     getDIE##T().EmitValue(AP, Form);                                           \
199     break;
200 #include "llvm/CodeGen/DIEValue.def"
201   }
202 }
203
204 unsigned DIEValue::SizeOf(const AsmPrinter *AP) const {
205   switch (Ty) {
206   case isNone:
207     llvm_unreachable("Expected valid DIEValue");
208 #define HANDLE_DIEVALUE(T)                                                     \
209   case is##T:                                                                  \
210     return getDIE##T().SizeOf(AP, Form);
211 #include "llvm/CodeGen/DIEValue.def"
212   }
213   llvm_unreachable("Unknown DIE kind");
214 }
215
216 #ifndef NDEBUG
217 void DIEValue::print(raw_ostream &O) const {
218   switch (Ty) {
219   case isNone:
220     llvm_unreachable("Expected valid DIEValue");
221 #define HANDLE_DIEVALUE(T)                                                     \
222   case is##T:                                                                  \
223     getDIE##T().print(O);                                                      \
224     break;
225 #include "llvm/CodeGen/DIEValue.def"
226   }
227 }
228
229 void DIEValue::dump() const {
230   print(dbgs());
231 }
232 #endif
233
234 //===----------------------------------------------------------------------===//
235 // DIEInteger Implementation
236 //===----------------------------------------------------------------------===//
237
238 /// EmitValue - Emit integer of appropriate size.
239 ///
240 void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
241   unsigned Size = ~0U;
242   switch (Form) {
243   case dwarf::DW_FORM_flag_present:
244     // Emit something to keep the lines and comments in sync.
245     // FIXME: Is there a better way to do this?
246     Asm->OutStreamer->AddBlankLine();
247     return;
248   case dwarf::DW_FORM_flag:  // Fall thru
249   case dwarf::DW_FORM_ref1:  // Fall thru
250   case dwarf::DW_FORM_data1: Size = 1; break;
251   case dwarf::DW_FORM_ref2:  // Fall thru
252   case dwarf::DW_FORM_data2: Size = 2; break;
253   case dwarf::DW_FORM_sec_offset: // Fall thru
254   case dwarf::DW_FORM_strp: // Fall thru
255   case dwarf::DW_FORM_ref4:  // Fall thru
256   case dwarf::DW_FORM_data4: Size = 4; break;
257   case dwarf::DW_FORM_ref8:  // Fall thru
258   case dwarf::DW_FORM_ref_sig8:  // Fall thru
259   case dwarf::DW_FORM_data8: Size = 8; break;
260   case dwarf::DW_FORM_GNU_str_index: Asm->EmitULEB128(Integer); return;
261   case dwarf::DW_FORM_GNU_addr_index: Asm->EmitULEB128(Integer); return;
262   case dwarf::DW_FORM_udata: Asm->EmitULEB128(Integer); return;
263   case dwarf::DW_FORM_sdata: Asm->EmitSLEB128(Integer); return;
264   case dwarf::DW_FORM_addr:
265     Size = Asm->getPointerSize();
266     break;
267   case dwarf::DW_FORM_ref_addr:
268     Size = SizeOf(Asm, dwarf::DW_FORM_ref_addr);
269     break;
270   default: llvm_unreachable("DIE Value form not supported yet");
271   }
272   Asm->OutStreamer->EmitIntValue(Integer, Size);
273 }
274
275 /// SizeOf - Determine size of integer value in bytes.
276 ///
277 unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
278   switch (Form) {
279   case dwarf::DW_FORM_flag_present: return 0;
280   case dwarf::DW_FORM_flag:  // Fall thru
281   case dwarf::DW_FORM_ref1:  // Fall thru
282   case dwarf::DW_FORM_data1: return sizeof(int8_t);
283   case dwarf::DW_FORM_ref2:  // Fall thru
284   case dwarf::DW_FORM_data2: return sizeof(int16_t);
285   case dwarf::DW_FORM_sec_offset: // Fall thru
286   case dwarf::DW_FORM_strp: // Fall thru
287   case dwarf::DW_FORM_ref4:  // Fall thru
288   case dwarf::DW_FORM_data4: return sizeof(int32_t);
289   case dwarf::DW_FORM_ref8:  // Fall thru
290   case dwarf::DW_FORM_ref_sig8:  // Fall thru
291   case dwarf::DW_FORM_data8: return sizeof(int64_t);
292   case dwarf::DW_FORM_GNU_str_index: return getULEB128Size(Integer);
293   case dwarf::DW_FORM_GNU_addr_index: return getULEB128Size(Integer);
294   case dwarf::DW_FORM_udata: return getULEB128Size(Integer);
295   case dwarf::DW_FORM_sdata: return getSLEB128Size(Integer);
296   case dwarf::DW_FORM_addr:
297     return AP->getPointerSize();
298   case dwarf::DW_FORM_ref_addr:
299     if (AP->OutStreamer->getContext().getDwarfVersion() == 2)
300       return AP->getPointerSize();
301     return sizeof(int32_t);
302   default: llvm_unreachable("DIE Value form not supported yet");
303   }
304 }
305
306 #ifndef NDEBUG
307 void DIEInteger::print(raw_ostream &O) const {
308   O << "Int: " << (int64_t)Integer << "  0x";
309   O.write_hex(Integer);
310 }
311 #endif
312
313 //===----------------------------------------------------------------------===//
314 // DIEExpr Implementation
315 //===----------------------------------------------------------------------===//
316
317 /// EmitValue - Emit expression value.
318 ///
319 void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
320   AP->OutStreamer->EmitValue(Expr, SizeOf(AP, Form));
321 }
322
323 /// SizeOf - Determine size of expression value in bytes.
324 ///
325 unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
326   if (Form == dwarf::DW_FORM_data4) return 4;
327   if (Form == dwarf::DW_FORM_sec_offset) return 4;
328   if (Form == dwarf::DW_FORM_strp) return 4;
329   return AP->getPointerSize();
330 }
331
332 #ifndef NDEBUG
333 void DIEExpr::print(raw_ostream &O) const { O << "Expr: " << *Expr; }
334 #endif
335
336 //===----------------------------------------------------------------------===//
337 // DIELabel Implementation
338 //===----------------------------------------------------------------------===//
339
340 /// EmitValue - Emit label value.
341 ///
342 void DIELabel::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
343   AP->EmitLabelReference(Label, SizeOf(AP, Form),
344                          Form == dwarf::DW_FORM_strp ||
345                              Form == dwarf::DW_FORM_sec_offset ||
346                              Form == dwarf::DW_FORM_ref_addr);
347 }
348
349 /// SizeOf - Determine size of label value in bytes.
350 ///
351 unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
352   if (Form == dwarf::DW_FORM_data4) return 4;
353   if (Form == dwarf::DW_FORM_sec_offset) return 4;
354   if (Form == dwarf::DW_FORM_strp) return 4;
355   return AP->getPointerSize();
356 }
357
358 #ifndef NDEBUG
359 void DIELabel::print(raw_ostream &O) const { O << "Lbl: " << Label->getName(); }
360 #endif
361
362 //===----------------------------------------------------------------------===//
363 // DIEDelta Implementation
364 //===----------------------------------------------------------------------===//
365
366 /// EmitValue - Emit delta value.
367 ///
368 void DIEDelta::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
369   AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form));
370 }
371
372 /// SizeOf - Determine size of delta value in bytes.
373 ///
374 unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
375   if (Form == dwarf::DW_FORM_data4) return 4;
376   if (Form == dwarf::DW_FORM_sec_offset) return 4;
377   if (Form == dwarf::DW_FORM_strp) return 4;
378   return AP->getPointerSize();
379 }
380
381 #ifndef NDEBUG
382 void DIEDelta::print(raw_ostream &O) const {
383   O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
384 }
385 #endif
386
387 //===----------------------------------------------------------------------===//
388 // DIEString Implementation
389 //===----------------------------------------------------------------------===//
390
391 /// EmitValue - Emit string value.
392 ///
393 void DIEString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
394   assert(
395       (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
396       "Expected valid string form");
397
398   // Index of string in symbol table.
399   if (Form == dwarf::DW_FORM_GNU_str_index) {
400     DIEInteger(S.getIndex()).EmitValue(AP, Form);
401     return;
402   }
403
404   // Relocatable symbol.
405   assert(Form == dwarf::DW_FORM_strp);
406   if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) {
407     DIELabel(S.getSymbol()).EmitValue(AP, Form);
408     return;
409   }
410
411   // Offset into symbol table.
412   DIEInteger(S.getOffset()).EmitValue(AP, Form);
413 }
414
415 /// SizeOf - Determine size of delta value in bytes.
416 ///
417 unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
418   assert(
419       (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
420       "Expected valid string form");
421
422   // Index of string in symbol table.
423   if (Form == dwarf::DW_FORM_GNU_str_index)
424     return DIEInteger(S.getIndex()).SizeOf(AP, Form);
425
426   // Relocatable symbol.
427   if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
428     return DIELabel(S.getSymbol()).SizeOf(AP, Form);
429
430   // Offset into symbol table.
431   return DIEInteger(S.getOffset()).SizeOf(AP, Form);
432 }
433
434 #ifndef NDEBUG
435 void DIEString::print(raw_ostream &O) const {
436   O << "String: " << S.getString();
437 }
438 #endif
439
440 //===----------------------------------------------------------------------===//
441 // DIEEntry Implementation
442 //===----------------------------------------------------------------------===//
443
444 /// EmitValue - Emit debug information entry offset.
445 ///
446 void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
447
448   if (Form == dwarf::DW_FORM_ref_addr) {
449     const DwarfDebug *DD = AP->getDwarfDebug();
450     unsigned Addr = Entry->getOffset();
451     assert(!DD->useSplitDwarf() && "TODO: dwo files can't have relocations.");
452     // For DW_FORM_ref_addr, output the offset from beginning of debug info
453     // section. Entry->getOffset() returns the offset from start of the
454     // compile unit.
455     DwarfCompileUnit *CU = DD->lookupUnit(Entry->getUnit());
456     assert(CU && "CUDie should belong to a CU.");
457     Addr += CU->getDebugInfoOffset();
458     if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
459       AP->EmitLabelPlusOffset(CU->getSectionSym(), Addr,
460                               DIEEntry::getRefAddrSize(AP));
461     else
462       AP->OutStreamer->EmitIntValue(Addr, DIEEntry::getRefAddrSize(AP));
463   } else
464     AP->EmitInt32(Entry->getOffset());
465 }
466
467 unsigned DIEEntry::getRefAddrSize(const AsmPrinter *AP) {
468   // DWARF4: References that use the attribute form DW_FORM_ref_addr are
469   // specified to be four bytes in the DWARF 32-bit format and eight bytes
470   // in the DWARF 64-bit format, while DWARF Version 2 specifies that such
471   // references have the same size as an address on the target system.
472   const DwarfDebug *DD = AP->getDwarfDebug();
473   assert(DD && "Expected Dwarf Debug info to be available");
474   if (DD->getDwarfVersion() == 2)
475     return AP->getPointerSize();
476   return sizeof(int32_t);
477 }
478
479 #ifndef NDEBUG
480 void DIEEntry::print(raw_ostream &O) const {
481   O << format("Die: 0x%lx", (long)(intptr_t)&Entry);
482 }
483 #endif
484
485 //===----------------------------------------------------------------------===//
486 // DIETypeSignature Implementation
487 //===----------------------------------------------------------------------===//
488 void DIETypeSignature::EmitValue(const AsmPrinter *Asm,
489                                  dwarf::Form Form) const {
490   assert(Form == dwarf::DW_FORM_ref_sig8);
491   Asm->OutStreamer->EmitIntValue(Unit->getTypeSignature(), 8);
492 }
493
494 #ifndef NDEBUG
495 void DIETypeSignature::print(raw_ostream &O) const {
496   O << format("Type Unit: 0x%lx", Unit->getTypeSignature());
497 }
498 #endif
499
500 //===----------------------------------------------------------------------===//
501 // DIELoc Implementation
502 //===----------------------------------------------------------------------===//
503
504 /// ComputeSize - calculate the size of the location expression.
505 ///
506 unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const {
507   if (!Size) {
508     for (const auto &V : values())
509       Size += V.SizeOf(AP);
510   }
511
512   return Size;
513 }
514
515 /// EmitValue - Emit location data.
516 ///
517 void DIELoc::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
518   switch (Form) {
519   default: llvm_unreachable("Improper form for block");
520   case dwarf::DW_FORM_block1: Asm->EmitInt8(Size);    break;
521   case dwarf::DW_FORM_block2: Asm->EmitInt16(Size);   break;
522   case dwarf::DW_FORM_block4: Asm->EmitInt32(Size);   break;
523   case dwarf::DW_FORM_block:
524   case dwarf::DW_FORM_exprloc:
525     Asm->EmitULEB128(Size); break;
526   }
527
528   for (const auto &V : values())
529     V.EmitValue(Asm);
530 }
531
532 /// SizeOf - Determine size of location data in bytes.
533 ///
534 unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
535   switch (Form) {
536   case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
537   case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
538   case dwarf::DW_FORM_block4: return Size + sizeof(int32_t);
539   case dwarf::DW_FORM_block:
540   case dwarf::DW_FORM_exprloc:
541     return Size + getULEB128Size(Size);
542   default: llvm_unreachable("Improper form for block");
543   }
544 }
545
546 #ifndef NDEBUG
547 void DIELoc::print(raw_ostream &O) const {
548   printValues(O, *this, "ExprLoc", Size, 5);
549 }
550 #endif
551
552 //===----------------------------------------------------------------------===//
553 // DIEBlock Implementation
554 //===----------------------------------------------------------------------===//
555
556 /// ComputeSize - calculate the size of the block.
557 ///
558 unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const {
559   if (!Size) {
560     for (const auto &V : values())
561       Size += V.SizeOf(AP);
562   }
563
564   return Size;
565 }
566
567 /// EmitValue - Emit block data.
568 ///
569 void DIEBlock::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
570   switch (Form) {
571   default: llvm_unreachable("Improper form for block");
572   case dwarf::DW_FORM_block1: Asm->EmitInt8(Size);    break;
573   case dwarf::DW_FORM_block2: Asm->EmitInt16(Size);   break;
574   case dwarf::DW_FORM_block4: Asm->EmitInt32(Size);   break;
575   case dwarf::DW_FORM_block:  Asm->EmitULEB128(Size); break;
576   }
577
578   for (const auto &V : values())
579     V.EmitValue(Asm);
580 }
581
582 /// SizeOf - Determine size of block data in bytes.
583 ///
584 unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
585   switch (Form) {
586   case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
587   case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
588   case dwarf::DW_FORM_block4: return Size + sizeof(int32_t);
589   case dwarf::DW_FORM_block:  return Size + getULEB128Size(Size);
590   default: llvm_unreachable("Improper form for block");
591   }
592 }
593
594 #ifndef NDEBUG
595 void DIEBlock::print(raw_ostream &O) const {
596   printValues(O, *this, "Blk", Size, 5);
597 }
598 #endif
599
600 //===----------------------------------------------------------------------===//
601 // DIELocList Implementation
602 //===----------------------------------------------------------------------===//
603
604 unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
605   if (Form == dwarf::DW_FORM_data4)
606     return 4;
607   if (Form == dwarf::DW_FORM_sec_offset)
608     return 4;
609   return AP->getPointerSize();
610 }
611
612 /// EmitValue - Emit label value.
613 ///
614 void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
615   DwarfDebug *DD = AP->getDwarfDebug();
616   MCSymbol *Label = DD->getDebugLocs().getList(Index).Label;
617   AP->emitDwarfSymbolReference(Label, /*ForceOffset*/ DD->useSplitDwarf());
618 }
619
620 #ifndef NDEBUG
621 void DIELocList::print(raw_ostream &O) const { O << "LocList: " << Index; }
622 #endif