Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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. |
Eric Christopher | b800ff7 | 2013-01-07 22:40:45 +0000 | [diff] [blame] | 11 | // |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Frederic Riss | e541e0b | 2015-01-05 21:29:41 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/DIE.h" |
David Blaikie | 37c5231 | 2014-10-04 15:49:50 +0000 | [diff] [blame] | 15 | #include "DwarfCompileUnit.h" |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 16 | #include "DwarfDebug.h" |
David Blaikie | 47f615e | 2013-12-17 23:32:35 +0000 | [diff] [blame] | 17 | #include "DwarfUnit.h" |
Benjamin Kramer | 4d128a2 | 2010-01-17 07:46:39 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/Twine.h" |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/AsmPrinter.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 20 | #include "llvm/IR/DataLayout.h" |
Chris Lattner | 7b26fce | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCAsmInfo.h" |
Rafael Espindola | 74dd854 | 2014-10-21 00:25:49 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCContext.h" |
Chris Lattner | 71601e8 | 2010-01-20 07:41:15 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MCStreamer.h" |
Chris Lattner | 06d45f6 | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCSymbol.h" |
David Greene | 8bc072c | 2009-12-24 00:27:55 +0000 | [diff] [blame] | 25 | #include "llvm/Support/Debug.h" |
Torok Edwin | 56d0659 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 26 | #include "llvm/Support/ErrorHandling.h" |
Chris Lattner | 7472571 | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 27 | #include "llvm/Support/Format.h" |
Chris Lattner | f5c834f | 2010-01-22 22:09:00 +0000 | [diff] [blame] | 28 | #include "llvm/Support/FormattedStream.h" |
Logan Chien | 5b776b7 | 2014-02-22 14:00:39 +0000 | [diff] [blame] | 29 | #include "llvm/Support/LEB128.h" |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 30 | #include "llvm/Support/MD5.h" |
Benjamin Kramer | 799003b | 2015-03-23 19:32:43 +0000 | [diff] [blame] | 31 | #include "llvm/Support/raw_ostream.h" |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 32 | using namespace llvm; |
| 33 | |
Paul Robinson | 70b3453 | 2017-04-20 19:16:51 +0000 | [diff] [blame] | 34 | #define DEBUG_TYPE "dwarfdebug" |
| 35 | |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 36 | //===----------------------------------------------------------------------===// |
| 37 | // DIEAbbrevData Implementation |
| 38 | //===----------------------------------------------------------------------===// |
| 39 | |
| 40 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 41 | /// |
| 42 | void DIEAbbrevData::Profile(FoldingSetNodeID &ID) const { |
Reid Kleckner | ad65f10 | 2013-10-21 19:18:31 +0000 | [diff] [blame] | 43 | // Explicitly cast to an integer type for which FoldingSetNodeID has |
| 44 | // overloads. Otherwise MSVC 2010 thinks this call is ambiguous. |
| 45 | ID.AddInteger(unsigned(Attribute)); |
| 46 | ID.AddInteger(unsigned(Form)); |
Victor Leschuk | d7bfa40 | 2017-03-01 22:13:42 +0000 | [diff] [blame] | 47 | if (Form == dwarf::DW_FORM_implicit_const) |
| 48 | ID.AddInteger(Value); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | //===----------------------------------------------------------------------===// |
| 52 | // DIEAbbrev Implementation |
| 53 | //===----------------------------------------------------------------------===// |
| 54 | |
| 55 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 56 | /// |
| 57 | void DIEAbbrev::Profile(FoldingSetNodeID &ID) const { |
Reid Kleckner | ad65f10 | 2013-10-21 19:18:31 +0000 | [diff] [blame] | 58 | ID.AddInteger(unsigned(Tag)); |
Eric Christopher | e8f1072 | 2014-03-05 01:44:58 +0000 | [diff] [blame] | 59 | ID.AddInteger(unsigned(Children)); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 60 | |
| 61 | // For each attribute description. |
| 62 | for (unsigned i = 0, N = Data.size(); i < N; ++i) |
| 63 | Data[i].Profile(ID); |
| 64 | } |
| 65 | |
| 66 | /// Emit - Print the abbreviation using the specified asm printer. |
| 67 | /// |
Frederic Riss | cd04434 | 2015-03-04 02:30:08 +0000 | [diff] [blame] | 68 | void DIEAbbrev::Emit(const AsmPrinter *AP) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 69 | // Emit its Dwarf tag type. |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 70 | AP->EmitULEB128(Tag, dwarf::TagString(Tag).data()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 71 | |
| 72 | // Emit whether it has children DIEs. |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 73 | AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children).data()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 74 | |
| 75 | // For each attribute description. |
| 76 | for (unsigned i = 0, N = Data.size(); i < N; ++i) { |
| 77 | const DIEAbbrevData &AttrData = Data[i]; |
| 78 | |
| 79 | // Emit attribute type. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 80 | AP->EmitULEB128(AttrData.getAttribute(), |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 81 | dwarf::AttributeString(AttrData.getAttribute()).data()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 82 | |
| 83 | // Emit form type. |
Paul Robinson | 70b3453 | 2017-04-20 19:16:51 +0000 | [diff] [blame] | 84 | #ifndef NDEBUG |
| 85 | // Could be an assertion, but this way we can see the failing form code |
| 86 | // easily, which helps track down where it came from. |
| 87 | if (!dwarf::isValidFormForVersion(AttrData.getForm(), |
| 88 | AP->getDwarfVersion())) { |
| 89 | DEBUG(dbgs() << "Invalid form " << format("0x%x", AttrData.getForm()) |
| 90 | << " for DWARF version " << AP->getDwarfVersion() << "\n"); |
| 91 | llvm_unreachable("Invalid form for specified DWARF version"); |
| 92 | } |
| 93 | #endif |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 94 | AP->EmitULEB128(AttrData.getForm(), |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 95 | dwarf::FormEncodingString(AttrData.getForm()).data()); |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 96 | |
| 97 | // Emit value for DW_FORM_implicit_const. |
Paul Robinson | 70b3453 | 2017-04-20 19:16:51 +0000 | [diff] [blame] | 98 | if (AttrData.getForm() == dwarf::DW_FORM_implicit_const) |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 99 | AP->EmitSLEB128(AttrData.getValue()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | // Mark end of abbreviation. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 103 | AP->EmitULEB128(0, "EOM(1)"); |
| 104 | AP->EmitULEB128(0, "EOM(2)"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 107 | LLVM_DUMP_METHOD |
Sam Clegg | 705f798 | 2017-06-21 22:19:17 +0000 | [diff] [blame] | 108 | void DIEAbbrev::print(raw_ostream &O) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 109 | O << "Abbreviation @" |
Chris Lattner | 7472571 | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 110 | << format("0x%lx", (long)(intptr_t)this) |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 111 | << " " |
| 112 | << dwarf::TagString(Tag) |
| 113 | << " " |
Eric Christopher | e8f1072 | 2014-03-05 01:44:58 +0000 | [diff] [blame] | 114 | << dwarf::ChildrenString(Children) |
Chris Lattner | 7472571 | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 115 | << '\n'; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 116 | |
| 117 | for (unsigned i = 0, N = Data.size(); i < N; ++i) { |
| 118 | O << " " |
| 119 | << dwarf::AttributeString(Data[i].getAttribute()) |
| 120 | << " " |
Victor Leschuk | d7bfa40 | 2017-03-01 22:13:42 +0000 | [diff] [blame] | 121 | << dwarf::FormEncodingString(Data[i].getForm()); |
| 122 | |
| 123 | if (Data[i].getForm() == dwarf::DW_FORM_implicit_const) |
| 124 | O << " " << Data[i].getValue(); |
| 125 | |
| 126 | O << '\n'; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 127 | } |
| 128 | } |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 129 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 130 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Sam Clegg | 705f798 | 2017-06-21 22:19:17 +0000 | [diff] [blame] | 131 | LLVM_DUMP_METHOD void DIEAbbrev::dump() const { |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 132 | print(dbgs()); |
| 133 | } |
| 134 | #endif |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 135 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 136 | //===----------------------------------------------------------------------===// |
| 137 | // DIEAbbrevSet Implementation |
| 138 | //===----------------------------------------------------------------------===// |
| 139 | |
| 140 | DIEAbbrevSet::~DIEAbbrevSet() { |
| 141 | for (DIEAbbrev *Abbrev : Abbreviations) |
| 142 | Abbrev->~DIEAbbrev(); |
| 143 | } |
| 144 | |
| 145 | DIEAbbrev &DIEAbbrevSet::uniqueAbbreviation(DIE &Die) { |
| 146 | |
| 147 | FoldingSetNodeID ID; |
| 148 | DIEAbbrev Abbrev = Die.generateAbbrev(); |
| 149 | Abbrev.Profile(ID); |
| 150 | |
| 151 | void *InsertPos; |
| 152 | if (DIEAbbrev *Existing = |
| 153 | AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) { |
| 154 | Die.setAbbrevNumber(Existing->getNumber()); |
| 155 | return *Existing; |
| 156 | } |
| 157 | |
| 158 | // Move the abbreviation to the heap and assign a number. |
| 159 | DIEAbbrev *New = new (Alloc) DIEAbbrev(std::move(Abbrev)); |
| 160 | Abbreviations.push_back(New); |
| 161 | New->setNumber(Abbreviations.size()); |
| 162 | Die.setAbbrevNumber(Abbreviations.size()); |
| 163 | |
| 164 | // Store it for lookup. |
| 165 | AbbreviationsSet.InsertNode(New, InsertPos); |
| 166 | return *New; |
| 167 | } |
| 168 | |
| 169 | void DIEAbbrevSet::Emit(const AsmPrinter *AP, MCSection *Section) const { |
| 170 | if (!Abbreviations.empty()) { |
| 171 | // Start the debug abbrev section. |
| 172 | AP->OutStreamer->SwitchSection(Section); |
| 173 | AP->emitDwarfAbbrevs(Abbreviations); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | //===----------------------------------------------------------------------===// |
| 178 | // DIE Implementation |
| 179 | //===----------------------------------------------------------------------===// |
| 180 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 181 | DIE *DIE::getParent() const { |
| 182 | return Owner.dyn_cast<DIE*>(); |
| 183 | } |
| 184 | |
Duncan P. N. Exon Smith | 815a6eb5 | 2015-05-27 22:31:41 +0000 | [diff] [blame] | 185 | DIEAbbrev DIE::generateAbbrev() const { |
| 186 | DIEAbbrev Abbrev(Tag, hasChildren()); |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 187 | for (const DIEValue &V : values()) |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 188 | if (V.getForm() == dwarf::DW_FORM_implicit_const) |
| 189 | Abbrev.AddImplicitConstAttribute(V.getAttribute(), |
| 190 | V.getDIEInteger().getValue()); |
| 191 | else |
| 192 | Abbrev.AddAttribute(V.getAttribute(), V.getForm()); |
Duncan P. N. Exon Smith | 815a6eb5 | 2015-05-27 22:31:41 +0000 | [diff] [blame] | 193 | return Abbrev; |
| 194 | } |
| 195 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 196 | unsigned DIE::getDebugSectionOffset() const { |
| 197 | const DIEUnit *Unit = getUnit(); |
| 198 | assert(Unit && "DIE must be owned by a DIEUnit to get its absolute offset"); |
Benjamin Kramer | 6a8704c | 2016-12-01 19:10:10 +0000 | [diff] [blame] | 199 | return Unit->getDebugSectionOffset() + getOffset(); |
Manman Ren | 4dbdc90 | 2013-10-31 17:54:35 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 202 | const DIE *DIE::getUnitDie() const { |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 203 | const DIE *p = this; |
| 204 | while (p) { |
David Blaikie | 409dd9c | 2013-11-19 23:08:21 +0000 | [diff] [blame] | 205 | if (p->getTag() == dwarf::DW_TAG_compile_unit || |
| 206 | p->getTag() == dwarf::DW_TAG_type_unit) |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 207 | return p; |
| 208 | p = p->getParent(); |
| 209 | } |
Craig Topper | 353eda4 | 2014-04-24 06:44:33 +0000 | [diff] [blame] | 210 | return nullptr; |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 213 | const DIEUnit *DIE::getUnit() const { |
| 214 | const DIE *UnitDie = getUnitDie(); |
| 215 | if (UnitDie) |
| 216 | return UnitDie->Owner.dyn_cast<DIEUnit*>(); |
| 217 | return nullptr; |
| 218 | } |
| 219 | |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 220 | DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const { |
Eric Christopher | 8552e22 | 2013-08-07 01:18:33 +0000 | [diff] [blame] | 221 | // Iterate through all the attributes until we find the one we're |
| 222 | // looking for, if we can't find it return NULL. |
Duncan P. N. Exon Smith | 88a8fc5 | 2015-05-27 22:44:06 +0000 | [diff] [blame] | 223 | for (const auto &V : values()) |
| 224 | if (V.getAttribute() == Attribute) |
| 225 | return V; |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 226 | return DIEValue(); |
Eric Christopher | 8552e22 | 2013-08-07 01:18:33 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 229 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 230 | static void printValues(raw_ostream &O, const DIEValueList &Values, |
| 231 | StringRef Type, unsigned Size, unsigned IndentCount) { |
| 232 | O << Type << ": Size: " << Size << "\n"; |
| 233 | |
| 234 | unsigned I = 0; |
| 235 | const std::string Indent(IndentCount, ' '); |
| 236 | for (const auto &V : Values.values()) { |
| 237 | O << Indent; |
| 238 | O << "Blk[" << I++ << "]"; |
| 239 | O << " " << dwarf::FormEncodingString(V.getForm()) << " "; |
| 240 | V.print(O); |
| 241 | O << "\n"; |
| 242 | } |
| 243 | } |
| 244 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 245 | LLVM_DUMP_METHOD |
Eric Christopher | 6c6de84 | 2013-05-06 17:50:50 +0000 | [diff] [blame] | 246 | void DIE::print(raw_ostream &O, unsigned IndentCount) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 247 | const std::string Indent(IndentCount, ' '); |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 248 | O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this) |
| 249 | << ", Offset: " << Offset << ", Size: " << Size << "\n"; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 250 | |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 251 | O << Indent << dwarf::TagString(getTag()) << " " |
| 252 | << dwarf::ChildrenString(hasChildren()) << "\n"; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 253 | |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 254 | IndentCount += 2; |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 255 | for (const auto &V : values()) { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 256 | O << Indent; |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 257 | O << dwarf::AttributeString(V.getAttribute()); |
Duncan P. N. Exon Smith | 4fb1f9c | 2015-06-25 23:46:41 +0000 | [diff] [blame] | 258 | O << " " << dwarf::FormEncodingString(V.getForm()) << " "; |
| 259 | V.print(O); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 260 | O << "\n"; |
| 261 | } |
| 262 | IndentCount -= 2; |
| 263 | |
Duncan P. N. Exon Smith | 827200c | 2015-06-25 23:52:10 +0000 | [diff] [blame] | 264 | for (const auto &Child : children()) |
| 265 | Child.print(O, IndentCount + 4); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 266 | |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 267 | O << "\n"; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 268 | } |
| 269 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 270 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Sam Clegg | 705f798 | 2017-06-21 22:19:17 +0000 | [diff] [blame] | 271 | LLVM_DUMP_METHOD void DIE::dump() const { |
David Greene | 8bc072c | 2009-12-24 00:27:55 +0000 | [diff] [blame] | 272 | print(dbgs()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 273 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 274 | #endif |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 275 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 276 | unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP, |
| 277 | DIEAbbrevSet &AbbrevSet, |
| 278 | unsigned CUOffset) { |
| 279 | // Unique the abbreviation and fill in the abbreviation number so this DIE |
| 280 | // can be emitted. |
| 281 | const DIEAbbrev &Abbrev = AbbrevSet.uniqueAbbreviation(*this); |
| 282 | |
| 283 | // Set compile/type unit relative offset of this DIE. |
| 284 | setOffset(CUOffset); |
| 285 | |
| 286 | // Add the byte size of the abbreviation code. |
| 287 | CUOffset += getULEB128Size(getAbbrevNumber()); |
| 288 | |
| 289 | // Add the byte size of all the DIE attribute values. |
| 290 | for (const auto &V : values()) |
| 291 | CUOffset += V.SizeOf(AP); |
| 292 | |
| 293 | // Let the children compute their offsets and abbreviation numbers. |
| 294 | if (hasChildren()) { |
| 295 | (void)Abbrev; |
| 296 | assert(Abbrev.hasChildren() && "Children flag not set"); |
| 297 | |
| 298 | for (auto &Child : children()) |
| 299 | CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset); |
| 300 | |
| 301 | // Each child chain is terminated with a zero byte, adjust the offset. |
| 302 | CUOffset += sizeof(int8_t); |
| 303 | } |
| 304 | |
| 305 | // Compute the byte size of this DIE and all of its children correctly. This |
| 306 | // is needed so that top level DIE can help the compile unit set its length |
| 307 | // correctly. |
| 308 | setSize(CUOffset - getOffset()); |
| 309 | return CUOffset; |
| 310 | } |
| 311 | |
| 312 | //===----------------------------------------------------------------------===// |
| 313 | // DIEUnit Implementation |
| 314 | //===----------------------------------------------------------------------===// |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 315 | DIEUnit::DIEUnit(uint16_t V, uint8_t A, dwarf::Tag UnitTag) |
| 316 | : Die(UnitTag), Section(nullptr), Offset(0), Length(0), Version(V), |
| 317 | AddrSize(A) |
| 318 | { |
David Blaikie | e40caae | 2016-12-01 21:59:09 +0000 | [diff] [blame] | 319 | Die.Owner = this; |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 320 | assert((UnitTag == dwarf::DW_TAG_compile_unit || |
| 321 | UnitTag == dwarf::DW_TAG_type_unit || |
| 322 | UnitTag == dwarf::DW_TAG_partial_unit) && "expected a unit TAG"); |
| 323 | } |
| 324 | |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 325 | void DIEValue::EmitValue(const AsmPrinter *AP) const { |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 326 | switch (Ty) { |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 327 | case isNone: |
| 328 | llvm_unreachable("Expected valid DIEValue"); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 329 | #define HANDLE_DIEVALUE(T) \ |
| 330 | case is##T: \ |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 331 | getDIE##T().EmitValue(AP, Form); \ |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 332 | break; |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 333 | #include "llvm/CodeGen/DIEValue.def" |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 337 | unsigned DIEValue::SizeOf(const AsmPrinter *AP) const { |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 338 | switch (Ty) { |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 339 | case isNone: |
| 340 | llvm_unreachable("Expected valid DIEValue"); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 341 | #define HANDLE_DIEVALUE(T) \ |
| 342 | case is##T: \ |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 343 | return getDIE##T().SizeOf(AP, Form); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 344 | #include "llvm/CodeGen/DIEValue.def" |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 345 | } |
Aaron Ballman | c681c3d | 2015-05-23 14:46:49 +0000 | [diff] [blame] | 346 | llvm_unreachable("Unknown DIE kind"); |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 347 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 348 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 349 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 350 | void DIEValue::print(raw_ostream &O) const { |
| 351 | switch (Ty) { |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 352 | case isNone: |
| 353 | llvm_unreachable("Expected valid DIEValue"); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 354 | #define HANDLE_DIEVALUE(T) \ |
| 355 | case is##T: \ |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 356 | getDIE##T().print(O); \ |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 357 | break; |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 358 | #include "llvm/CodeGen/DIEValue.def" |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 359 | } |
| 360 | } |
| 361 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 362 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 363 | LLVM_DUMP_METHOD void DIEValue::dump() const { |
David Greene | 8bc072c | 2009-12-24 00:27:55 +0000 | [diff] [blame] | 364 | print(dbgs()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 365 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 366 | #endif |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 367 | |
| 368 | //===----------------------------------------------------------------------===// |
| 369 | // DIEInteger Implementation |
| 370 | //===----------------------------------------------------------------------===// |
| 371 | |
| 372 | /// EmitValue - Emit integer of appropriate size. |
| 373 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 374 | void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 375 | switch (Form) { |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 376 | case dwarf::DW_FORM_implicit_const: |
Eric Christopher | bb69a27 | 2012-08-24 01:14:27 +0000 | [diff] [blame] | 377 | case dwarf::DW_FORM_flag_present: |
| 378 | // Emit something to keep the lines and comments in sync. |
| 379 | // FIXME: Is there a better way to do this? |
Lang Hames | 9ff69c8 | 2015-04-24 19:11:51 +0000 | [diff] [blame] | 380 | Asm->OutStreamer->AddBlankLine(); |
Eric Christopher | bb69a27 | 2012-08-24 01:14:27 +0000 | [diff] [blame] | 381 | return; |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 382 | case dwarf::DW_FORM_flag: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 383 | case dwarf::DW_FORM_ref1: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 384 | case dwarf::DW_FORM_data1: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 385 | case dwarf::DW_FORM_strx1: |
| 386 | case dwarf::DW_FORM_addrx1: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 387 | case dwarf::DW_FORM_ref2: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 388 | case dwarf::DW_FORM_data2: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 389 | case dwarf::DW_FORM_strx2: |
| 390 | case dwarf::DW_FORM_addrx2: |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 391 | case dwarf::DW_FORM_strx3: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 392 | case dwarf::DW_FORM_strp: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 393 | case dwarf::DW_FORM_ref4: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 394 | case dwarf::DW_FORM_data4: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 395 | case dwarf::DW_FORM_ref_sup4: |
| 396 | case dwarf::DW_FORM_strx4: |
| 397 | case dwarf::DW_FORM_addrx4: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 398 | case dwarf::DW_FORM_ref8: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 399 | case dwarf::DW_FORM_ref_sig8: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 400 | case dwarf::DW_FORM_data8: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 401 | case dwarf::DW_FORM_ref_sup8: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 402 | case dwarf::DW_FORM_GNU_ref_alt: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 403 | case dwarf::DW_FORM_GNU_strp_alt: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 404 | case dwarf::DW_FORM_line_strp: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 405 | case dwarf::DW_FORM_sec_offset: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 406 | case dwarf::DW_FORM_strp_sup: |
Eric Christopher | e8a7b1b | 2012-09-10 23:34:03 +0000 | [diff] [blame] | 407 | case dwarf::DW_FORM_addr: |
Frederic Riss | ee17fb9b | 2015-03-04 22:07:36 +0000 | [diff] [blame] | 408 | case dwarf::DW_FORM_ref_addr: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 409 | Asm->OutStreamer->EmitIntValue(Integer, SizeOf(Asm, Form)); |
| 410 | return; |
| 411 | case dwarf::DW_FORM_GNU_str_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 412 | case dwarf::DW_FORM_GNU_addr_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 413 | case dwarf::DW_FORM_ref_udata: |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 414 | case dwarf::DW_FORM_strx: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 415 | case dwarf::DW_FORM_udata: |
| 416 | Asm->EmitULEB128(Integer); |
| 417 | return; |
| 418 | case dwarf::DW_FORM_sdata: |
| 419 | Asm->EmitSLEB128(Integer); |
| 420 | return; |
Torok Edwin | fbcc663 | 2009-07-14 16:55:14 +0000 | [diff] [blame] | 421 | default: llvm_unreachable("DIE Value form not supported yet"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | |
| 425 | /// SizeOf - Determine size of integer value in bytes. |
| 426 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 427 | unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Pavel Labath | 8ed6582b | 2018-03-14 11:31:17 +0000 | [diff] [blame] | 428 | dwarf::FormParams Params = {0, 0, dwarf::DWARF32}; |
Pavel Labath | 322711f | 2018-03-14 09:39:54 +0000 | [diff] [blame] | 429 | if (AP) |
| 430 | Params = {AP->getDwarfVersion(), uint8_t(AP->getPointerSize()), |
| 431 | AP->OutStreamer->getContext().getDwarfFormat()}; |
| 432 | |
| 433 | if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params)) |
| 434 | return *FixedSize; |
| 435 | |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 436 | switch (Form) { |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 437 | case dwarf::DW_FORM_GNU_str_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 438 | case dwarf::DW_FORM_GNU_addr_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 439 | case dwarf::DW_FORM_ref_udata: |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 440 | case dwarf::DW_FORM_strx: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 441 | case dwarf::DW_FORM_udata: |
| 442 | return getULEB128Size(Integer); |
| 443 | case dwarf::DW_FORM_sdata: |
| 444 | return getSLEB128Size(Integer); |
David Blaikie | 46a9f01 | 2012-01-20 21:51:11 +0000 | [diff] [blame] | 445 | default: llvm_unreachable("DIE Value form not supported yet"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 446 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 447 | } |
| 448 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 449 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 450 | void DIEInteger::print(raw_ostream &O) const { |
Benjamin Kramer | f3da529 | 2011-11-05 08:57:40 +0000 | [diff] [blame] | 451 | O << "Int: " << (int64_t)Integer << " 0x"; |
| 452 | O.write_hex(Integer); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 453 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 454 | |
| 455 | //===----------------------------------------------------------------------===// |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 456 | // DIEExpr Implementation |
| 457 | //===----------------------------------------------------------------------===// |
| 458 | |
| 459 | /// EmitValue - Emit expression value. |
| 460 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 461 | void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Simon Dardis | 2e8cdbd | 2017-02-08 19:03:46 +0000 | [diff] [blame] | 462 | AP->EmitDebugThreadLocal(Expr, SizeOf(AP, Form)); |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | /// SizeOf - Determine size of expression value in bytes. |
| 466 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 467 | unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 468 | if (Form == dwarf::DW_FORM_data4) return 4; |
| 469 | if (Form == dwarf::DW_FORM_sec_offset) return 4; |
| 470 | if (Form == dwarf::DW_FORM_strp) return 4; |
Mehdi Amini | 1660cab | 2015-07-16 05:59:25 +0000 | [diff] [blame] | 471 | return AP->getPointerSize(); |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 472 | } |
| 473 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 474 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 475 | void DIEExpr::print(raw_ostream &O) const { O << "Expr: " << *Expr; } |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 476 | |
| 477 | //===----------------------------------------------------------------------===// |
Chris Lattner | 8dcf41e | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 478 | // DIELabel Implementation |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 479 | //===----------------------------------------------------------------------===// |
| 480 | |
| 481 | /// EmitValue - Emit label value. |
| 482 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 483 | void DIELabel::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
David Blaikie | f244319 | 2013-10-21 17:28:37 +0000 | [diff] [blame] | 484 | AP->EmitLabelReference(Label, SizeOf(AP, Form), |
| 485 | Form == dwarf::DW_FORM_strp || |
| 486 | Form == dwarf::DW_FORM_sec_offset || |
Keno Fischer | f7d84ee | 2017-01-02 03:00:19 +0000 | [diff] [blame] | 487 | Form == dwarf::DW_FORM_ref_addr || |
| 488 | Form == dwarf::DW_FORM_data4); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | /// SizeOf - Determine size of label value in bytes. |
| 492 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 493 | unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 494 | if (Form == dwarf::DW_FORM_data4) return 4; |
Eric Christopher | 4c7765f | 2013-01-17 03:00:04 +0000 | [diff] [blame] | 495 | if (Form == dwarf::DW_FORM_sec_offset) return 4; |
Nick Lewycky | d59c0ca | 2011-10-27 06:44:11 +0000 | [diff] [blame] | 496 | if (Form == dwarf::DW_FORM_strp) return 4; |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 497 | return AP->MAI->getCodePointerSize(); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 498 | } |
| 499 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 500 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 501 | void DIELabel::print(raw_ostream &O) const { O << "Lbl: " << Label->getName(); } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 502 | |
| 503 | //===----------------------------------------------------------------------===// |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 504 | // DIEDelta Implementation |
| 505 | //===----------------------------------------------------------------------===// |
| 506 | |
| 507 | /// EmitValue - Emit delta value. |
| 508 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 509 | void DIEDelta::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Chris Lattner | 5a00dea | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 510 | AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form)); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /// SizeOf - Determine size of delta value in bytes. |
| 514 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 515 | unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 516 | if (Form == dwarf::DW_FORM_data4) return 4; |
Eric Christopher | 33ff697 | 2013-11-21 23:46:41 +0000 | [diff] [blame] | 517 | if (Form == dwarf::DW_FORM_sec_offset) return 4; |
Nick Lewycky | d59c0ca | 2011-10-27 06:44:11 +0000 | [diff] [blame] | 518 | if (Form == dwarf::DW_FORM_strp) return 4; |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 519 | return AP->MAI->getCodePointerSize(); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 522 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 523 | void DIEDelta::print(raw_ostream &O) const { |
Chris Lattner | bc9210c | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 524 | O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName(); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 525 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 526 | |
| 527 | //===----------------------------------------------------------------------===// |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 528 | // DIEString Implementation |
| 529 | //===----------------------------------------------------------------------===// |
| 530 | |
| 531 | /// EmitValue - Emit string value. |
| 532 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 533 | void DIEString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 534 | // Index of string in symbol table. |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 535 | switch (Form) { |
| 536 | case dwarf::DW_FORM_GNU_str_index: |
| 537 | case dwarf::DW_FORM_strx: |
| 538 | case dwarf::DW_FORM_strx1: |
| 539 | case dwarf::DW_FORM_strx2: |
| 540 | case dwarf::DW_FORM_strx3: |
| 541 | case dwarf::DW_FORM_strx4: |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 542 | DIEInteger(S.getIndex()).EmitValue(AP, Form); |
| 543 | return; |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 544 | case dwarf::DW_FORM_strp: |
| 545 | if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) |
| 546 | DIELabel(S.getSymbol()).EmitValue(AP, Form); |
| 547 | else |
| 548 | DIEInteger(S.getOffset()).EmitValue(AP, Form); |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 549 | return; |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 550 | default: |
| 551 | llvm_unreachable("Expected valid string form"); |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 552 | } |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | /// SizeOf - Determine size of delta value in bytes. |
| 556 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 557 | unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 558 | // Index of string in symbol table. |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 559 | switch (Form) { |
| 560 | case dwarf::DW_FORM_GNU_str_index: |
| 561 | case dwarf::DW_FORM_strx: |
| 562 | case dwarf::DW_FORM_strx1: |
| 563 | case dwarf::DW_FORM_strx2: |
| 564 | case dwarf::DW_FORM_strx3: |
| 565 | case dwarf::DW_FORM_strx4: |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 566 | return DIEInteger(S.getIndex()).SizeOf(AP, Form); |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 567 | case dwarf::DW_FORM_strp: |
| 568 | if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) |
| 569 | return DIELabel(S.getSymbol()).SizeOf(AP, Form); |
| 570 | return DIEInteger(S.getOffset()).SizeOf(AP, Form); |
| 571 | default: |
| 572 | llvm_unreachable("Expected valid string form"); |
| 573 | } |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 574 | } |
| 575 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 576 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 577 | void DIEString::print(raw_ostream &O) const { |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 578 | O << "String: " << S.getString(); |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 579 | } |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 580 | |
| 581 | //===----------------------------------------------------------------------===// |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 582 | // DIEInlineString Implementation |
| 583 | //===----------------------------------------------------------------------===// |
| 584 | void DIEInlineString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
| 585 | if (Form == dwarf::DW_FORM_string) { |
| 586 | for (char ch : S) |
Rafael Espindola | 4b4d85f | 2018-03-29 23:32:54 +0000 | [diff] [blame] | 587 | AP->emitInt8(ch); |
| 588 | AP->emitInt8(0); |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 589 | return; |
| 590 | } |
| 591 | llvm_unreachable("Expected valid string form"); |
| 592 | } |
| 593 | |
| 594 | unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
| 595 | // Emit string bytes + NULL byte. |
| 596 | return S.size() + 1; |
| 597 | } |
| 598 | |
| 599 | LLVM_DUMP_METHOD |
| 600 | void DIEInlineString::print(raw_ostream &O) const { |
Benjamin Kramer | eedc405 | 2016-12-09 13:33:41 +0000 | [diff] [blame] | 601 | O << "InlineString: " << S; |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | //===----------------------------------------------------------------------===// |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 605 | // DIEEntry Implementation |
| 606 | //===----------------------------------------------------------------------===// |
| 607 | |
| 608 | /// EmitValue - Emit debug information entry offset. |
| 609 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 610 | void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Eric Christopher | dd50838 | 2014-03-06 00:00:56 +0000 | [diff] [blame] | 611 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 612 | switch (Form) { |
| 613 | case dwarf::DW_FORM_ref1: |
| 614 | case dwarf::DW_FORM_ref2: |
| 615 | case dwarf::DW_FORM_ref4: |
| 616 | case dwarf::DW_FORM_ref8: |
| 617 | AP->OutStreamer->EmitIntValue(Entry->getOffset(), SizeOf(AP, Form)); |
| 618 | return; |
| 619 | |
| 620 | case dwarf::DW_FORM_ref_udata: |
| 621 | AP->EmitULEB128(Entry->getOffset()); |
| 622 | return; |
| 623 | |
| 624 | case dwarf::DW_FORM_ref_addr: { |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 625 | // Get the absolute offset for this DIE within the debug info/types section. |
| 626 | unsigned Addr = Entry->getDebugSectionOffset(); |
David Blaikie | 85366ac | 2017-04-22 07:53:44 +0000 | [diff] [blame] | 627 | if (const MCSymbol *SectionSym = |
| 628 | Entry->getUnit()->getCrossSectionRelativeBaseAddress()) { |
| 629 | AP->EmitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form), true); |
| 630 | return; |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 631 | } |
David Blaikie | 85366ac | 2017-04-22 07:53:44 +0000 | [diff] [blame] | 632 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 633 | AP->OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form)); |
| 634 | return; |
| 635 | } |
| 636 | default: |
| 637 | llvm_unreachable("Improper form for DIE reference"); |
| 638 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 639 | } |
| 640 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 641 | unsigned DIEEntry::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
| 642 | switch (Form) { |
| 643 | case dwarf::DW_FORM_ref1: |
| 644 | return 1; |
| 645 | case dwarf::DW_FORM_ref2: |
| 646 | return 2; |
| 647 | case dwarf::DW_FORM_ref4: |
| 648 | return 4; |
| 649 | case dwarf::DW_FORM_ref8: |
| 650 | return 8; |
| 651 | case dwarf::DW_FORM_ref_udata: |
| 652 | return getULEB128Size(Entry->getOffset()); |
| 653 | case dwarf::DW_FORM_ref_addr: |
| 654 | if (AP->getDwarfVersion() == 2) |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 655 | return AP->MAI->getCodePointerSize(); |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 656 | switch (AP->OutStreamer->getContext().getDwarfFormat()) { |
| 657 | case dwarf::DWARF32: |
| 658 | return 4; |
| 659 | case dwarf::DWARF64: |
| 660 | return 8; |
| 661 | } |
| 662 | llvm_unreachable("Invalid DWARF format"); |
| 663 | |
| 664 | default: |
| 665 | llvm_unreachable("Improper form for DIE reference"); |
| 666 | } |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 667 | } |
| 668 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 669 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 670 | void DIEEntry::print(raw_ostream &O) const { |
David Blaikie | 8dbcc3f | 2014-04-25 19:33:43 +0000 | [diff] [blame] | 671 | O << format("Die: 0x%lx", (long)(intptr_t)&Entry); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 672 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 673 | |
| 674 | //===----------------------------------------------------------------------===// |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 675 | // DIELoc Implementation |
| 676 | //===----------------------------------------------------------------------===// |
| 677 | |
| 678 | /// ComputeSize - calculate the size of the location expression. |
| 679 | /// |
Frederic Riss | cd04434 | 2015-03-04 02:30:08 +0000 | [diff] [blame] | 680 | unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const { |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 681 | if (!Size) { |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 682 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 683 | Size += V.SizeOf(AP); |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 684 | } |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 685 | |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 686 | return Size; |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | /// EmitValue - Emit location data. |
| 690 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 691 | void DIELoc::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 692 | switch (Form) { |
| 693 | default: llvm_unreachable("Improper form for block"); |
Rafael Espindola | 4b4d85f | 2018-03-29 23:32:54 +0000 | [diff] [blame] | 694 | case dwarf::DW_FORM_block1: Asm->emitInt8(Size); break; |
| 695 | case dwarf::DW_FORM_block2: Asm->emitInt16(Size); break; |
| 696 | case dwarf::DW_FORM_block4: Asm->emitInt32(Size); break; |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 697 | case dwarf::DW_FORM_block: |
| 698 | case dwarf::DW_FORM_exprloc: |
| 699 | Asm->EmitULEB128(Size); break; |
| 700 | } |
| 701 | |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 702 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 703 | V.EmitValue(Asm); |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | /// SizeOf - Determine size of location data in bytes. |
| 707 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 708 | unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 709 | switch (Form) { |
| 710 | case dwarf::DW_FORM_block1: return Size + sizeof(int8_t); |
| 711 | case dwarf::DW_FORM_block2: return Size + sizeof(int16_t); |
| 712 | case dwarf::DW_FORM_block4: return Size + sizeof(int32_t); |
| 713 | case dwarf::DW_FORM_block: |
| 714 | case dwarf::DW_FORM_exprloc: |
Logan Chien | 5b776b7 | 2014-02-22 14:00:39 +0000 | [diff] [blame] | 715 | return Size + getULEB128Size(Size); |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 716 | default: llvm_unreachable("Improper form for block"); |
| 717 | } |
| 718 | } |
| 719 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 720 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 721 | void DIELoc::print(raw_ostream &O) const { |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 722 | printValues(O, *this, "ExprLoc", Size, 5); |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 723 | } |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 724 | |
| 725 | //===----------------------------------------------------------------------===// |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 726 | // DIEBlock Implementation |
| 727 | //===----------------------------------------------------------------------===// |
| 728 | |
| 729 | /// ComputeSize - calculate the size of the block. |
| 730 | /// |
Frederic Riss | cd04434 | 2015-03-04 02:30:08 +0000 | [diff] [blame] | 731 | unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const { |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 732 | if (!Size) { |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 733 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 734 | Size += V.SizeOf(AP); |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 735 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 736 | |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 737 | return Size; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | /// EmitValue - Emit block data. |
| 741 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 742 | void DIEBlock::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 743 | switch (Form) { |
Craig Topper | ee4dab5 | 2012-02-05 08:31:47 +0000 | [diff] [blame] | 744 | default: llvm_unreachable("Improper form for block"); |
Rafael Espindola | 4b4d85f | 2018-03-29 23:32:54 +0000 | [diff] [blame] | 745 | case dwarf::DW_FORM_block1: Asm->emitInt8(Size); break; |
| 746 | case dwarf::DW_FORM_block2: Asm->emitInt16(Size); break; |
| 747 | case dwarf::DW_FORM_block4: Asm->emitInt32(Size); break; |
Chris Lattner | 9efd118 | 2010-04-04 19:09:29 +0000 | [diff] [blame] | 748 | case dwarf::DW_FORM_block: Asm->EmitULEB128(Size); break; |
Jonas Devlieghere | 9e3e7a9 | 2018-04-02 10:40:43 +0000 | [diff] [blame^] | 749 | case dwarf::DW_FORM_string: break; |
Paul Robinson | a06f8dc | 2017-12-18 19:08:35 +0000 | [diff] [blame] | 750 | case dwarf::DW_FORM_data16: break; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 751 | } |
| 752 | |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 753 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 754 | V.EmitValue(Asm); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | /// SizeOf - Determine size of block data in bytes. |
| 758 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 759 | unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 760 | switch (Form) { |
| 761 | case dwarf::DW_FORM_block1: return Size + sizeof(int8_t); |
| 762 | case dwarf::DW_FORM_block2: return Size + sizeof(int16_t); |
| 763 | case dwarf::DW_FORM_block4: return Size + sizeof(int32_t); |
Logan Chien | 5b776b7 | 2014-02-22 14:00:39 +0000 | [diff] [blame] | 764 | case dwarf::DW_FORM_block: return Size + getULEB128Size(Size); |
Paul Robinson | a06f8dc | 2017-12-18 19:08:35 +0000 | [diff] [blame] | 765 | case dwarf::DW_FORM_data16: return 16; |
David Blaikie | 46a9f01 | 2012-01-20 21:51:11 +0000 | [diff] [blame] | 766 | default: llvm_unreachable("Improper form for block"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 767 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 768 | } |
| 769 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 770 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 771 | void DIEBlock::print(raw_ostream &O) const { |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 772 | printValues(O, *this, "Blk", Size, 5); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 773 | } |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 774 | |
| 775 | //===----------------------------------------------------------------------===// |
| 776 | // DIELocList Implementation |
| 777 | //===----------------------------------------------------------------------===// |
| 778 | |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 779 | unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 780 | if (Form == dwarf::DW_FORM_data4) |
| 781 | return 4; |
| 782 | if (Form == dwarf::DW_FORM_sec_offset) |
| 783 | return 4; |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 784 | return AP->MAI->getCodePointerSize(); |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | /// EmitValue - Emit label value. |
| 788 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 789 | void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
David Blaikie | 9c550ac | 2014-03-25 01:44:02 +0000 | [diff] [blame] | 790 | DwarfDebug *DD = AP->getDwarfDebug(); |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 791 | MCSymbol *Label = DD->getDebugLocs().getList(Index).Label; |
Rafael Espindola | 857546e | 2015-06-16 23:22:02 +0000 | [diff] [blame] | 792 | AP->emitDwarfSymbolReference(Label, /*ForceOffset*/ DD->useSplitDwarf()); |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 793 | } |
| 794 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 795 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 796 | void DIELocList::print(raw_ostream &O) const { O << "LocList: " << Index; } |