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