LLVM: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

40#include

41#include

42#include

43

44using namespace llvm;

45

46

48 "add-linkage-names-to-declaration-call-origins", cl::Hidden,

49 cl::desc("Add DW_AT_linkage_name to function declaration DIEs "

50 "referenced by DW_AT_call_origin attributes. Enabled by default "

51 "for -gsce debugger tuning."));

52

54 "emit-func-debug-line-table-offsets", cl::Hidden,

55 cl::desc("Include line table offset in function's debug info and emit end "

56 "sequence after each function's line data."),

58

60 bool EnabledByDefault = DD->tuneForSCE();

61 if (EnabledByDefault)

64}

65

67

68

69

70

71

72

74 return dwarf::DW_TAG_skeleton_unit;

75

76 return dwarf::DW_TAG_compile_unit;

77}

78

79

81 switch (AddrSpace) {

92 default:

94 "Cannot translate unknown address space to DWARF address space");

95 return AddrSpace;

96 }

97}

98

104 MacroLabelBegin = Asm->createTempSymbol("cu_macro_begin");

105}

106

107

108

111 if ((Skeleton || DD->useSplitDwarf()) && Label)

112 DD->addArangeLabel(SymbolCU(this, Label));

113

114

115 if ((DD->useSplitDwarf() || !Skeleton) && DD->getDwarfVersion() < 5)

117

118 bool UseAddrOffsetFormOrExpressions =

119 DD->useAddrOffsetForm() || DD->useAddrOffsetExpressions();

120

122 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)

123 Base = DD->getSectionLabel(&Label->getSection());

124

125 if (Base || Base == Label) {

126 unsigned idx = DD->getAddressPool().getIndex(Label);

128 DD->getDwarfVersion() >= 5 ? dwarf::DW_FORM_addrx

129 : dwarf::DW_FORM_GNU_addr_index,

131 return;

132 }

133

134

135

136 assert(DD->getDwarfVersion() >= 5 &&

137 "Addr+offset expressions are only valuable when using debug_addr (to "

138 "reduce relocations) available in DWARFv5 or higher");

139 if (DD->useAddrOffsetExpressions()) {

143 } else

146 DD->getAddressPool().getIndex(Base), Label, Base));

147}

148

152 if (Label)

154 else

156}

157

159

160

161

162

163

164 unsigned CUID = Asm->OutStreamer->hasRawTextSupport() ? 0 : getUniqueID();

165 if (!File)

166 return Asm->OutStreamer->emitDwarfFileDirective(0, "", "", std::nullopt,

167 std::nullopt, CUID);

168

169 if (LastFile != File) {

170 LastFile = File;

171 LastFileID = Asm->OutStreamer->emitDwarfFileDirective(

172 0, File->getDirectory(), File->getFilename(), DD->getMD5AsBytes(File),

173 File->getSource(), CUID);

174 }

175 return LastFileID;

176}

177

180

182 return Die;

183

185

186 auto *GVContext = GV->getScope();

188

192

193

198 assert(SDMDecl->isStaticMember() && "Expected static member decl");

200

202 addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);

203

204

205 if (GTy != SDMDecl->getBaseType())

206 addType(*VariableDIE, GTy);

207 } else {

209

211 if (!DisplayName.empty())

213 if (GTy)

214 addType(*VariableDIE, GTy);

215

216

218 addFlag(*VariableDIE, dwarf::DW_AT_external);

219

220

222 }

223

225 addFlag(*VariableDIE, dwarf::DW_AT_declaration);

226 else

228

230

232 addUInt(*VariableDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,

233 AlignInBytes);

234

237

238

240

241 return VariableDIE;

242}

243

246 bool addToAccelTable = false;

248 std::optional NVPTXAddressSpace;

249 std::unique_ptr DwarfExpr;

250 for (const auto &GE : GlobalExprs) {

253

254

255

256

257

258 if (GlobalExprs.size() == 1 && Expr && Expr->isConstant()) {

259 addToAccelTable = true;

261 *VariableDIE,

265 break;

266 }

267

268

269

270 if (Global && Global->hasDLLImportStorageClass())

271 continue;

272

273

275 continue;

276

278 Asm->getObjFileLowering().supportDebugThreadLocalLocation())

279 continue;

280

281 if (Loc) {

282 addToAccelTable = true;

284 DwarfExpr = std::make_unique(*Asm, *this, *Loc);

285 }

286

287 if (Expr) {

288

289

290

291 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {

292 unsigned LocalNVPTXAddressSpace;

297 NVPTXAddressSpace = LocalNVPTXAddressSpace;

298 }

299 }

300 DwarfExpr->addFragmentOffset(Expr);

301 }

302

305

306

307 auto GetPointerSizedFormAndOp = [this]() {

308 unsigned PointerSize = Asm->MAI->getCodePointerSize();

309 assert((PointerSize == 4 || PointerSize == 8) &&

310 "Add support for other sizes if necessary");

311 struct FormAndOp {

314 };

315 return PointerSize == 4

316 ? FormAndOp{dwarf::DW_FORM_data4, dwarf::DW_OP_const4u}

317 : FormAndOp{dwarf::DW_FORM_data8, dwarf::DW_OP_const8u};

318 };

319 if (Global->isThreadLocal()) {

320 if (Asm->TM.getTargetTriple().isWasm()) {

321

322

323

324

325

326 addWasmRelocBaseGlobal(Loc, "__tls_base", 1);

328 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);

329 } else if (Asm->TM.useEmulatedTLS()) {

330

331 } else {

332

333

334 if (DD->useSplitDwarf()) {

335 auto FormAndOp = GetPointerSizedFormAndOp();

336

337 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);

338

339

341 Asm->getObjFileLowering().getDebugThreadLocalSymbol(Sym));

342 } else {

343 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);

345 DD->getAddressPool().getIndex(Sym, true));

346 }

347

349 DD->useGNUTLSOpcode() ? dwarf::DW_OP_GNU_push_tls_address

350 : dwarf::DW_OP_form_tls_address);

351 }

352 } else if (Asm->TM.getTargetTriple().isWasm() &&

354

355

356

357 addWasmRelocBaseGlobal(Loc, "__memory_base", 1);

359 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);

360 } else if ((Asm->TM.getRelocationModel() == Reloc::RWPI ||

362 Asm->getObjFileLowering()

363 .getKindForGlobal(Global, Asm->TM)

364 .isReadOnly()) {

365 auto FormAndOp = GetPointerSizedFormAndOp();

366

367 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);

368

370 Asm->getObjFileLowering().getIndirectSymViaRWPI(Sym));

371

372 Register BaseReg = Asm->getObjFileLowering().getStaticBase();

373 unsigned DwarfBaseReg =

374 Asm->TM.getMCRegisterInfo()->getDwarfRegNum(BaseReg, false);

375 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + DwarfBaseReg);

376

377 addSInt(*Loc, dwarf::DW_FORM_sdata, 0);

378

379 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);

380 } else {

381 DD->addArangeLabel(SymbolCU(this, Sym));

383 }

384 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB() &&

385 !NVPTXAddressSpace)

386 NVPTXAddressSpace =

388 }

389

390

391

392

393 if (DwarfExpr->isUnknownLocation())

394 DwarfExpr->setMemoryLocationKind();

395 DwarfExpr->addExpression(Expr);

396 }

397 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {

398

399 addUInt(*VariableDIE, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,

401 }

403 addBlock(*VariableDIE, dwarf::DW_AT_location, DwarfExpr->finalize());

404

405 if (DD->useAllLinkageNames())

407

408 if (addToAccelTable) {

409 DD->addAccelName(*this, CUNode->getNameTableKind(), GV->getName(),

410 *VariableDIE);

411

412

413

415 DD->useAllLinkageNames())

417 *VariableDIE);

