1 //===--- lib/CodeGen/DIE.cpp - DWARF Info Entries -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Data structures for DWARF info entries.
12 //===----------------------------------------------------------------------===//
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"
34 //===----------------------------------------------------------------------===//
35 // DIEAbbrevData Implementation
36 //===----------------------------------------------------------------------===//
38 /// Profile - Used to gather unique data for the abbreviation folding set.
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));
47 //===----------------------------------------------------------------------===//
48 // DIEAbbrev Implementation
49 //===----------------------------------------------------------------------===//
51 /// Profile - Used to gather unique data for the abbreviation folding set.
53 void DIEAbbrev::Profile(FoldingSetNodeID &ID) const {
54 ID.AddInteger(unsigned(Tag));
55 ID.AddInteger(unsigned(Children));
57 // For each attribute description.
58 for (unsigned i = 0, N = Data.size(); i < N; ++i)
62 /// Emit - Print the abbreviation using the specified asm printer.
64 void DIEAbbrev::Emit(const AsmPrinter *AP) const {
65 // Emit its Dwarf tag type.
66 AP->EmitULEB128(Tag, dwarf::TagString(Tag).data());
68 // Emit whether it has children DIEs.
69 AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children).data());
71 // For each attribute description.
72 for (unsigned i = 0, N = Data.size(); i < N; ++i) {
73 const DIEAbbrevData &AttrData = Data[i];
75 // Emit attribute type.
76 AP->EmitULEB128(AttrData.getAttribute(),
77 dwarf::AttributeString(AttrData.getAttribute()).data());
80 AP->EmitULEB128(AttrData.getForm(),
81 dwarf::FormEncodingString(AttrData.getForm()).data());
84 // Mark end of abbreviation.
85 AP->EmitULEB128(0, "EOM(1)");
86 AP->EmitULEB128(0, "EOM(2)");
90 void DIEAbbrev::print(raw_ostream &O) {
92 << format("0x%lx", (long)(intptr_t)this)
94 << dwarf::TagString(Tag)
96 << dwarf::ChildrenString(Children)
99 for (unsigned i = 0, N = Data.size(); i < N; ++i) {
101 << dwarf::AttributeString(Data[i].getAttribute())
103 << dwarf::FormEncodingString(Data[i].getForm())
109 void DIEAbbrev::dump() { print(dbgs()); }
111 //===----------------------------------------------------------------------===//
112 // DIEAbbrevSet Implementation
113 //===----------------------------------------------------------------------===//
115 DIEAbbrevSet::~DIEAbbrevSet() {
116 for (DIEAbbrev *Abbrev : Abbreviations)
117 Abbrev->~DIEAbbrev();
120 DIEAbbrev &DIEAbbrevSet::uniqueAbbreviation(DIE &Die) {
123 DIEAbbrev Abbrev = Die.generateAbbrev();
127 if (DIEAbbrev *Existing =
128 AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
129 Die.setAbbrevNumber(Existing->getNumber());
133 // Move the abbreviation to the heap and assign a number.
134 DIEAbbrev *New = new (Alloc) DIEAbbrev(std::move(Abbrev));
135 Abbreviations.push_back(New);
136 New->setNumber(Abbreviations.size());
137 Die.setAbbrevNumber(Abbreviations.size());
139 // Store it for lookup.
140 AbbreviationsSet.InsertNode(New, InsertPos);
144 void DIEAbbrevSet::Emit(const AsmPrinter *AP, MCSection *Section) const {
145 if (!Abbreviations.empty()) {
146 // Start the debug abbrev section.
147 AP->OutStreamer->SwitchSection(Section);
148 AP->emitDwarfAbbrevs(Abbreviations);
152 //===----------------------------------------------------------------------===//
153 // DIE Implementation
154 //===----------------------------------------------------------------------===//
156 DIE *DIE::getParent() const {
157 return Owner.dyn_cast<DIE*>();
160 DIEAbbrev DIE::generateAbbrev() const {
161 DIEAbbrev Abbrev(Tag, hasChildren());
162 for (const DIEValue &V : values())
163 Abbrev.AddAttribute(V.getAttribute(), V.getForm());
167 unsigned DIE::getDebugSectionOffset() const {
168 const DIEUnit *Unit = getUnit();
169 assert(Unit && "DIE must be owned by a DIEUnit to get its absolute offset");
170 return Unit->getDebugSectionOffset() + getOffset();
173 const DIE *DIE::getUnitDie() const {
176 if (p->getTag() == dwarf::DW_TAG_compile_unit ||
177 p->getTag() == dwarf::DW_TAG_type_unit)
184 const DIEUnit *DIE::getUnit() const {
185 const DIE *UnitDie = getUnitDie();
187 return UnitDie->Owner.dyn_cast<DIEUnit*>();
191 DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const {
192 // Iterate through all the attributes until we find the one we're
193 // looking for, if we can't find it return NULL.
194 for (const auto &V : values())
195 if (V.getAttribute() == Attribute)
201 static void printValues(raw_ostream &O, const DIEValueList &Values,
202 StringRef Type, unsigned Size, unsigned IndentCount) {
203 O << Type << ": Size: " << Size << "\n";
206 const std::string Indent(IndentCount, ' ');
207 for (const auto &V : Values.values()) {
209 O << "Blk[" << I++ << "]";
210 O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
217 void DIE::print(raw_ostream &O, unsigned IndentCount) const {
218 const std::string Indent(IndentCount, ' ');
219 O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this)
220 << ", Offset: " << Offset << ", Size: " << Size << "\n";
222 O << Indent << dwarf::TagString(getTag()) << " "
223 << dwarf::ChildrenString(hasChildren()) << "\n";
226 for (const auto &V : values()) {
228 O << dwarf::AttributeString(V.getAttribute());
229 O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
235 for (const auto &Child : children())
236 Child.print(O, IndentCount + 4);
246 unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP,
247 DIEAbbrevSet &AbbrevSet,
249 // Unique the abbreviation and fill in the abbreviation number so this DIE
251 const DIEAbbrev &Abbrev = AbbrevSet.uniqueAbbreviation(*this);
253 // Set compile/type unit relative offset of this DIE.
256 // Add the byte size of the abbreviation code.
257 CUOffset += getULEB128Size(getAbbrevNumber());
259 // Add the byte size of all the DIE attribute values.
260 for (const auto &V : values())
261 CUOffset += V.SizeOf(AP);
263 // Let the children compute their offsets and abbreviation numbers.
266 assert(Abbrev.hasChildren() && "Children flag not set");
268 for (auto &Child : children())
269 CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset);
271 // Each child chain is terminated with a zero byte, adjust the offset.
272 CUOffset += sizeof(int8_t);
275 // Compute the byte size of this DIE and all of its children correctly. This
276 // is needed so that top level DIE can help the compile unit set its length
278 setSize(CUOffset - getOffset());
282 //===----------------------------------------------------------------------===//
283 // DIEUnit Implementation
284 //===----------------------------------------------------------------------===//
285 DIEUnit::DIEUnit(uint16_t V, uint8_t A, dwarf::Tag UnitTag)
286 : Die(UnitTag), Section(nullptr), Offset(0), Length(0), Version(V),
290 assert((UnitTag == dwarf::DW_TAG_compile_unit ||
291 UnitTag == dwarf::DW_TAG_type_unit ||
292 UnitTag == dwarf::DW_TAG_partial_unit) && "expected a unit TAG");
295 void DIEValue::EmitValue(const AsmPrinter *AP) const {
298 llvm_unreachable("Expected valid DIEValue");
299 #define HANDLE_DIEVALUE(T) \
301 getDIE##T().EmitValue(AP, Form); \
303 #include "llvm/CodeGen/DIEValue.def"
307 unsigned DIEValue::SizeOf(const AsmPrinter *AP) const {
310 llvm_unreachable("Expected valid DIEValue");
311 #define HANDLE_DIEVALUE(T) \
313 return getDIE##T().SizeOf(AP, Form);
314 #include "llvm/CodeGen/DIEValue.def"
316 llvm_unreachable("Unknown DIE kind");
320 void DIEValue::print(raw_ostream &O) const {
323 llvm_unreachable("Expected valid DIEValue");
324 #define HANDLE_DIEVALUE(T) \
326 getDIE##T().print(O); \
328 #include "llvm/CodeGen/DIEValue.def"
333 void DIEValue::dump() const {
337 //===----------------------------------------------------------------------===//
338 // DIEInteger Implementation
339 //===----------------------------------------------------------------------===//
341 /// EmitValue - Emit integer of appropriate size.
343 void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
345 case dwarf::DW_FORM_flag_present:
346 // Emit something to keep the lines and comments in sync.
347 // FIXME: Is there a better way to do this?
348 Asm->OutStreamer->AddBlankLine();
350 case dwarf::DW_FORM_flag:
352 case dwarf::DW_FORM_ref1:
354 case dwarf::DW_FORM_data1:
356 case dwarf::DW_FORM_ref2:
358 case dwarf::DW_FORM_data2:
360 case dwarf::DW_FORM_strp:
362 case dwarf::DW_FORM_ref4:
364 case dwarf::DW_FORM_data4:
366 case dwarf::DW_FORM_ref8:
368 case dwarf::DW_FORM_ref_sig8:
370 case dwarf::DW_FORM_data8:
372 case dwarf::DW_FORM_GNU_ref_alt:
374 case dwarf::DW_FORM_GNU_strp_alt:
376 case dwarf::DW_FORM_line_strp:
378 case dwarf::DW_FORM_sec_offset:
380 case dwarf::DW_FORM_strp_sup:
382 case dwarf::DW_FORM_ref_sup:
384 case dwarf::DW_FORM_addr:
386 case dwarf::DW_FORM_ref_addr:
387 Asm->OutStreamer->EmitIntValue(Integer, SizeOf(Asm, Form));
389 case dwarf::DW_FORM_GNU_str_index:
391 case dwarf::DW_FORM_GNU_addr_index:
393 case dwarf::DW_FORM_ref_udata:
395 case dwarf::DW_FORM_udata:
396 Asm->EmitULEB128(Integer);
398 case dwarf::DW_FORM_sdata:
399 Asm->EmitSLEB128(Integer);
401 default: llvm_unreachable("DIE Value form not supported yet");
405 /// SizeOf - Determine size of integer value in bytes.
407 unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
409 case dwarf::DW_FORM_flag_present: return 0;
410 case dwarf::DW_FORM_flag: LLVM_FALLTHROUGH;
411 case dwarf::DW_FORM_ref1: LLVM_FALLTHROUGH;
412 case dwarf::DW_FORM_data1: return sizeof(int8_t);
413 case dwarf::DW_FORM_ref2: LLVM_FALLTHROUGH;
414 case dwarf::DW_FORM_data2: return sizeof(int16_t);
415 case dwarf::DW_FORM_ref4: LLVM_FALLTHROUGH;
416 case dwarf::DW_FORM_data4: return sizeof(int32_t);
417 case dwarf::DW_FORM_ref8: LLVM_FALLTHROUGH;
418 case dwarf::DW_FORM_ref_sig8: LLVM_FALLTHROUGH;
419 case dwarf::DW_FORM_data8: return sizeof(int64_t);
420 case dwarf::DW_FORM_ref_addr:
421 if (AP->getDwarfVersion() == 2)
422 return AP->getPointerSize();
424 case dwarf::DW_FORM_strp:
426 case dwarf::DW_FORM_GNU_ref_alt:
428 case dwarf::DW_FORM_GNU_strp_alt:
430 case dwarf::DW_FORM_line_strp:
432 case dwarf::DW_FORM_sec_offset:
434 case dwarf::DW_FORM_strp_sup:
436 case dwarf::DW_FORM_ref_sup:
437 switch (AP->OutStreamer->getContext().getDwarfFormat()) {
443 llvm_unreachable("Invalid DWARF format");
444 case dwarf::DW_FORM_GNU_str_index:
446 case dwarf::DW_FORM_GNU_addr_index:
448 case dwarf::DW_FORM_ref_udata:
450 case dwarf::DW_FORM_udata:
451 return getULEB128Size(Integer);
452 case dwarf::DW_FORM_sdata:
453 return getSLEB128Size(Integer);
454 case dwarf::DW_FORM_addr:
455 return AP->getPointerSize();
456 default: llvm_unreachable("DIE Value form not supported yet");
461 void DIEInteger::print(raw_ostream &O) const {
462 O << "Int: " << (int64_t)Integer << " 0x";
463 O.write_hex(Integer);
466 //===----------------------------------------------------------------------===//
467 // DIEExpr Implementation
468 //===----------------------------------------------------------------------===//
470 /// EmitValue - Emit expression value.
472 void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
473 AP->OutStreamer->EmitValue(Expr, SizeOf(AP, Form));
476 /// SizeOf - Determine size of expression value in bytes.
478 unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
479 if (Form == dwarf::DW_FORM_data4) return 4;
480 if (Form == dwarf::DW_FORM_sec_offset) return 4;
481 if (Form == dwarf::DW_FORM_strp) return 4;
482 return AP->getPointerSize();
486 void DIEExpr::print(raw_ostream &O) const { O << "Expr: " << *Expr; }
488 //===----------------------------------------------------------------------===//
489 // DIELabel Implementation
490 //===----------------------------------------------------------------------===//
492 /// EmitValue - Emit label value.
494 void DIELabel::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
495 AP->EmitLabelReference(Label, SizeOf(AP, Form),
496 Form == dwarf::DW_FORM_strp ||
497 Form == dwarf::DW_FORM_sec_offset ||
498 Form == dwarf::DW_FORM_ref_addr ||
499 Form == dwarf::DW_FORM_data4);
502 /// SizeOf - Determine size of label value in bytes.
504 unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
505 if (Form == dwarf::DW_FORM_data4) return 4;
506 if (Form == dwarf::DW_FORM_sec_offset) return 4;
507 if (Form == dwarf::DW_FORM_strp) return 4;
508 return AP->getPointerSize();
512 void DIELabel::print(raw_ostream &O) const { O << "Lbl: " << Label->getName(); }
514 //===----------------------------------------------------------------------===//
515 // DIEDelta Implementation
516 //===----------------------------------------------------------------------===//
518 /// EmitValue - Emit delta value.
520 void DIEDelta::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
521 AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form));
524 /// SizeOf - Determine size of delta value in bytes.
526 unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
527 if (Form == dwarf::DW_FORM_data4) return 4;
528 if (Form == dwarf::DW_FORM_sec_offset) return 4;
529 if (Form == dwarf::DW_FORM_strp) return 4;
530 return AP->getPointerSize();
534 void DIEDelta::print(raw_ostream &O) const {
535 O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
538 //===----------------------------------------------------------------------===//
539 // DIEString Implementation
540 //===----------------------------------------------------------------------===//
542 /// EmitValue - Emit string value.
544 void DIEString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
546 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
547 "Expected valid string form");
549 // Index of string in symbol table.
550 if (Form == dwarf::DW_FORM_GNU_str_index) {
551 DIEInteger(S.getIndex()).EmitValue(AP, Form);
555 // Relocatable symbol.
556 assert(Form == dwarf::DW_FORM_strp);
557 if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) {
558 DIELabel(S.getSymbol()).EmitValue(AP, Form);
562 // Offset into symbol table.
563 DIEInteger(S.getOffset()).EmitValue(AP, Form);
566 /// SizeOf - Determine size of delta value in bytes.
568 unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
570 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
571 "Expected valid string form");
573 // Index of string in symbol table.
574 if (Form == dwarf::DW_FORM_GNU_str_index)
575 return DIEInteger(S.getIndex()).SizeOf(AP, Form);
577 // Relocatable symbol.
578 if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
579 return DIELabel(S.getSymbol()).SizeOf(AP, Form);
581 // Offset into symbol table.
582 return DIEInteger(S.getOffset()).SizeOf(AP, Form);
586 void DIEString::print(raw_ostream &O) const {
587 O << "String: " << S.getString();
590 //===----------------------------------------------------------------------===//
591 // DIEInlineString Implementation
592 //===----------------------------------------------------------------------===//
593 void DIEInlineString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
594 if (Form == dwarf::DW_FORM_string) {
600 llvm_unreachable("Expected valid string form");
603 unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
604 // Emit string bytes + NULL byte.
609 void DIEInlineString::print(raw_ostream &O) const {
610 O << "InlineString: " << S;
613 //===----------------------------------------------------------------------===//
614 // DIEEntry Implementation
615 //===----------------------------------------------------------------------===//
617 /// EmitValue - Emit debug information entry offset.
619 void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
622 case dwarf::DW_FORM_ref1:
623 case dwarf::DW_FORM_ref2:
624 case dwarf::DW_FORM_ref4:
625 case dwarf::DW_FORM_ref8:
626 AP->OutStreamer->EmitIntValue(Entry->getOffset(), SizeOf(AP, Form));
629 case dwarf::DW_FORM_ref_udata:
630 AP->EmitULEB128(Entry->getOffset());
633 case dwarf::DW_FORM_ref_addr: {
634 // Get the absolute offset for this DIE within the debug info/types section.
635 unsigned Addr = Entry->getDebugSectionOffset();
636 if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) {
637 const DwarfDebug *DD = AP->getDwarfDebug();
639 assert(!DD->useSplitDwarf() &&
640 "TODO: dwo files can't have relocations.");
641 const DIEUnit *Unit = Entry->getUnit();
642 assert(Unit && "CUDie should belong to a CU.");
643 MCSection *Section = Unit->getSection();
645 const MCSymbol *SectionSym = Section->getBeginSymbol();
646 AP->EmitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form), true);
650 AP->OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form));
654 llvm_unreachable("Improper form for DIE reference");
658 unsigned DIEEntry::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
660 case dwarf::DW_FORM_ref1:
662 case dwarf::DW_FORM_ref2:
664 case dwarf::DW_FORM_ref4:
666 case dwarf::DW_FORM_ref8:
668 case dwarf::DW_FORM_ref_udata:
669 return getULEB128Size(Entry->getOffset());
670 case dwarf::DW_FORM_ref_addr:
671 if (AP->getDwarfVersion() == 2)
672 return AP->getPointerSize();
673 switch (AP->OutStreamer->getContext().getDwarfFormat()) {
679 llvm_unreachable("Invalid DWARF format");
682 llvm_unreachable("Improper form for DIE reference");
687 void DIEEntry::print(raw_ostream &O) const {
688 O << format("Die: 0x%lx", (long)(intptr_t)&Entry);
691 //===----------------------------------------------------------------------===//
692 // DIELoc Implementation
693 //===----------------------------------------------------------------------===//
695 /// ComputeSize - calculate the size of the location expression.
697 unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const {
699 for (const auto &V : values())
700 Size += V.SizeOf(AP);
706 /// EmitValue - Emit location data.
708 void DIELoc::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
710 default: llvm_unreachable("Improper form for block");
711 case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
712 case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break;
713 case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break;
714 case dwarf::DW_FORM_block:
715 case dwarf::DW_FORM_exprloc:
716 Asm->EmitULEB128(Size); break;
719 for (const auto &V : values())
723 /// SizeOf - Determine size of location data in bytes.
725 unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
727 case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
728 case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
729 case dwarf::DW_FORM_block4: return Size + sizeof(int32_t);
730 case dwarf::DW_FORM_block:
731 case dwarf::DW_FORM_exprloc:
732 return Size + getULEB128Size(Size);
733 default: llvm_unreachable("Improper form for block");
738 void DIELoc::print(raw_ostream &O) const {
739 printValues(O, *this, "ExprLoc", Size, 5);
742 //===----------------------------------------------------------------------===//
743 // DIEBlock Implementation
744 //===----------------------------------------------------------------------===//
746 /// ComputeSize - calculate the size of the block.
748 unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const {
750 for (const auto &V : values())
751 Size += V.SizeOf(AP);
757 /// EmitValue - Emit block data.
759 void DIEBlock::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
761 default: llvm_unreachable("Improper form for block");
762 case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
763 case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break;
764 case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break;
765 case dwarf::DW_FORM_block: Asm->EmitULEB128(Size); break;
768 for (const auto &V : values())
772 /// SizeOf - Determine size of block data in bytes.
774 unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
776 case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
777 case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
778 case dwarf::DW_FORM_block4: return Size + sizeof(int32_t);
779 case dwarf::DW_FORM_block: return Size + getULEB128Size(Size);
780 default: llvm_unreachable("Improper form for block");
785 void DIEBlock::print(raw_ostream &O) const {
786 printValues(O, *this, "Blk", Size, 5);
789 //===----------------------------------------------------------------------===//
790 // DIELocList Implementation
791 //===----------------------------------------------------------------------===//
793 unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
794 if (Form == dwarf::DW_FORM_data4)
796 if (Form == dwarf::DW_FORM_sec_offset)
798 return AP->getPointerSize();
801 /// EmitValue - Emit label value.
803 void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
804 DwarfDebug *DD = AP->getDwarfDebug();
805 MCSymbol *Label = DD->getDebugLocs().getList(Index).Label;
806 AP->emitDwarfSymbolReference(Label, /*ForceOffset*/ DD->useSplitDwarf());
810 void DIELocList::print(raw_ostream &O) const { O << "LocList: " << Index; }