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());
83 // Emit value for DW_FORM_implicit_const.
84 if (AttrData.getForm() == dwarf::DW_FORM_implicit_const) {
85 assert(AP->getDwarfVersion() >= 5 &&
86 "DW_FORM_implicit_const is supported starting from DWARFv5");
87 AP->EmitSLEB128(AttrData.getValue());
91 // Mark end of abbreviation.
92 AP->EmitULEB128(0, "EOM(1)");
93 AP->EmitULEB128(0, "EOM(2)");
97 void DIEAbbrev::print(raw_ostream &O) {
99 << format("0x%lx", (long)(intptr_t)this)
101 << dwarf::TagString(Tag)
103 << dwarf::ChildrenString(Children)
106 for (unsigned i = 0, N = Data.size(); i < N; ++i) {
108 << dwarf::AttributeString(Data[i].getAttribute())
110 << dwarf::FormEncodingString(Data[i].getForm())
116 void DIEAbbrev::dump() { print(dbgs()); }
118 //===----------------------------------------------------------------------===//
119 // DIEAbbrevSet Implementation
120 //===----------------------------------------------------------------------===//
122 DIEAbbrevSet::~DIEAbbrevSet() {
123 for (DIEAbbrev *Abbrev : Abbreviations)
124 Abbrev->~DIEAbbrev();
127 DIEAbbrev &DIEAbbrevSet::uniqueAbbreviation(DIE &Die) {
130 DIEAbbrev Abbrev = Die.generateAbbrev();
134 if (DIEAbbrev *Existing =
135 AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
136 Die.setAbbrevNumber(Existing->getNumber());
140 // Move the abbreviation to the heap and assign a number.
141 DIEAbbrev *New = new (Alloc) DIEAbbrev(std::move(Abbrev));
142 Abbreviations.push_back(New);
143 New->setNumber(Abbreviations.size());
144 Die.setAbbrevNumber(Abbreviations.size());
146 // Store it for lookup.
147 AbbreviationsSet.InsertNode(New, InsertPos);
151 void DIEAbbrevSet::Emit(const AsmPrinter *AP, MCSection *Section) const {
152 if (!Abbreviations.empty()) {
153 // Start the debug abbrev section.
154 AP->OutStreamer->SwitchSection(Section);
155 AP->emitDwarfAbbrevs(Abbreviations);
159 //===----------------------------------------------------------------------===//
160 // DIE Implementation
161 //===----------------------------------------------------------------------===//
163 DIE *DIE::getParent() const {
164 return Owner.dyn_cast<DIE*>();
167 DIEAbbrev DIE::generateAbbrev() const {
168 DIEAbbrev Abbrev(Tag, hasChildren());
169 for (const DIEValue &V : values())
170 if (V.getForm() == dwarf::DW_FORM_implicit_const)
171 Abbrev.AddImplicitConstAttribute(V.getAttribute(),
172 V.getDIEInteger().getValue());
174 Abbrev.AddAttribute(V.getAttribute(), V.getForm());
178 unsigned DIE::getDebugSectionOffset() const {
179 const DIEUnit *Unit = getUnit();
180 assert(Unit && "DIE must be owned by a DIEUnit to get its absolute offset");
181 return Unit->getDebugSectionOffset() + getOffset();
184 const DIE *DIE::getUnitDie() const {
187 if (p->getTag() == dwarf::DW_TAG_compile_unit ||
188 p->getTag() == dwarf::DW_TAG_type_unit)
195 const DIEUnit *DIE::getUnit() const {
196 const DIE *UnitDie = getUnitDie();
198 return UnitDie->Owner.dyn_cast<DIEUnit*>();
202 DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const {
203 // Iterate through all the attributes until we find the one we're
204 // looking for, if we can't find it return NULL.
205 for (const auto &V : values())
206 if (V.getAttribute() == Attribute)
212 static void printValues(raw_ostream &O, const DIEValueList &Values,
213 StringRef Type, unsigned Size, unsigned IndentCount) {
214 O << Type << ": Size: " << Size << "\n";
217 const std::string Indent(IndentCount, ' ');
218 for (const auto &V : Values.values()) {
220 O << "Blk[" << I++ << "]";
221 O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
228 void DIE::print(raw_ostream &O, unsigned IndentCount) const {
229 const std::string Indent(IndentCount, ' ');
230 O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this)
231 << ", Offset: " << Offset << ", Size: " << Size << "\n";
233 O << Indent << dwarf::TagString(getTag()) << " "
234 << dwarf::ChildrenString(hasChildren()) << "\n";
237 for (const auto &V : values()) {
239 O << dwarf::AttributeString(V.getAttribute());
240 O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
246 for (const auto &Child : children())
247 Child.print(O, IndentCount + 4);
257 unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP,
258 DIEAbbrevSet &AbbrevSet,
260 // Unique the abbreviation and fill in the abbreviation number so this DIE
262 const DIEAbbrev &Abbrev = AbbrevSet.uniqueAbbreviation(*this);
264 // Set compile/type unit relative offset of this DIE.
267 // Add the byte size of the abbreviation code.
268 CUOffset += getULEB128Size(getAbbrevNumber());
270 // Add the byte size of all the DIE attribute values.
271 for (const auto &V : values())
272 CUOffset += V.SizeOf(AP);
274 // Let the children compute their offsets and abbreviation numbers.
277 assert(Abbrev.hasChildren() && "Children flag not set");
279 for (auto &Child : children())
280 CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset);
282 // Each child chain is terminated with a zero byte, adjust the offset.
283 CUOffset += sizeof(int8_t);
286 // Compute the byte size of this DIE and all of its children correctly. This
287 // is needed so that top level DIE can help the compile unit set its length
289 setSize(CUOffset - getOffset());
293 //===----------------------------------------------------------------------===//
294 // DIEUnit Implementation
295 //===----------------------------------------------------------------------===//
296 DIEUnit::DIEUnit(uint16_t V, uint8_t A, dwarf::Tag UnitTag)
297 : Die(UnitTag), Section(nullptr), Offset(0), Length(0), Version(V),
301 assert((UnitTag == dwarf::DW_TAG_compile_unit ||
302 UnitTag == dwarf::DW_TAG_type_unit ||
303 UnitTag == dwarf::DW_TAG_partial_unit) && "expected a unit TAG");
306 void DIEValue::EmitValue(const AsmPrinter *AP) const {
309 llvm_unreachable("Expected valid DIEValue");
310 #define HANDLE_DIEVALUE(T) \
312 getDIE##T().EmitValue(AP, Form); \
314 #include "llvm/CodeGen/DIEValue.def"
318 unsigned DIEValue::SizeOf(const AsmPrinter *AP) const {
321 llvm_unreachable("Expected valid DIEValue");
322 #define HANDLE_DIEVALUE(T) \
324 return getDIE##T().SizeOf(AP, Form);
325 #include "llvm/CodeGen/DIEValue.def"
327 llvm_unreachable("Unknown DIE kind");
331 void DIEValue::print(raw_ostream &O) const {
334 llvm_unreachable("Expected valid DIEValue");
335 #define HANDLE_DIEVALUE(T) \
337 getDIE##T().print(O); \
339 #include "llvm/CodeGen/DIEValue.def"
344 void DIEValue::dump() const {
348 //===----------------------------------------------------------------------===//
349 // DIEInteger Implementation
350 //===----------------------------------------------------------------------===//
352 /// EmitValue - Emit integer of appropriate size.
354 void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
356 case dwarf::DW_FORM_implicit_const:
358 case dwarf::DW_FORM_flag_present:
359 // Emit something to keep the lines and comments in sync.
360 // FIXME: Is there a better way to do this?
361 Asm->OutStreamer->AddBlankLine();
363 case dwarf::DW_FORM_flag:
365 case dwarf::DW_FORM_ref1:
367 case dwarf::DW_FORM_data1:
369 case dwarf::DW_FORM_ref2:
371 case dwarf::DW_FORM_data2:
373 case dwarf::DW_FORM_strp:
375 case dwarf::DW_FORM_ref4:
377 case dwarf::DW_FORM_data4:
379 case dwarf::DW_FORM_ref8:
381 case dwarf::DW_FORM_ref_sig8:
383 case dwarf::DW_FORM_data8:
385 case dwarf::DW_FORM_GNU_ref_alt:
387 case dwarf::DW_FORM_GNU_strp_alt:
389 case dwarf::DW_FORM_line_strp:
391 case dwarf::DW_FORM_sec_offset:
393 case dwarf::DW_FORM_strp_sup:
395 case dwarf::DW_FORM_ref_sup:
397 case dwarf::DW_FORM_addr:
399 case dwarf::DW_FORM_ref_addr:
400 Asm->OutStreamer->EmitIntValue(Integer, SizeOf(Asm, Form));
402 case dwarf::DW_FORM_GNU_str_index:
404 case dwarf::DW_FORM_GNU_addr_index:
406 case dwarf::DW_FORM_ref_udata:
408 case dwarf::DW_FORM_udata:
409 Asm->EmitULEB128(Integer);
411 case dwarf::DW_FORM_sdata:
412 Asm->EmitSLEB128(Integer);
414 default: llvm_unreachable("DIE Value form not supported yet");
418 /// SizeOf - Determine size of integer value in bytes.
420 unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
422 case dwarf::DW_FORM_implicit_const: LLVM_FALLTHROUGH;
423 case dwarf::DW_FORM_flag_present: return 0;
424 case dwarf::DW_FORM_flag: LLVM_FALLTHROUGH;
425 case dwarf::DW_FORM_ref1: LLVM_FALLTHROUGH;
426 case dwarf::DW_FORM_data1: return sizeof(int8_t);
427 case dwarf::DW_FORM_ref2: LLVM_FALLTHROUGH;
428 case dwarf::DW_FORM_data2: return sizeof(int16_t);
429 case dwarf::DW_FORM_ref4: LLVM_FALLTHROUGH;
430 case dwarf::DW_FORM_data4: return sizeof(int32_t);
431 case dwarf::DW_FORM_ref8: LLVM_FALLTHROUGH;
432 case dwarf::DW_FORM_ref_sig8: LLVM_FALLTHROUGH;
433 case dwarf::DW_FORM_data8: return sizeof(int64_t);
434 case dwarf::DW_FORM_ref_addr:
435 if (AP->getDwarfVersion() == 2)
436 return AP->getPointerSize();
438 case dwarf::DW_FORM_strp:
440 case dwarf::DW_FORM_GNU_ref_alt:
442 case dwarf::DW_FORM_GNU_strp_alt:
444 case dwarf::DW_FORM_line_strp:
446 case dwarf::DW_FORM_sec_offset:
448 case dwarf::DW_FORM_strp_sup:
450 case dwarf::DW_FORM_ref_sup:
451 switch (AP->OutStreamer->getContext().getDwarfFormat()) {
457 llvm_unreachable("Invalid DWARF format");
458 case dwarf::DW_FORM_GNU_str_index:
460 case dwarf::DW_FORM_GNU_addr_index:
462 case dwarf::DW_FORM_ref_udata:
464 case dwarf::DW_FORM_udata:
465 return getULEB128Size(Integer);
466 case dwarf::DW_FORM_sdata:
467 return getSLEB128Size(Integer);
468 case dwarf::DW_FORM_addr:
469 return AP->getPointerSize();
470 default: llvm_unreachable("DIE Value form not supported yet");
475 void DIEInteger::print(raw_ostream &O) const {
476 O << "Int: " << (int64_t)Integer << " 0x";
477 O.write_hex(Integer);
480 //===----------------------------------------------------------------------===//
481 // DIEExpr Implementation
482 //===----------------------------------------------------------------------===//
484 /// EmitValue - Emit expression value.
486 void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
487 AP->EmitDebugValue(Expr, SizeOf(AP, Form));
490 /// SizeOf - Determine size of expression value in bytes.
492 unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
493 if (Form == dwarf::DW_FORM_data4) return 4;
494 if (Form == dwarf::DW_FORM_sec_offset) return 4;
495 if (Form == dwarf::DW_FORM_strp) return 4;
496 return AP->getPointerSize();
500 void DIEExpr::print(raw_ostream &O) const { O << "Expr: " << *Expr; }
502 //===----------------------------------------------------------------------===//
503 // DIELabel Implementation
504 //===----------------------------------------------------------------------===//
506 /// EmitValue - Emit label value.
508 void DIELabel::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
509 AP->EmitLabelReference(Label, SizeOf(AP, Form),
510 Form == dwarf::DW_FORM_strp ||
511 Form == dwarf::DW_FORM_sec_offset ||
512 Form == dwarf::DW_FORM_ref_addr ||
513 Form == dwarf::DW_FORM_data4);
516 /// SizeOf - Determine size of label value in bytes.
518 unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
519 if (Form == dwarf::DW_FORM_data4) return 4;
520 if (Form == dwarf::DW_FORM_sec_offset) return 4;
521 if (Form == dwarf::DW_FORM_strp) return 4;
522 return AP->getPointerSize();
526 void DIELabel::print(raw_ostream &O) const { O << "Lbl: " << Label->getName(); }
528 //===----------------------------------------------------------------------===//
529 // DIEDelta Implementation
530 //===----------------------------------------------------------------------===//
532 /// EmitValue - Emit delta value.
534 void DIEDelta::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
535 AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form));
538 /// SizeOf - Determine size of delta value in bytes.
540 unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
541 if (Form == dwarf::DW_FORM_data4) return 4;
542 if (Form == dwarf::DW_FORM_sec_offset) return 4;
543 if (Form == dwarf::DW_FORM_strp) return 4;
544 return AP->getPointerSize();
548 void DIEDelta::print(raw_ostream &O) const {
549 O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
552 //===----------------------------------------------------------------------===//
553 // DIEString Implementation
554 //===----------------------------------------------------------------------===//
556 /// EmitValue - Emit string value.
558 void DIEString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
560 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
561 "Expected valid string form");
563 // Index of string in symbol table.
564 if (Form == dwarf::DW_FORM_GNU_str_index) {
565 DIEInteger(S.getIndex()).EmitValue(AP, Form);
569 // Relocatable symbol.
570 assert(Form == dwarf::DW_FORM_strp);
571 if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) {
572 DIELabel(S.getSymbol()).EmitValue(AP, Form);
576 // Offset into symbol table.
577 DIEInteger(S.getOffset()).EmitValue(AP, Form);
580 /// SizeOf - Determine size of delta value in bytes.
582 unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
584 (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
585 "Expected valid string form");
587 // Index of string in symbol table.
588 if (Form == dwarf::DW_FORM_GNU_str_index)
589 return DIEInteger(S.getIndex()).SizeOf(AP, Form);
591 // Relocatable symbol.
592 if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
593 return DIELabel(S.getSymbol()).SizeOf(AP, Form);
595 // Offset into symbol table.
596 return DIEInteger(S.getOffset()).SizeOf(AP, Form);
600 void DIEString::print(raw_ostream &O) const {
601 O << "String: " << S.getString();
604 //===----------------------------------------------------------------------===//
605 // DIEInlineString Implementation
606 //===----------------------------------------------------------------------===//
607 void DIEInlineString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
608 if (Form == dwarf::DW_FORM_string) {
614 llvm_unreachable("Expected valid string form");
617 unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
618 // Emit string bytes + NULL byte.
623 void DIEInlineString::print(raw_ostream &O) const {
624 O << "InlineString: " << S;
627 //===----------------------------------------------------------------------===//
628 // DIEEntry Implementation
629 //===----------------------------------------------------------------------===//
631 /// EmitValue - Emit debug information entry offset.
633 void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
636 case dwarf::DW_FORM_ref1:
637 case dwarf::DW_FORM_ref2:
638 case dwarf::DW_FORM_ref4:
639 case dwarf::DW_FORM_ref8:
640 AP->OutStreamer->EmitIntValue(Entry->getOffset(), SizeOf(AP, Form));
643 case dwarf::DW_FORM_ref_udata:
644 AP->EmitULEB128(Entry->getOffset());
647 case dwarf::DW_FORM_ref_addr: {
648 // Get the absolute offset for this DIE within the debug info/types section.
649 unsigned Addr = Entry->getDebugSectionOffset();
650 if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) {
651 const DwarfDebug *DD = AP->getDwarfDebug();
653 assert(!DD->useSplitDwarf() &&
654 "TODO: dwo files can't have relocations.");
655 const DIEUnit *Unit = Entry->getUnit();
656 assert(Unit && "CUDie should belong to a CU.");
657 MCSection *Section = Unit->getSection();
659 const MCSymbol *SectionSym = Section->getBeginSymbol();
660 AP->EmitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form), true);
664 AP->OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form));
668 llvm_unreachable("Improper form for DIE reference");
672 unsigned DIEEntry::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
674 case dwarf::DW_FORM_ref1:
676 case dwarf::DW_FORM_ref2:
678 case dwarf::DW_FORM_ref4:
680 case dwarf::DW_FORM_ref8:
682 case dwarf::DW_FORM_ref_udata:
683 return getULEB128Size(Entry->getOffset());
684 case dwarf::DW_FORM_ref_addr:
685 if (AP->getDwarfVersion() == 2)
686 return AP->getPointerSize();
687 switch (AP->OutStreamer->getContext().getDwarfFormat()) {
693 llvm_unreachable("Invalid DWARF format");
696 llvm_unreachable("Improper form for DIE reference");
701 void DIEEntry::print(raw_ostream &O) const {
702 O << format("Die: 0x%lx", (long)(intptr_t)&Entry);
705 //===----------------------------------------------------------------------===//
706 // DIELoc Implementation
707 //===----------------------------------------------------------------------===//
709 /// ComputeSize - calculate the size of the location expression.
711 unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const {
713 for (const auto &V : values())
714 Size += V.SizeOf(AP);
720 /// EmitValue - Emit location data.
722 void DIELoc::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
724 default: llvm_unreachable("Improper form for block");
725 case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
726 case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break;
727 case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break;
728 case dwarf::DW_FORM_block:
729 case dwarf::DW_FORM_exprloc:
730 Asm->EmitULEB128(Size); break;
733 for (const auto &V : values())
737 /// SizeOf - Determine size of location data in bytes.
739 unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
741 case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
742 case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
743 case dwarf::DW_FORM_block4: return Size + sizeof(int32_t);
744 case dwarf::DW_FORM_block:
745 case dwarf::DW_FORM_exprloc:
746 return Size + getULEB128Size(Size);
747 default: llvm_unreachable("Improper form for block");
752 void DIELoc::print(raw_ostream &O) const {
753 printValues(O, *this, "ExprLoc", Size, 5);
756 //===----------------------------------------------------------------------===//
757 // DIEBlock Implementation
758 //===----------------------------------------------------------------------===//
760 /// ComputeSize - calculate the size of the block.
762 unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const {
764 for (const auto &V : values())
765 Size += V.SizeOf(AP);
771 /// EmitValue - Emit block data.
773 void DIEBlock::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
775 default: llvm_unreachable("Improper form for block");
776 case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
777 case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break;
778 case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break;
779 case dwarf::DW_FORM_block: Asm->EmitULEB128(Size); break;
782 for (const auto &V : values())
786 /// SizeOf - Determine size of block data in bytes.
788 unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
790 case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
791 case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
792 case dwarf::DW_FORM_block4: return Size + sizeof(int32_t);
793 case dwarf::DW_FORM_block: return Size + getULEB128Size(Size);
794 default: llvm_unreachable("Improper form for block");
799 void DIEBlock::print(raw_ostream &O) const {
800 printValues(O, *this, "Blk", Size, 5);
803 //===----------------------------------------------------------------------===//
804 // DIELocList Implementation
805 //===----------------------------------------------------------------------===//
807 unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
808 if (Form == dwarf::DW_FORM_data4)
810 if (Form == dwarf::DW_FORM_sec_offset)
812 return AP->getPointerSize();
815 /// EmitValue - Emit label value.
817 void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
818 DwarfDebug *DD = AP->getDwarfDebug();
819 MCSymbol *Label = DD->getDebugLocs().getList(Index).Label;
820 AP->emitDwarfSymbolReference(Label, /*ForceOffset*/ DD->useSplitDwarf());
824 void DIELocList::print(raw_ostream &O) const { O << "LocList: " << Index; }