418 }

419}

420

423

425 return NDie;

427 DIE &NDie = createAndAddDIE(dwarf::DW_TAG_common_block, *ContextDIE, CB);

429 addString(NDie, dwarf::DW_AT_name, Name);

435 return &NDie;

436}

437

439 DD->insertSectionLabel(Range.Begin);

440

441 auto *PrevCU = DD->getPrevCU();

442 bool SameAsPrevCU = this == PrevCU;

443 DD->setPrevCU(this);

444

445

446

447

448 if (CURanges.empty() || !SameAsPrevCU ||

449 (&CURanges.back().End->getSection() !=

450 &Range.End->getSection())) {

451

452 if (PrevCU)

453 DD->terminateLineTable(PrevCU);

454 CURanges.push_back(Range);

455 return;

456 }

457

458 CURanges.back().End = Range.End;

459}

460

462 if (CUNode->isDebugDirectivesOnly())

463 return;

464

466 if (DD->useSectionsAsReferences()) {

468 } else {

469 LineTableStartSym =

470 Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID());

471 }

472

473

474

475

476

477

480}

481

487

490 assert(Begin && "Begin label should not be null!");

491 assert(End && "End label should not be null!");

494

496 if (DD->getDwarfVersion() >= 4 &&

499 return;

500 }

502}

503

504

505

506

507void DwarfCompileUnit::addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName,

509

510

511 const unsigned TI_GLOBAL_RELOC = 3;

513 auto *Sym =

515

516

517

522 true});

523 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_WASM_location);

524 addSInt(*Loc, dwarf::DW_FORM_sdata, TI_GLOBAL_RELOC);

525 if (!isDwoUnit()) {

526 addLabel(*Loc, dwarf::DW_FORM_data4, Sym);

527 } else {

528

529

530

531

532

533

534 addUInt(*Loc, dwarf::DW_FORM_data4, GlobalIndex);

535 }

536}

537

538

539

540

546

547

548 for (const auto &R : Asm->MBBSectionRanges)

549 BB_List.push_back({R.second.BeginLabel, R.second.EndLabel});

550

552

553 if (DD->useAppleExtensionAttributes() &&

554 DD->getCurrentFunction()->getTarget().Options.DisableFramePointerElim(

555 *DD->getCurrentFunction()))

556 addFlag(*SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr);

557

560 *SPDie, dwarf::DW_AT_LLVM_stmt_sequence, LineTableSym,

561 Asm->getObjFileLowering().getDwarfLineSection()->getBeginSymbol());

562 }

563

564

569 switch (FrameBase.Kind) {

573 addAddress(*SPDie, dwarf::DW_AT_frame_base, Location);

574 }

575 break;

576 }

579 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);

581 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_consts);

583 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);

584 }

585 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);

586 break;

587 }

589

590 const unsigned TI_GLOBAL_RELOC = 3;

592

595

596 addWasmRelocBaseGlobal(Loc, "__stack_pointer",

598 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);

599 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);

600 } else {

607 addBlock(*SPDie, dwarf::DW_AT_frame_base, DwarfExpr.finalize());

608 }

609 break;

610 }

611 }

612 }

613

614

615

616 DD->addSubprogramNames(*this, CUNode->getNameTableKind(), SP, *SPDie);

617

618 return *SPDie;

619}

620

621

623 DIE &ParentScopeDIE) {

624 if (!Scope || !Scope->getScopeNode())

625 return;

626

627 auto *DS = Scope->getScopeNode();

628

630 "Only handle inlined subprograms here, use "

631 "constructSubprogramScopeDIE for non-inlined "

632 "subprograms");

633

634

637 assert(ScopeDIE && "Scope DIE should not be null.");

639 return;

640 }

641

642

643 if (DD->isLexicalScopeDIENull(Scope))

644 return;

645

646

648 assert(ScopeDIE && "Scope DIE should not be null.");

649

650 ParentScopeDIE.addChild(ScopeDIE);

652}

653

656

657 HasRangeLists = true;

658

659

660 auto IndexAndList =

661 (DD->getDwarfVersion() < 5 && Skeleton ? Skeleton->DU : DU)

662 ->addRange(*(Skeleton ? Skeleton : this), std::move(Range));

663

664 uint32_t Index = IndexAndList.first;

665 auto &List = *IndexAndList.second;

666

667

668

669

670

671

672 if (DD->getDwarfVersion() >= 5)

673 addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_rnglistx, Index);

674 else {

676 const MCSymbol *RangeSectionSym =

678 if (isDwoUnit())

680 RangeSectionSym);

681 else

683 RangeSectionSym);

684 }

685}

686

689 assert(!Ranges.empty());

690 if (DD->useRangesSection() ||

691 (Ranges.size() == 1 &&

692 (DD->alwaysUseRanges(*this) ||

693 DD->getSectionLabel(&Ranges.front().Begin->getSection()) ==

694 Ranges.front().Begin))) {

695 const RangeSpan &Front = Ranges.front();

696 const RangeSpan &Back = Ranges.back();

698 } else

700}

701

705 List.reserve(Ranges.size());

706 for (const InsnRange &R : Ranges) {

707 auto *BeginLabel = DD->getLabelBeforeInsn(R.first);

708 auto *EndLabel = DD->getLabelAfterInsn(R.second);

709

710 const auto *BeginMBB = R.first->getParent();

711 const auto *EndMBB = R.second->getParent();

712

713 const auto *MBB = BeginMBB;

714

715

716

717

718

719

720 do {

721 if (MBB->sameSection(EndMBB) || MBB->isEndSection()) {

722 auto MBBSectionRange = Asm->MBBSectionRanges[MBB->getSectionID()];

723 List.push_back(

724 {MBB->sameSection(BeginMBB) ? BeginLabel

725 : MBBSectionRange.BeginLabel,

726 MBB->sameSection(EndMBB) ? EndLabel : MBBSectionRange.EndLabel});

727 }

728 if (MBB->sameSection(EndMBB))

729 break;

730 MBB = MBB->getNextNode();

731 } while (true);

732 }

734}

735

737 DIE &ParentScopeDIE) {

738 assert(Scope->getScopeNode());

739 auto *DS = Scope->getScopeNode();

741

742

743 DIE *OriginDIE = getAbstractScopeDIEs()[InlinedSP];

744 assert(OriginDIE && "Unable to find original DIE for an inlined subprogram.");

745

747 ParentScopeDIE.addChild(ScopeDIE);

748 addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);

749

751

752

753 const DILocation *IA = Scope->getInlinedAt();

754 addUInt(*ScopeDIE, dwarf::DW_AT_call_file, std::nullopt,

756 addUInt(*ScopeDIE, dwarf::DW_AT_call_line, std::nullopt, IA->getLine());

757 if (IA->getColumn())

758 addUInt(*ScopeDIE, dwarf::DW_AT_call_column, std::nullopt, IA->getColumn());

759 if (IA->getDiscriminator() && DD->getDwarfVersion() >= 4)

760 addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, std::nullopt,

761 IA->getDiscriminator());

762

763

764

765 DD->addSubprogramNames(*this, CUNode->getNameTableKind(), InlinedSP,

766 *ScopeDIE);

767

768 return ScopeDIE;

769}

770

771

772

774 if (DD->isLexicalScopeDIENull(Scope))

775 return nullptr;

776 const auto *DS = Scope->getScopeNode();

777

779 if (Scope->isAbstractScope()) {

780 assert(!getAbstractScopeDIEs().count(DS) &&

781 "Abstract DIE for this scope exists!");

782 getAbstractScopeDIEs()[DS] = ScopeDIE;

783 return ScopeDIE;

784 }

785 if (!Scope->getInlinedAt()) {

786 assert(!LexicalBlockDIEs.count(DS) &&

787 "Concrete out-of-line DIE for this scope exists!");

788 LexicalBlockDIEs[DS] = ScopeDIE;

789 } else {

790 InlinedLocalScopeDIEs[DS].push_back(ScopeDIE);

791 }

792

794

795 return ScopeDIE;

796}

797

801 DV.setDIE(*VariableDie);

802

803 if (Abstract) {

805 } else {

806 std::visit(

807 [&](const auto &V) {

808 applyConcreteDbgVariableAttributes(V, DV, *VariableDie);

809 },

811 }

812 return VariableDie;

813}

814

815void DwarfCompileUnit::applyConcreteDbgVariableAttributes(

817 const DbgValueLoc *DVal = &Single.getValueLoc();

819 !Single.getExpr()) {

820

821

822 addUInt(VariableDie, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,

824 }

827 if (Entry->isLocation()) {

829 } else if (Entry->isInt()) {

830 auto *Expr = Single.getExpr();

831 if (Expr && Expr->getNumElements()) {

833 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);

834

835 DwarfExpr.addFragmentOffset(Expr);

836 DwarfExpr.addUnsignedConstant(Entry->getInt());

837 DwarfExpr.addExpression(Expr);

838 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());

839 if (DwarfExpr.TagOffset)

840 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset,

841 dwarf::DW_FORM_data1, *DwarfExpr.TagOffset);

842 } else

844 } else if (Entry->isConstantFP()) {

846 } else if (Entry->isConstantInt()) {

848 } else if (Entry->isTargetIndexLocation()) {

850 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);

854 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());

855 }

856 return;

857 }

858

859

861 return Entry.isLocation() && !Entry.getLoc().getReg();

862 }))

863 return;

864 const DIExpression *Expr = Single.getExpr();

865 assert(Expr && "Variadic Debug Value must have an Expression.");

867 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);

868 DwarfExpr.addFragmentOffset(Expr);

869 DIExpressionCursor Cursor(Expr);

870 const TargetRegisterInfo &TRI = *Asm->MF->getSubtarget().getRegisterInfo();

871

872 auto AddEntry = [&](const DbgValueLocEntry &Entry,

873 DIExpressionCursor &Cursor) {

874 if (Entry.isLocation()) {

875 if (!DwarfExpr.addMachineRegExpression(TRI, Cursor,

876 Entry.getLoc().getReg()))

877 return false;

878 } else if (Entry.isInt()) {

879

880 DwarfExpr.addUnsignedConstant(Entry.getInt());

881 } else if (Entry.isConstantFP()) {

882

883

884

885

886 APInt RawBytes = Entry.getConstantFP()->getValueAPF().bitcastToAPInt();

888 return false;

889 DwarfExpr.addUnsignedConstant(RawBytes.getZExtValue());

890 } else if (Entry.isConstantInt()) {

891 APInt RawBytes = Entry.getConstantInt()->getValue();

893 return false;

894 DwarfExpr.addUnsignedConstant(RawBytes.getZExtValue());

895 } else if (Entry.isTargetIndexLocation()) {

896 TargetIndexLocation Loc = Entry.getTargetIndexLocation();

897

898

899 assert(Asm->TM.getTargetTriple().isWasm());

900 DwarfExpr.addWasmLocation(Loc.Index, static_cast<uint64_t>(Loc.Offset));

901 } else {

903 }

904 return true;

905 };

906

907 if (!DwarfExpr.addExpression(

908 std::move(Cursor),

909 [&](unsigned Idx, DIExpressionCursor &Cursor) -> bool {

910 return AddEntry(DVal->getLocEntries()[Idx], Cursor);

911 }))

912 return;

913

914

915 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());

916 if (DwarfExpr.TagOffset)

917 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,

918 *DwarfExpr.TagOffset);

919}

920

921void DwarfCompileUnit::applyConcreteDbgVariableAttributes(

926 if (TagOffset)

927 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,

928 *TagOffset);

929}

930

931void DwarfCompileUnit::applyConcreteDbgVariableAttributes(const Loc::MMI &MMI,

933 DIE &VariableDie) {

934 std::optional NVPTXAddressSpace;

936 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);

939 const DIExpression *Expr = Fragment.Expr;

940 const TargetFrameLowering *TFI = Asm->MF->getSubtarget().getFrameLowering();

941 StackOffset Offset =

943 DwarfExpr.addFragmentOffset(Expr);

944

945 auto *TRI = Asm->MF->getSubtarget().getRegisterInfo();

946 SmallVector<uint64_t, 8> Ops;

947 TRI->getOffsetOpcodes(Offset, Ops);

948

949

950

951

952 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {

953 unsigned LocalNVPTXAddressSpace;

954 const DIExpression *NewExpr =

956 if (NewExpr != Expr) {

957 Expr = NewExpr;

958 NVPTXAddressSpace = LocalNVPTXAddressSpace;

959 }

960 }

961 if (Expr)

963 DIExpressionCursor Cursor(Ops);

964 DwarfExpr.setMemoryLocationKind();

965 if (const MCSymbol *FrameSymbol = Asm->getFunctionFrameSymbol())

967 else

968 DwarfExpr.addMachineRegExpression(

969 *Asm->MF->getSubtarget().getRegisterInfo(), Cursor, FrameReg);

970 DwarfExpr.addExpression(std::move(Cursor));

971 }

972 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {

973

974 addUInt(VariableDie, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,

976 }

977 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());

978 if (DwarfExpr.TagOffset)

979 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,

980 *DwarfExpr.TagOffset);

981}

982

983void DwarfCompileUnit::applyConcreteDbgVariableAttributes(

985 DIE &VariableDie) {

987 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);

988

990 DwarfExpr.addFragmentOffset(&Expr);

991 DIExpressionCursor Cursor(Expr.getElements());

992 DwarfExpr.beginEntryValueExpression(Cursor);

993 DwarfExpr.addMachineRegExpression(

994 *Asm->MF->getSubtarget().getRegisterInfo(), Cursor, Register);

995 DwarfExpr.addExpression(std::move(Cursor));

996 }

997 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());

998}

999

1000void DwarfCompileUnit::applyConcreteDbgVariableAttributes(

1001 const std::monostate &, const DbgVariable &DV, DIE &VariableDie) {}

1002

1005 DIE *&ObjectPointer) {

1008 ObjectPointer = Var;

1009 return Var;

1010}

1011

1016 DL.setDIE(*LabelDie);

1017

1018 if (Scope.isAbstractScope())

1020

1021 return LabelDie;

1022}

1023

1024

1028 if (!Array || Array->getTag() != dwarf::DW_TAG_array_type)

1029 return Result;

1030 if (auto *DLVar = Array->getDataLocation())

1031 Result.push_back(DLVar);

1032 if (auto *AsVar = Array->getAssociated())

1033 Result.push_back(AsVar);

1034 if (auto *AlVar = Array->getAllocated())

1035 Result.push_back(AlVar);

1036 for (auto *El : Array->getElements()) {

1038 if (auto Count = Subrange->getCount())

1040 Result.push_back(Dependency);

1041 if (auto LB = Subrange->getLowerBound())

1043 Result.push_back(Dependency);

1044 if (auto UB = Subrange->getUpperBound())

1046 Result.push_back(Dependency);

1047 if (auto ST = Subrange->getStride())

1049 Result.push_back(Dependency);

1051 if (auto Count = GenericSubrange->getCount())

1053 Result.push_back(Dependency);

1054 if (auto LB = GenericSubrange->getLowerBound())

1056 Result.push_back(Dependency);

1057 if (auto UB = GenericSubrange->getUpperBound())

1059 Result.push_back(Dependency);

1060 if (auto ST = GenericSubrange->getStride())

1062 Result.push_back(Dependency);

1063 }

1064 }

1065 return Result;

1066}

1067

1068

1069

1074

1076

1078

1080

1081

1083 DbgVar.insert({Var->getVariable(), Var});

1085 }

1086

1087

1088 while (!WorkList.empty()) {

1089 auto Item = WorkList.back();

1091 bool visitedAllDependencies = Item.getInt();

1093

1095

1096

1097 if (Visited.count(Var))

1098 continue;

1099

1100

1101 if (visitedAllDependencies) {

1102 Visited.insert(Var);

1103 Result.push_back(Var);

1104 continue;

1105 }

1106

1107

1108 auto Res = Visiting.insert(Var);

1109 if (!Res.second) {

1110 assert(false && "dependency cycle in local variables");

1111 return Result;

1112 }

1113

1114

1115

1117 for (const auto *Dependency : dependencies(Var)) {

1118

1122 }

1123 }

1124 return Result;

1125}

1126

1132

1133 if (Scope) {

1134 assert(!Scope->getInlinedAt());

1135 assert(!Scope->isAbstractScope());

1136

1137

1138

1140 addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);

1141 }

1142

1143

1145

1146

1147

1148

1149 if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&

1153

1154 return ScopeDIE;

1155}

1156

1158 DIE &ScopeDIE) {

1159 DIE *ObjectPointer = nullptr;

1160

1161

1162 auto Vars = DU->getScopeVariables().lookup(Scope);

1163 for (auto &DV : Vars.Args)

1165

1166

1170

1171

1172 for (DbgLabel *DL : DU->getScopeLabels().lookup(Scope))

1174

1175

1176

1177

1179 auto &LocalDecls = DD->getLocalDeclsForScope(Scope->getScopeNode());

1180 DeferredLocalDecls.insert_range(LocalDecls);

1181 }

1182

1183

1184 auto skipLexicalScope = [this](LexicalScope *S) -> bool {

1186 return false;

1187 auto Vars = DU->getScopeVariables().lookup(S);

1188 if (!Vars.Args.empty() || !Vars.Locals.empty())

1189 return false;

1191 DD->getLocalDeclsForScope(S->getScopeNode()).empty();

1192 };

1193 for (LexicalScope *LS : Scope->getChildren()) {

1194

1195

1196 if (skipLexicalScope(LS))

1198 else

1200 }

1201

1202 return ObjectPointer;

1203}

1204

1207 if (auto *AbsDef = getAbstractScopeDIEs().lookup(SP))

1208 return *AbsDef;

1209

1210 auto [ContextDIE, ContextCU] = getOrCreateAbstractSubprogramContextDIE(SP);

1211 return createAbstractSubprogramDIE(SP, ContextDIE, ContextCU);

1212}

1213

1214DIE &DwarfCompileUnit::createAbstractSubprogramDIE(

1216

1217

1219 *ContextDIE, nullptr);

1220

1221

1222 ContextCU->getAbstractScopeDIEs()[SP] = &AbsDef;

1223

1225 ContextCU->addSInt(AbsDef, dwarf::DW_AT_inline,

1227 : dwarf::DW_FORM_implicit_const,

1229

1230 return AbsDef;

1231}

1232

1233std::pair<DIE *, DwarfCompileUnit *>

1234DwarfCompileUnit::getOrCreateAbstractSubprogramContextDIE(

1239

1240 if (auto *SPDecl = SP->getDeclaration())

1241 if (!Minimal)

1243

1244

1245

1246

1247 auto *ContextCU = IgnoreScope ? this : DD->lookupCU(ContextDIE->getUnitDie());

1248

1249 return std::make_pair(ContextDIE, ContextCU);

1250}

1251

1255

1256

1257 if (!getFinalizedAbstractSubprograms().insert(SP).second)

1258 return;

1259

1260 auto [ContextDIE, ContextCU] = getOrCreateAbstractSubprogramContextDIE(SP);

1261 DIE *AbsDef = getAbstractScopeDIEs().lookup(SP);

1262 if (!AbsDef)

1263 AbsDef = &createAbstractSubprogramDIE(SP, ContextDIE, ContextCU);

1264

1266 ContextCU->addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer,

1267 *ObjectPointer);

1268}

1269

1271 return DD->getDwarfVersion() <= 4 && DD->tuneForLLDB();

1272}

1273

1276 return Tag;

1277 switch (Tag) {

1278 case dwarf::DW_TAG_call_site:

1279 return dwarf::DW_TAG_GNU_call_site;

1280 case dwarf::DW_TAG_call_site_parameter:

1281 return dwarf::DW_TAG_GNU_call_site_parameter;

1282 default:

1284 }

1285}

1286

1290 return Attr;

1291 switch (Attr) {

1292 case dwarf::DW_AT_call_all_calls:

1293 return dwarf::DW_AT_GNU_all_call_sites;

1294 case dwarf::DW_AT_call_target:

1295 return dwarf::DW_AT_GNU_call_site_target;

1296 case dwarf::DW_AT_call_origin:

1297 return dwarf::DW_AT_abstract_origin;

1298 case dwarf::DW_AT_call_return_pc:

1299 return dwarf::DW_AT_low_pc;

1300 case dwarf::DW_AT_call_value:

1301 return dwarf::DW_AT_GNU_call_site_value;

1302 case dwarf::DW_AT_call_tail_call:

1303 return dwarf::DW_AT_GNU_tail_call;

1304 default:

1306 }

1307}

1308

1312 return Loc;

1313 switch (Loc) {

1314 case dwarf::DW_OP_entry_value:

1315 return dwarf::DW_OP_GNU_entry_value;

1316 default:

1317 llvm_unreachable("DWARF5 location atom with no GNU analog");

1318 }

1319}

1320

1323 bool IsTail, const MCSymbol *PCAddr, const MCSymbol *CallAddr,

1324 unsigned CallReg, DIType *AllocSiteTy) {

1325

1327 ScopeDIE, nullptr);

1328

1329 if (CallReg) {

1330

1333 } else if (CalleeSP) {

1335 assert(CalleeDIE && "Could not create DIE for call site entry origin");

1337 !CalleeSP->isDefinition() &&

1338 !CalleeDIE->findAttribute(dwarf::DW_AT_linkage_name)) {

1339 addLinkageName(*CalleeDIE, CalleeSP->getLinkageName());

1340 }

1341

1343 *CalleeDIE);

1344 }

1345

1346 if (IsTail) {

1347

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1363 addLabelAddress(CallSiteDIE, dwarf::DW_AT_call_pc, CallAddr);

1364 }

1365

1366

1367

1368

1369

1370

1371

1373 assert(PCAddr && "Missing return PC information for a call");

1376 }

1377

1378 if (AllocSiteTy)

1379 addType(CallSiteDIE, AllocSiteTy, dwarf::DW_AT_LLVM_alloc_type);

1380

1381 return CallSiteDIE;

1382}

1383

1386 for (const auto &Param : Params) {

1387 unsigned Register = Param.getRegister();

1388 auto CallSiteDieParam =

1392 addAddress(*CallSiteDieParam, dwarf::DW_AT_location,

1394

1398

1400

1403

1404 CallSiteDIE.addChild(CallSiteDieParam);

1405 }

1406}

1407

1412 DIE *EntityDie;

1413 auto *Entity = Module->getEntity();

1419

1420

1421

1422 if (auto *AbsSPDie = getAbstractScopeDIEs().lookup(SP))

1423 EntityDie = AbsSPDie;

1424 else

1432 else

1433 EntityDie = getDIE(Entity);

1436 addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);

1438 if (!Name.empty()) {

1439 addString(*IMDie, dwarf::DW_AT_name, Name);

1440

1441

1442

1443

1444

1445

1446 DD->addAccelNamespace(*this, CUNode->getNameTableKind(), Name, *IMDie);

1447 }

1448

1449

1450

1451 DINodeArray Elements = Module->getElements();

1452 for (const auto *Element : Elements) {

1453 if (!Element)

1454 continue;

1457 }

1458

1459 return IMDie;

1460}

1461

1464

1465

1467 return Die;

1468

1470 assert(ContextDIE && "Empty scope for the imported entity!");

1471

1473 ContextDIE->addChild(IMDie);

1474 return IMDie;

1475}

1476

1479 if (DIE *AbsSPDIE = getAbstractScopeDIEs().lookup(SP)) {

1480 if (D)

1481

1482 addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);

1483 } else {

1485 if (D)

1486

1488 }

1489}

1490

1493

1494 auto *Die = Entity->getDIE();

1495

1496

1497 const DbgLabel *Label = nullptr;

1498 if (AbsEntity && AbsEntity->getDIE()) {

1499 addDIEEntry(*Die, dwarf::DW_AT_abstract_origin, *AbsEntity->getDIE());

1501 } else {

1506 else

1507 llvm_unreachable("DbgEntity must be DbgVariable or DbgLabel.");

1508 }

1509

1510 if (!Label)

1511 return;

1512

1513 const auto *Sym = Label->getSymbol();

1514 if (!Sym)

1515 return;

1516

1518

1519

1520 if (StringRef Name = Label->getName(); !Name.empty())

1522}

1523

1525 auto AttachAO = [&](const DILocalScope *LS, DIE *ScopeDIE) {

1526 if (auto *AbsLSDie = getAbstractScopeDIEs().lookup(LS))

1527 addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *AbsLSDie);

1528 };

1529

1530 for (auto [LScope, ScopeDIE] : LexicalBlockDIEs)

1531 AttachAO(LScope, ScopeDIE);

1532 for (auto &[LScope, ScopeDIEs] : InlinedLocalScopeDIEs)

1533 for (auto *ScopeDIE : ScopeDIEs)

1534 AttachAO(LScope, ScopeDIE);

1535}

1536

1538 auto &AbstractEntities = getAbstractEntities();

1539 auto I = AbstractEntities.find(Node);

1540 if (I != AbstractEntities.end())

1541 return I->second.get();

1542 return nullptr;

1543}

1544

1547 assert(Scope && Scope->isAbstractScope());

1548 auto &Entity = getAbstractEntities()[Node];

1551 nullptr );

1554 Entity = std::make_unique(

1557 }

1558}

1559

1561

1562 if (!Skeleton && DD->useSectionsAsReferences()) {

1565 }

1566

1567 dwarf::UnitType UT = Skeleton ? dwarf::DW_UT_split_compile

1568 : DD->useSplitDwarf() ? dwarf::DW_UT_skeleton

1569 : dwarf::DW_UT_compile;

1571 if (DD->getDwarfVersion() >= 5 && UT != dwarf::DW_UT_compile)

1573}

1574

1576 switch (CUNode->getNameTableKind()) {

1578 return false;

1579

1580

1582 return true;

1584 return false;

1587 CUNode->isDebugDirectivesOnly() &&

1589 DD->getDwarfVersion() < 5;

1590 }

1591 llvm_unreachable("Unhandled DICompileUnit::DebugNameTableKind enum");

1592}

1593

1594

1596 const DIScope *Context) {

1598 return;

1600 GlobalNames[FullName] = &Die;

1601}

1602

1604 const DIScope *Context) {

1606 return;

1608

1609

1610

1611

1612 GlobalNames.insert(std::make_pair(std::move(FullName), &getUnitDie()));

1613}

1614

1615

1617 const DIScope *Context) {

1619 return;

1621 GlobalTypes[FullName] = &Die;

1622}

1623

1625 const DIScope *Context) {

1627 return;

1629

1630

1631

1632

1633 GlobalTypes.insert(std::make_pair(std::move(FullName), &getUnitDie()));

1634}

1635

1638 auto *Single = std::get_ifLoc::Single(&DV);

1639 if (Single && Single->getExpr())

1640 addComplexAddress(Single->getExpr(), Die, dwarf::DW_AT_location, Location);

1641 else

1642 addAddress(Die, dwarf::DW_AT_location, Location);

1643}

1644

1645

1650 if (Location.isIndirect())

1652

1656 return;

1658

1659

1661

1663 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,

1665}

1666

1667

1668

1669

1670

1677 DwarfExpr.setLocation(Location, DIExpr);

1678

1680

1683

1686 return;

1688

1689

1691

1693 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,

1695}

1696

1697

1699 unsigned Index) {

1701 ? dwarf::DW_FORM_loclistx

1702 : DD->getDwarfSectionOffsetForm();

1704}

1705

1707 DIE &VariableDie) {

1709 if (!Name.empty())

1710 addString(VariableDie, dwarf::DW_AT_name, Name);

1712 if (DIVar) {

1713 if (uint32_t AlignInBytes = DIVar->getAlignInBytes())

1714 addUInt(VariableDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,

1715 AlignInBytes);

1716 addAnnotation(VariableDie, DIVar->getAnnotations());

1717 }

1718

1722 addFlag(VariableDie, dwarf::DW_AT_artificial);

1723}

1724

1726 DIE &LabelDie) {

1727 StringRef Name = Label.getName();

1728 if (!Name.empty())

1729 addString(LabelDie, dwarf::DW_AT_name, Name);

1730 const auto *DILabel = Label.getLabel();

1733 addFlag(LabelDie, dwarf::DW_AT_artificial);

1735 addUInt(LabelDie, dwarf::DW_AT_LLVM_coro_suspend_idx, std::nullopt,

1737}

1738

1739

1741 const MCExpr *Expr) {

1743}

1744

1747 auto *SPDecl = SP->getDeclaration();

1748 auto *Context = SPDecl ? SPDecl->getScope() : SP->getScope();

1751}

1752

1753bool DwarfCompileUnit::isDwoUnit() const {

1755}

1756

1757void DwarfCompileUnit::finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) {

1759}

1760

1763 (DD->useSplitDwarf() && !Skeleton);

1764}

1765

1769

1772 MCSymbol *Label = DD->getAddressPool().getLabel();

1774 DD->getDwarfVersion() >= 5 ? dwarf::DW_AT_addr_base

1775 : dwarf::DW_AT_GNU_addr_base,

1777}

1778

1783

1785

1786

1787

1788

1793 addString(Die, dwarf::DW_AT_name,

1796 addUInt(Die, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Btr.Encoding);

1797

1798

1799

1800

1801

1802

1803 addUInt(Die, dwarf::DW_AT_byte_size, std::nullopt,

1805 Btr.Die = &Die;

1806 }

1807}

1808

1810

1811 bool isAbstract = getAbstractScopeDIEs().count(LB->getSubprogram());

1812 if (isAbstract) {

1813 auto &DIEs = getAbstractScopeDIEs();

1814 if (auto It = DIEs.find(LB); It != DIEs.end())

1815 return It->second;

1816 }

1817 assert(!isAbstract && "Missed lexical block DIE in abstract tree!");

1818

1819

1820 return LexicalBlockDIEs.lookup(LB);

1821}

1822

1826 Context = LFScope->getNonLexicalBlockFileScope();

1829

1830

1832 const auto &DIEs = getAbstractScopeDIEs();

1833 if (auto It = DIEs.find(SPScope); It != DIEs.end())

1834 return It->second;

1835 }

1837}

1838

1841 bool Minimal) {

1842 if (F && SP->isDefinition()) {

1843 F = DD->getLexicalScopes().getFunction(SP);

1844

1845 if (F) {

1846

1847

1848 return &DD->getOrCreateAbstractSubprogramCU(SP, *this)

1849 .getOrCreateAbstractSubprogramDIE(SP);

1850 }

1851 }

1852

1854}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

static SmallVector< DbgVariable *, 8 > sortLocalVars(SmallVectorImpl< DbgVariable * > &Input)

Sort local variables so that variables appearing inside of helper expressions come first.

Definition DwarfCompileUnit.cpp:1071

static unsigned translateToNVVMDWARFAddrSpace(unsigned AddrSpace)

Translate NVVM IR address space code to DWARF correspondent value.

Definition DwarfCompileUnit.cpp:80

static SmallVector< const DIVariable *, 2 > dependencies(DbgVariable *Var)

Return all DIVariables that appear in count: expressions.

Definition DwarfCompileUnit.cpp:1025

static cl::opt< bool > EmitFuncLineTableOffsetsOption("emit-func-debug-line-table-offsets", cl::Hidden, cl::desc("Include line table offset in function's debug info and emit end " "sequence after each function's line data."), cl::init(false))

static bool AddLinkageNamesToDeclCallOriginsForTuning(const DwarfDebug *DD)

Definition DwarfCompileUnit.cpp:59

static dwarf::Tag GetCompileUnitType(UnitKind Kind, DwarfDebug *DW)

Definition DwarfCompileUnit.cpp:66

static cl::opt< cl::boolOrDefault > AddLinkageNamesToDeclCallOrigins("add-linkage-names-to-declaration-call-origins", cl::Hidden, cl::desc("Add DW_AT_linkage_name to function declaration DIEs " "referenced by DW_AT_call_origin attributes. Enabled by default " "for -gsce debugger tuning."))

Query value using AddLinkageNamesToDeclCallOriginsForTuning.

This file contains constants used for implementing Dwarf debug support.

static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)

A Lookup helper functions.

const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]

Register const TargetRegisterInfo * TRI

Promote Memory to Register

NVPTX address space definition.

ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))

This file defines the SmallString class.

The Input class is used to parse a yaml document into in-memory structs and vectors.

uint64_t getZExtValue() const

Get zero extended value.

unsigned getBitWidth() const

Return the number of bits in the APInt.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

This class is intended to be used as a driving class for all asm writers.

TargetMachine & TM

Target machine description.

const DataLayout & getDataLayout() const

Return information about data layout.

MCSymbol * GetExternalSymbolSymbol(const Twine &Sym) const

Return the MCSymbol for the specified ExternalSymbol.

Functions, function parameters, and return types can have attributes to indicate how they should be t...

unsigned getLineNo() const

StringRef getName() const

DIScope * getScope() const

DIGlobalVariable * getDecl() const

static LLVM_ABI std::optional< DebugEmissionKind > getEmissionKind(StringRef Str)

DIEBlock - Represents a block of values.

DwarfExpression implementation for singular DW_AT_location.

Represents a pointer to a location list in the debug_loc section.

DIELoc - Represents an expression location.

A structured debug information entry.

LLVM_ABI DIEValue findAttribute(dwarf::Attribute Attribute) const

Find a value in the DIE with the attribute given.

DIE & addChild(DIE *Child)

Add a child to the DIE.

DIE & addChildFront(DIE *Child)

static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)

LLVM_ABI const DIE * getUnitDie() const

Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.

Holds a DIExpression and keeps track of how many operands have been consumed so far.

element_iterator elements_end() const

LLVM_ABI bool isEntryValue() const

Check if the expression consists of exactly one entry value operand.

element_iterator elements_begin() const

ArrayRef< uint64_t > getElements() const

uint64_t getElement(unsigned I) const

LLVM_ABI std::optional< SignedOrUnsignedConstant > isConstant() const

Determine whether this represents a constant value, if so.

static LLVM_ABI const DIExpression * extractAddressClass(const DIExpression *Expr, unsigned &AddrClass)

Checks if the last 4 elements of the expression are DW_OP_constu DW_OP_swap DW_O...

DIDerivedType * getStaticDataMemberDeclaration() const

MDTuple * getTemplateParams() const

bool isLocalToUnit() const

StringRef getLinkageName() const

StringRef getDisplayName() const

bool isDefinition() const

DINodeArray getAnnotations() const

An imported module (C++ using directive or similar).

bool isArtificial() const

std::optional< unsigned > getCoroSuspendIdx() const

LLVM_ABI DISubprogram * getSubprogram() const

Get the subprogram for this scope.

Tagged DWARF-like metadata node.

LLVM_ABI dwarf::Tag getTag() const

Base class for scope-like contexts.

Subprogram description. Uses SubclassData1.

uint32_t getAlignInBytes() const

DIScope * getScope() const

StringRef getName() const

LLVM_ABI unsigned getPointerSize(unsigned AS=0) const

The pointer representation size in bytes, rounded up to a whole number of bytes.

This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...

const DINode * getEntity() const

Accessors.

This class is used to track label information.

A single location or constant within a variable location description, with either a single entry (wit...

The location of a single variable, composed of an expression and 0 or more DbgValueLocEntries.

ArrayRef< DbgValueLocEntry > getLocEntries() const

This class is used to track local variable information.

bool isArtificial() const

Return true if DbgVariable is artificial.

dwarf::Tag getTag() const

bool isObjectPointer() const

const DILocalVariable * getVariable() const

StringRef getName() const

const DIType * getType() const

Loc::Variant & asVariant()

To workaround P2162R0 https://github.com/cplusplus/papers/issues/873 the base class subobject needs t...

ValueT lookup(const_arg_type_t< KeyT > Val) const

lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...

std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)

bool useGNUAnalogForDwarf5Feature() const

Whether to use the GNU analog for a DWARF5 tag, attribute, or location atom.

Definition DwarfCompileUnit.cpp:1270

void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE, SmallVector< DbgCallSiteParam, 4 > &Params)

Construct call site parameter DIEs for the CallSiteDIE.

Definition DwarfCompileUnit.cpp:1384

void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End)

Definition DwarfCompileUnit.cpp:488

void emitHeader(bool UseOffsets) override

Emit the header for this unit, not including the initial length field.

Definition DwarfCompileUnit.cpp:1560

dwarf::Tag getDwarf5OrGNUTag(dwarf::Tag Tag) const

This takes a DWARF 5 tag and returns it or a GNU analog.

Definition DwarfCompileUnit.cpp:1274

void constructAbstractSubprogramScopeDIE(LexicalScope *Scope)

Definition DwarfCompileUnit.cpp:1252

bool includeMinimalInlineScopes() const

Definition DwarfCompileUnit.cpp:1761

DIE * getOrCreateImportedEntityDIE(const DIImportedEntity *IE)

Get or create a DIE for an imported entity.

Definition DwarfCompileUnit.cpp:1462

void addBaseTypeRef(DIEValueList &Die, int64_t Idx)

Definition DwarfCompileUnit.cpp:1779

void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context)

Add a new global name present in a type unit to this compile unit.

Definition DwarfCompileUnit.cpp:1603

void finishEntityDefinition(const DbgEntity *Entity)

Definition DwarfCompileUnit.cpp:1491

void addRange(RangeSpan Range)

addRange - Add an address range to the list of ranges for this unit.

Definition DwarfCompileUnit.cpp:438

void addAddrTableBase()

Add the DW_AT_addr_base attribute to the unit DIE.

Definition DwarfCompileUnit.cpp:1770

std::vector< BaseTypeRef > ExprRefedBaseTypes

DIE * constructInlinedScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE)

This scope represents an inlined body of a function.

Definition DwarfCompileUnit.cpp:736

void createBaseTypeDIEs()

Definition DwarfCompileUnit.cpp:1784

void addScopeRangeList(DIE &ScopeDIE, SmallVector< RangeSpan, 2 > Range)

A helper function to construct a RangeSpanList for a given lexical scope.

Definition DwarfCompileUnit.cpp:654

uint64_t getDWOId() const

DIE * getOrCreateCommonBlock(const DICommonBlock *CB, ArrayRef< GlobalExpr > GlobalExprs)

Definition DwarfCompileUnit.cpp:421

void addVariableAddress(const DbgVariable &DV, DIE &Die, MachineLocation Location)

Add DW_AT_location attribute for a DbgVariable based on provided MachineLocation.

Definition DwarfCompileUnit.cpp:1636

void initStmtList()

Definition DwarfCompileUnit.cpp:461

DIE & getOrCreateAbstractSubprogramDIE(const DISubprogram *SP)

Create an abstract subprogram DIE, that should later be populated by constructAbstractSubprogramScope...

Definition DwarfCompileUnit.cpp:1205

DIE & constructSubprogramScopeDIE(const DISubprogram *Sub, const Function &F, LexicalScope *Scope, MCSymbol *LineTableSym)

Construct a DIE for this subprogram scope.

Definition DwarfCompileUnit.cpp:1127

DIE * getLexicalBlockDIE(const DILexicalBlock *LB)

Get a DIE for the given DILexicalBlock.

Definition DwarfCompileUnit.cpp:1809

void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context) override

Add a new global name to the compile unit.

Definition DwarfCompileUnit.cpp:1595

DIE & updateSubprogramScopeDIE(const DISubprogram *SP, const Function &F, MCSymbol *LineTableSym)

Find DIE for the given subprogram and attach appropriate DW_AT_low_pc, DW_AT_high_pc and DW_AT_LLVM_s...

Definition DwarfCompileUnit.cpp:541

void createAbstractEntity(const DINode *Node, LexicalScope *Scope)

Definition DwarfCompileUnit.cpp:1545

void applyStmtList(DIE &D)

Apply the DW_AT_stmt_list from this compile unit to the specified DIE.

Definition DwarfCompileUnit.cpp:482

DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, const Function *F, bool Minimal=false) override

Definition DwarfCompileUnit.cpp:1839

DIE * getOrCreateContextDIE(const DIScope *Ty) override

Construct a DIE for a given scope.

Definition DwarfCompileUnit.cpp:1823

void applyCommonDbgVariableAttributes(const DbgVariable &Var, DIE &VariableDie)

Add attributes to Var which reflect the common attributes of VariableDie, namely those which are not ...

Definition DwarfCompileUnit.cpp:1706

DIE & constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP, const Function *CalleeF, bool IsTail, const MCSymbol *PCAddr, const MCSymbol *CallAddr, unsigned CallReg, DIType *AllocSiteTy)

Construct a call site entry DIE describing a call within Scope to a callee described by CalleeSP and ...

Definition DwarfCompileUnit.cpp:1321

DIE * constructVariableDIE(DbgVariable &DV, bool Abstract=false)

Construct a DIE for the given DbgVariable.

Definition DwarfCompileUnit.cpp:798

dwarf::LocationAtom getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const

This takes a DWARF 5 location atom and either returns it or a GNU analog.

Definition DwarfCompileUnit.cpp:1310

DIE * getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)

Get or create global variable DIE.

Definition DwarfCompileUnit.cpp:178

void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)

Definition DwarfCompileUnit.cpp:244

void applySubprogramAttributesToDefinition(const DISubprogram *SP, DIE &SPDie)

Definition DwarfCompileUnit.cpp:1745

DIE * createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE)

Definition DwarfCompileUnit.cpp:1157

void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr)

Add a Dwarf expression attribute data and value.

Definition DwarfCompileUnit.cpp:1740

dwarf::Attribute getDwarf5OrGNUAttr(dwarf::Attribute Attr) const

This takes a DWARF 5 attribute and returns it or a GNU analog.

Definition DwarfCompileUnit.cpp:1288

void addAddress(DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)

Add an address attribute to a die based on the location provided.

Definition DwarfCompileUnit.cpp:1646

void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie)

Definition DwarfCompileUnit.cpp:1725

void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)

addLocalLabelAddress - Add a dwarf label attribute data and value using DW_FORM_addr only.

Definition DwarfCompileUnit.cpp:149

DIE * constructLexicalScopeDIE(LexicalScope *Scope)

Construct new DW_TAG_lexical_block for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.

Definition DwarfCompileUnit.cpp:773

void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context) override

Add a new global type to the compile unit.

Definition DwarfCompileUnit.cpp:1616

unsigned getOrCreateSourceID(const DIFile *File) override

Look up the source ID for the given file.

Definition DwarfCompileUnit.cpp:158

void constructScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE)

Definition DwarfCompileUnit.cpp:622

void attachLexicalScopesAbstractOrigins()

Definition DwarfCompileUnit.cpp:1524

DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, UnitKind Kind=UnitKind::Full)

Definition DwarfCompileUnit.cpp:99

DIE * constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope)

Construct a DIE for the given DbgLabel.

Definition DwarfCompileUnit.cpp:1012

void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context)

Add a new global type present in a type unit to this compile unit.

Definition DwarfCompileUnit.cpp:1624

DbgEntity * getExistingAbstractEntity(const DINode *Node)

Definition DwarfCompileUnit.cpp:1537

bool hasDwarfPubSections() const

Definition DwarfCompileUnit.cpp:1575

void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)

addLabelAddress - Add a dwarf label attribute data and value using either DW_FORM_addr or DW_FORM_GNU...

Definition DwarfCompileUnit.cpp:109

void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index)

Add a Dwarf loclistptr attribute data and value.

Definition DwarfCompileUnit.cpp:1698

bool emitFuncLineTableOffsets() const

Definition DwarfCompileUnit.cpp:1766

void addComplexAddress(const DIExpression *DIExpr, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)

Start with the address based on the location provided, and generate the DWARF information necessary t...

Definition DwarfCompileUnit.cpp:1671

DIE * constructImportedEntityDIE(const DIImportedEntity *IE)

Definition DwarfCompileUnit.cpp:1408

DwarfCompileUnit & getCU() override

void attachRangesOrLowHighPC(DIE &D, SmallVector< RangeSpan, 2 > Ranges)

Definition DwarfCompileUnit.cpp:687

void finishSubprogramDefinition(const DISubprogram *SP)

Definition DwarfCompileUnit.cpp:1477

Collects and handles dwarf debug information.

uint16_t getDwarfVersion() const

Returns the Dwarf Version.

DwarfCompileUnit * lookupCU(const DIE *Die)

Find the matching DwarfCompileUnit for the given CU DIE.

static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)

bool useSplitDwarf() const

Returns whether or not to change the current debug info for the split dwarf proposal support.

void addAccelName(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)

void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr)

Set the location (Loc) and DIExpression (DIExpr) to describe.

void addFragmentOffset(const DIExpression *Expr)

If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Ex...

void setMemoryLocationKind()

Lock this down to become a memory location description.

std::optional< uint8_t > TagOffset

void setCallSiteParamValueFlag()

Lock this down to become a call site parameter location.

bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, llvm::Register MachineReg, unsigned FragmentOffsetInBits=0)

Emit a machine register location.

void addExpression(DIExpressionCursor &&Expr)

Emit all remaining operations in the DIExpressionCursor.

void addWasmLocation(unsigned Index, uint64_t Offset)

Emit location information expressed via WebAssembly location + offset The Index is an identifier for ...

void beginEntryValueExpression(DIExpressionCursor &ExprCursor)

Begin emission of an entry value dwarf operation.

virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)

Find existing DIE or create new DIE for the given type.

DwarfDebug & getDwarfDebug() const

void addAnnotation(DIE &Buffer, DINodeArray Annotations)

Add DW_TAG_LLVM_annotation.

void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)

Add block data.

void addTemplateParams(DIE &Buffer, DINodeArray TParams)

Add template parameters in buffer.

virtual DIE * getOrCreateContextDIE(const DIScope *Context)

Get context owner's DIE.

void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)

void addOpAddress(DIELoc &Die, const MCSymbol *Sym)

Add a dwarf op address data and value using the form given and an op of either DW_FORM_addr or DW_FOR...

void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)

Add an unsigned integer attribute data and value.

void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)

Add a string attribute data and value.

void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)

Add constant value entry in variable DIE.

DIE * getOrCreateNameSpace(const DINamespace *NS)

void insertDIE(const DINode *Desc, DIE *D)

Insert DIE into the map.

void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)

addSectionDelta - Add a label delta attribute data and value.

bool shouldPlaceInUnitDIE(const DISubprogram *SP, bool Minimal)

const DICompileUnit * CUNode

MDNode for the compile unit.

virtual DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, const Function *FnHint, bool Minimal=false)

DIE * getOrCreateSubprogramContextDIE(const DISubprogram *SP, bool IgnoreScope)

DIE * getDIE(const DINode *D) const

Returns the DIE map slot for the specified debug variable.

MCSymbol * LabelBegin

The start of the unit within its section.

void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, int64_t Integer)

Add an signed integer attribute data and value.

DwarfUnit(dwarf::Tag, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID=0)

void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)

Add a label delta attribute data and value.

void addLinkageName(DIE &Die, StringRef LinkageName)

Add a linkage name, if it isn't empty.

std::string getParentContextString(const DIScope *Context) const

Get string containing language specific context for a global name.

void addSourceLine(DIE &Die, unsigned Line, unsigned Column, const DIFile *File)

Add location information to specified debug information entry.

void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)

Emit the common part of the header for this unit.

BumpPtrAllocator DIEValueAllocator

DIE * getOrCreateModule(const DIModule *M)

const DICompileUnit * getCUNode() const

DIE & createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N=nullptr)

Create a DIE with the given Tag, add the DIE to its parent, and call insertDIE if MD is not null.

DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)

Create new static data member DIE.

void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)

Add a Dwarf label attribute data and value.

void addConstantFPValue(DIE &Die, const ConstantFP *CFP)

Add constant value entry in variable DIE.

void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)

Add a Dwarf section label attribute data and value.

void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)

void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)

MCSymbol * EndLabel

Emitted at the end of the CU and used to compute the CU Length field.

void addFlag(DIE &Die, dwarf::Attribute Attribute)

Add a flag that is true to the DIE.

AsmPrinter * Asm

Target of Dwarf emission.

unsigned getUniqueID() const

Gets Unique ID for this unit.

void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)

Add a new type attribute to the specified entity.

void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)

void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)

Add a DIE attribute data and value.

This class is used to track scope information.

Multi-value location description.

unsigned getDebugLocListIndex() const

std::optional< uint8_t > getDebugLocListTagOffset() const

Single value location description.

Base class for the full range of assembler expressions which are needed for parsing.

MCSection * getDwarfRangesSection() const

MCSection * getDwarfAddrSection() const

MCSection * getDwarfLineSection() const

MCSymbol * getBeginSymbol()

void setType(wasm::WasmSymbolType type)

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

bool isDefined() const

isDefined - Check if this symbol is defined (i.e., it has an address).

A Module instance is used to store all the information related to an LLVM module.

StringRef getName() const

Get a short "name" for the module.

Wrapper class representing virtual and physical registers.

static constexpr bool isPhysicalRegister(unsigned Reg)

Return true if the specified register number is in the physical register namespace.

Implements a dense probed hash-table based set with some number of buckets stored inline.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

constexpr bool empty() const

empty - Check if the string is empty.

Information about stack frame layout on the target.

virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const

Return the frame base information to be encoded in the DWARF subprogram debug info.

virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const

getFrameIndexReference - This method should return the base register and offset used to reference a f...

const Triple & getTargetTriple() const

TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...

bool isNVPTX() const

Tests whether the target is NVPTX (32- or 64-bit).

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

StringRef toStringRef(SmallVectorImpl< char > &Out) const

This returns the twine as a single StringRef if it can be represented as such.

std::pair< iterator, bool > insert(const ValueT &V)

size_type count(const_arg_type_t< ValueT > V) const

Return 1 if the specified key is in the set, 0 otherwise.

A DeclContext is a named program scope that is used for ODR uniquing of types.

LLVM_ABI StringRef AttributeEncodingString(unsigned Encoding)

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

@ DWARF_ADDR_shared_space

@ DWARF_ADDR_global_space

@ DWARF_ADDR_generic_space

initializer< Ty > init(const Ty &Val)

UnitType

Constants for unit types in DWARF v5.

@ WASM_SYMBOL_TYPE_GLOBAL

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

auto dyn_cast_if_present(const Y &Val)

dyn_cast_if_present - Functionally identical to dyn_cast, except that a null (or none in the case ...

bool isRangeRelaxable(const MCSymbol *Begin, const MCSymbol *End)

bool isa_and_nonnull(const Y &Val)

std::pair< const MachineInstr *, const MachineInstr * > InsnRange

This is used to track range of instructions with identical lexical scope.

bool any_of(R &&range, UnaryPredicate P)

Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.

auto reverse(ContainerTy &&C)

@ Apple

.apple_names, .apple_namespaces, .apple_types, .apple_objc.

FunctionAddr VTableAddr Count

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

@ Global

Append to llvm.global_dtors.

constexpr T divideCeil(U Numerator, V Denominator)

Returns the integer ceil(Numerator / Denominator).

@ Sub

Subtraction of integers.

auto count(R &&Range, const E &Element)

Wrapper function around std::count to count the number of times an element Element occurs in the give...

DWARFExpression::Operation Op

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)

Find subprogram that is enclosing this scope.

Single location defined by (potentially multiple) EntryValueInfo.

std::set< EntryValueInfo > EntryValues

Single location defined by (potentially multiple) MMI entries.

const std::set< FrameIndexExpr > & getFrameIndexExprs() const

Get the FI entries, sorted by fragment offset.

Helper used to pair up a symbol and its DWARF compile unit.

union llvm::TargetFrameLowering::DwarfFrameBase::@004076321055032247336074224075335064105264310375 Location

enum llvm::TargetFrameLowering::DwarfFrameBase::FrameBaseKind Kind

struct WasmFrameBase WasmLoc