10b57cec5SDimitry Andric //===- llvm/CodeGen/DwarfCompileUnit.h - Dwarf Compile Unit -----*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file contains support for writing dwarf compile unit. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H 140b57cec5SDimitry Andric #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "DwarfDebug.h" 170b57cec5SDimitry Andric #include "DwarfUnit.h" 180b57cec5SDimitry Andric #include "llvm/ADT/ArrayRef.h" 190b57cec5SDimitry Andric #include "llvm/ADT/DenseMap.h" 200b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h" 210b57cec5SDimitry Andric #include "llvm/ADT/StringMap.h" 220b57cec5SDimitry Andric #include "llvm/ADT/StringRef.h" 230b57cec5SDimitry Andric #include "llvm/BinaryFormat/Dwarf.h" 240b57cec5SDimitry Andric #include "llvm/CodeGen/DbgEntityHistoryCalculator.h" 250b57cec5SDimitry Andric #include "llvm/CodeGen/LexicalScopes.h" 260b57cec5SDimitry Andric #include "llvm/IR/DebugInfoMetadata.h" 270b57cec5SDimitry Andric #include "llvm/Support/Casting.h" 280b57cec5SDimitry Andric #include <cassert> 290b57cec5SDimitry Andric #include <cstdint> 300b57cec5SDimitry Andric #include <memory> 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric namespace llvm { 330b57cec5SDimitry Andric 340b57cec5SDimitry Andric class AsmPrinter; 35e8d8bef9SDimitry Andric class DIE; 36e8d8bef9SDimitry Andric class DIELoc; 37e8d8bef9SDimitry Andric class DIEValueList; 380b57cec5SDimitry Andric class DwarfFile; 390b57cec5SDimitry Andric class GlobalVariable; 400b57cec5SDimitry Andric class MCExpr; 410b57cec5SDimitry Andric class MCSymbol; 420b57cec5SDimitry Andric class MDNode; 430b57cec5SDimitry Andric 44480093f4SDimitry Andric enum class UnitKind { Skeleton, Full }; 45480093f4SDimitry Andric 460b57cec5SDimitry Andric class DwarfCompileUnit final : public DwarfUnit { 470b57cec5SDimitry Andric /// A numeric ID unique among all CUs in the module 480b57cec5SDimitry Andric unsigned UniqueID; 490b57cec5SDimitry Andric bool HasRangeLists = false; 500b57cec5SDimitry Andric 515ffd83dbSDimitry Andric /// The start of the unit line section, this is also 525ffd83dbSDimitry Andric /// reused in appyStmtList. 535ffd83dbSDimitry Andric MCSymbol *LineTableStartSym; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric /// Skeleton unit associated with this unit. 560b57cec5SDimitry Andric DwarfCompileUnit *Skeleton = nullptr; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric /// The start of the unit within its section. 59e8d8bef9SDimitry Andric MCSymbol *LabelBegin = nullptr; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric /// The start of the unit macro info within macro section. 620b57cec5SDimitry Andric MCSymbol *MacroLabelBegin; 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric /// GlobalNames - A map of globally visible named entities for this unit. 650b57cec5SDimitry Andric StringMap<const DIE *> GlobalNames; 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric /// GlobalTypes - A map of globally visible types for this unit. 680b57cec5SDimitry Andric StringMap<const DIE *> GlobalTypes; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric // List of ranges for a given compile unit. 710b57cec5SDimitry Andric SmallVector<RangeSpan, 2> CURanges; 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric // The base address of this unit, if any. Used for relative references in 740b57cec5SDimitry Andric // ranges/locs. 750b57cec5SDimitry Andric const MCSymbol *BaseAddress = nullptr; 760b57cec5SDimitry Andric 77*06c3fb27SDimitry Andric using MDNodeSetVector = 78*06c3fb27SDimitry Andric SetVector<const MDNode *, SmallVector<const MDNode *, 4>, 79*06c3fb27SDimitry Andric SmallPtrSet<const MDNode *, 4>>; 80*06c3fb27SDimitry Andric 81*06c3fb27SDimitry Andric // List of entities (either static locals, types or imports) that 82*06c3fb27SDimitry Andric // belong to subprograms within this CU. 83*06c3fb27SDimitry Andric MDNodeSetVector DeferredLocalDecls; 84*06c3fb27SDimitry Andric 85*06c3fb27SDimitry Andric // List of concrete lexical block scopes belong to subprograms within this CU. 86*06c3fb27SDimitry Andric DenseMap<const DILocalScope *, DIE *> LexicalBlockDIEs; 87*06c3fb27SDimitry Andric 88*06c3fb27SDimitry Andric // List of abstract local scopes (either DISubprogram or DILexicalBlock). 89*06c3fb27SDimitry Andric DenseMap<const DILocalScope *, DIE *> AbstractLocalScopeDIEs; 90*06c3fb27SDimitry Andric 910b57cec5SDimitry Andric DenseMap<const DINode *, std::unique_ptr<DbgEntity>> AbstractEntities; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric /// DWO ID for correlating skeleton and split units. 940b57cec5SDimitry Andric uint64_t DWOId = 0; 950b57cec5SDimitry Andric 9604eeddc0SDimitry Andric const DIFile *LastFile = nullptr; 9704eeddc0SDimitry Andric unsigned LastFileID; 9804eeddc0SDimitry Andric 990b57cec5SDimitry Andric /// Construct a DIE for the given DbgVariable without initializing the 1000b57cec5SDimitry Andric /// DbgVariable's DIE reference. 1010b57cec5SDimitry Andric DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract); 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric bool isDwoUnit() const override; 1040b57cec5SDimitry Andric 105*06c3fb27SDimitry Andric DenseMap<const DILocalScope *, DIE *> &getAbstractScopeDIEs() { 1060b57cec5SDimitry Andric if (isDwoUnit() && !DD->shareAcrossDWOCUs()) 107*06c3fb27SDimitry Andric return AbstractLocalScopeDIEs; 108*06c3fb27SDimitry Andric return DU->getAbstractScopeDIEs(); 1090b57cec5SDimitry Andric } 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric DenseMap<const DINode *, std::unique_ptr<DbgEntity>> &getAbstractEntities() { 1120b57cec5SDimitry Andric if (isDwoUnit() && !DD->shareAcrossDWOCUs()) 1130b57cec5SDimitry Andric return AbstractEntities; 1140b57cec5SDimitry Andric return DU->getAbstractEntities(); 1150b57cec5SDimitry Andric } 1160b57cec5SDimitry Andric 1170b57cec5SDimitry Andric void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) override; 1180b57cec5SDimitry Andric 119*06c3fb27SDimitry Andric /// Add info for Wasm-global-based relocation. 120*06c3fb27SDimitry Andric void addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName, 121*06c3fb27SDimitry Andric uint64_t GlobalIndex); 122*06c3fb27SDimitry Andric 1230b57cec5SDimitry Andric public: 1240b57cec5SDimitry Andric DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, 125480093f4SDimitry Andric DwarfDebug *DW, DwarfFile *DWU, 126480093f4SDimitry Andric UnitKind Kind = UnitKind::Full); 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andric bool hasRangeLists() const { return HasRangeLists; } 1290b57cec5SDimitry Andric unsigned getUniqueID() const { return UniqueID; } 1300b57cec5SDimitry Andric 1310b57cec5SDimitry Andric DwarfCompileUnit *getSkeleton() const { 1320b57cec5SDimitry Andric return Skeleton; 1330b57cec5SDimitry Andric } 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric bool includeMinimalInlineScopes() const; 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric void initStmtList(); 1380b57cec5SDimitry Andric 1390b57cec5SDimitry Andric /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE. 1400b57cec5SDimitry Andric void applyStmtList(DIE &D); 1410b57cec5SDimitry Andric 1425ffd83dbSDimitry Andric /// Get line table start symbol for this unit. 1435ffd83dbSDimitry Andric MCSymbol *getLineTableStartSym() const { return LineTableStartSym; } 1445ffd83dbSDimitry Andric 1450b57cec5SDimitry Andric /// A pair of GlobalVariable and DIExpression. 1460b57cec5SDimitry Andric struct GlobalExpr { 1470b57cec5SDimitry Andric const GlobalVariable *Var; 1480b57cec5SDimitry Andric const DIExpression *Expr; 1490b57cec5SDimitry Andric }; 1500b57cec5SDimitry Andric 1510b57cec5SDimitry Andric struct BaseTypeRef { 1520b57cec5SDimitry Andric BaseTypeRef(unsigned BitSize, dwarf::TypeKind Encoding) : 1530b57cec5SDimitry Andric BitSize(BitSize), Encoding(Encoding) {} 1540b57cec5SDimitry Andric unsigned BitSize; 1550b57cec5SDimitry Andric dwarf::TypeKind Encoding; 1560b57cec5SDimitry Andric DIE *Die = nullptr; 1570b57cec5SDimitry Andric }; 1580b57cec5SDimitry Andric 1590b57cec5SDimitry Andric std::vector<BaseTypeRef> ExprRefedBaseTypes; 1600b57cec5SDimitry Andric 1610b57cec5SDimitry Andric /// Get or create global variable DIE. 1620b57cec5SDimitry Andric DIE * 1630b57cec5SDimitry Andric getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, 1640b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1650b57cec5SDimitry Andric 1660b57cec5SDimitry Andric DIE *getOrCreateCommonBlock(const DICommonBlock *CB, 1670b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1680b57cec5SDimitry Andric 1690b57cec5SDimitry Andric void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV, 1700b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric /// addLabelAddress - Add a dwarf label attribute data and value using 1730b57cec5SDimitry Andric /// either DW_FORM_addr or DW_FORM_GNU_addr_index. 1740b57cec5SDimitry Andric void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, 1750b57cec5SDimitry Andric const MCSymbol *Label); 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andric /// addLocalLabelAddress - Add a dwarf label attribute data and value using 1780b57cec5SDimitry Andric /// DW_FORM_addr only. 1790b57cec5SDimitry Andric void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, 1800b57cec5SDimitry Andric const MCSymbol *Label); 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andric DwarfCompileUnit &getCU() override { return *this; } 1830b57cec5SDimitry Andric 1840b57cec5SDimitry Andric unsigned getOrCreateSourceID(const DIFile *File) override; 1850b57cec5SDimitry Andric 1860b57cec5SDimitry Andric /// addRange - Add an address range to the list of ranges for this unit. 1870b57cec5SDimitry Andric void addRange(RangeSpan Range); 1880b57cec5SDimitry Andric 1890b57cec5SDimitry Andric void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End); 1900b57cec5SDimitry Andric 1910b57cec5SDimitry Andric /// Find DIE for the given subprogram and attach appropriate 1920b57cec5SDimitry Andric /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global 1930b57cec5SDimitry Andric /// variables in this scope then create and insert DIEs for these 1940b57cec5SDimitry Andric /// variables. 1950b57cec5SDimitry Andric DIE &updateSubprogramScopeDIE(const DISubprogram *SP); 196bdd1243dSDimitry Andric DIE &updateSubprogramScopeDIEImpl(const DISubprogram *SP, DIE *SPDie); 1970b57cec5SDimitry Andric 1984824e7fdSDimitry Andric void constructScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE); 1990b57cec5SDimitry Andric 2000b57cec5SDimitry Andric /// A helper function to construct a RangeSpanList for a given 2010b57cec5SDimitry Andric /// lexical scope. 2020b57cec5SDimitry Andric void addScopeRangeList(DIE &ScopeDIE, SmallVector<RangeSpan, 2> Range); 2030b57cec5SDimitry Andric 2040b57cec5SDimitry Andric void attachRangesOrLowHighPC(DIE &D, SmallVector<RangeSpan, 2> Ranges); 2050b57cec5SDimitry Andric 2060b57cec5SDimitry Andric void attachRangesOrLowHighPC(DIE &D, 2070b57cec5SDimitry Andric const SmallVectorImpl<InsnRange> &Ranges); 2080b57cec5SDimitry Andric 209bdd1243dSDimitry Andric /// This scope represents an inlined body of a function. Construct a 2100b57cec5SDimitry Andric /// DIE to represent this concrete inlined copy of the function. 211bdd1243dSDimitry Andric DIE *constructInlinedScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE); 2120b57cec5SDimitry Andric 2130b57cec5SDimitry Andric /// Construct new DW_TAG_lexical_block for this scope and 2140b57cec5SDimitry Andric /// attach DW_AT_low_pc/DW_AT_high_pc labels. 2150b57cec5SDimitry Andric DIE *constructLexicalScopeDIE(LexicalScope *Scope); 2160b57cec5SDimitry Andric 217*06c3fb27SDimitry Andric /// Get a DIE for the given DILexicalBlock. 218*06c3fb27SDimitry Andric /// Note that this function assumes that the DIE has been already created 219*06c3fb27SDimitry Andric /// and it's an error, if it hasn't. 220*06c3fb27SDimitry Andric DIE *getLexicalBlockDIE(const DILexicalBlock *LB); 221*06c3fb27SDimitry Andric 2220b57cec5SDimitry Andric /// constructVariableDIE - Construct a DIE for the given DbgVariable. 2230b57cec5SDimitry Andric DIE *constructVariableDIE(DbgVariable &DV, bool Abstract = false); 2240b57cec5SDimitry Andric 2250b57cec5SDimitry Andric DIE *constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope, 2260b57cec5SDimitry Andric DIE *&ObjectPointer); 2270b57cec5SDimitry Andric 2280b57cec5SDimitry Andric /// Construct a DIE for the given DbgLabel. 2290b57cec5SDimitry Andric DIE *constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope); 2300b57cec5SDimitry Andric 2310b57cec5SDimitry Andric void createBaseTypeDIEs(); 2320b57cec5SDimitry Andric 233*06c3fb27SDimitry Andric /// Construct a DIE for a given scope. 234*06c3fb27SDimitry Andric /// This instance of 'getOrCreateContextDIE()' can handle DILocalScope. 235*06c3fb27SDimitry Andric DIE *getOrCreateContextDIE(const DIScope *Ty) override; 236*06c3fb27SDimitry Andric 2370b57cec5SDimitry Andric /// Construct a DIE for this subprogram scope. 2380b57cec5SDimitry Andric DIE &constructSubprogramScopeDIE(const DISubprogram *Sub, 2390b57cec5SDimitry Andric LexicalScope *Scope); 2400b57cec5SDimitry Andric 2410b57cec5SDimitry Andric DIE *createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE); 2420b57cec5SDimitry Andric 2430b57cec5SDimitry Andric void constructAbstractSubprogramScopeDIE(LexicalScope *Scope); 2440b57cec5SDimitry Andric 2455ffd83dbSDimitry Andric /// Whether to use the GNU analog for a DWARF5 tag, attribute, or location 2465ffd83dbSDimitry Andric /// atom. Only applicable when emitting otherwise DWARF4-compliant debug info. 2475ffd83dbSDimitry Andric bool useGNUAnalogForDwarf5Feature() const; 2485ffd83dbSDimitry Andric 2498bcb0991SDimitry Andric /// This takes a DWARF 5 tag and returns it or a GNU analog. 2508bcb0991SDimitry Andric dwarf::Tag getDwarf5OrGNUTag(dwarf::Tag Tag) const; 2518bcb0991SDimitry Andric 2528bcb0991SDimitry Andric /// This takes a DWARF 5 attribute and returns it or a GNU analog. 2538bcb0991SDimitry Andric dwarf::Attribute getDwarf5OrGNUAttr(dwarf::Attribute Attr) const; 2548bcb0991SDimitry Andric 2558bcb0991SDimitry Andric /// This takes a DWARF 5 location atom and either returns it or a GNU analog. 2568bcb0991SDimitry Andric dwarf::LocationAtom getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const; 2578bcb0991SDimitry Andric 2580b57cec5SDimitry Andric /// Construct a call site entry DIE describing a call within \p Scope to a 25969ade1e0SDimitry Andric /// callee described by \p CalleeSP. 2608bcb0991SDimitry Andric /// \p IsTail specifies whether the call is a tail call. 2615ffd83dbSDimitry Andric /// \p PCAddr points to the PC value after the call instruction. 2625ffd83dbSDimitry Andric /// \p CallAddr points to the PC value at the call instruction (or is null). 2638bcb0991SDimitry Andric /// \p CallReg is a register location for an indirect call. For direct calls 2648bcb0991SDimitry Andric /// the \p CallReg is set to 0. 26569ade1e0SDimitry Andric DIE &constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP, 26669ade1e0SDimitry Andric bool IsTail, const MCSymbol *PCAddr, 2675ffd83dbSDimitry Andric const MCSymbol *CallAddr, unsigned CallReg); 2688bcb0991SDimitry Andric /// Construct call site parameter DIEs for the \p CallSiteDIE. The \p Params 2698bcb0991SDimitry Andric /// were collected by the \ref collectCallSiteParameters. 2708bcb0991SDimitry Andric /// Note: The order of parameters does not matter, since debuggers recognize 2718bcb0991SDimitry Andric /// call site parameters by the DW_AT_location attribute. 2728bcb0991SDimitry Andric void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE, 2738bcb0991SDimitry Andric SmallVector<DbgCallSiteParam, 4> &Params); 2740b57cec5SDimitry Andric 275*06c3fb27SDimitry Andric /// Get or create a DIE for an imported entity. 276*06c3fb27SDimitry Andric DIE *getOrCreateImportedEntityDIE(const DIImportedEntity *IE); 277*06c3fb27SDimitry Andric DIE *constructImportedEntityDIE(const DIImportedEntity *IE); 2780b57cec5SDimitry Andric 2790b57cec5SDimitry Andric void finishSubprogramDefinition(const DISubprogram *SP); 2800b57cec5SDimitry Andric void finishEntityDefinition(const DbgEntity *Entity); 2810b57cec5SDimitry Andric 2820b57cec5SDimitry Andric /// Find abstract variable associated with Var. 2830b57cec5SDimitry Andric using InlinedEntity = DbgValueHistoryMap::InlinedEntity; 2840b57cec5SDimitry Andric DbgEntity *getExistingAbstractEntity(const DINode *Node); 2850b57cec5SDimitry Andric void createAbstractEntity(const DINode *Node, LexicalScope *Scope); 2860b57cec5SDimitry Andric 2870b57cec5SDimitry Andric /// Set the skeleton unit associated with this unit. 2880b57cec5SDimitry Andric void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; } 2890b57cec5SDimitry Andric 2900b57cec5SDimitry Andric unsigned getHeaderSize() const override { 2910b57cec5SDimitry Andric // DWARF v5 added the DWO ID to the header for split/skeleton units. 2920b57cec5SDimitry Andric unsigned DWOIdSize = 2930b57cec5SDimitry Andric DD->getDwarfVersion() >= 5 && DD->useSplitDwarf() ? sizeof(uint64_t) 2940b57cec5SDimitry Andric : 0; 2950b57cec5SDimitry Andric return DwarfUnit::getHeaderSize() + DWOIdSize; 2960b57cec5SDimitry Andric } 2970b57cec5SDimitry Andric unsigned getLength() { 298e8d8bef9SDimitry Andric return Asm->getUnitLengthFieldByteSize() + // Length field 2990b57cec5SDimitry Andric getHeaderSize() + getUnitDie().getSize(); 3000b57cec5SDimitry Andric } 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andric void emitHeader(bool UseOffsets) override; 3030b57cec5SDimitry Andric 3040b57cec5SDimitry Andric /// Add the DW_AT_addr_base attribute to the unit DIE. 3050b57cec5SDimitry Andric void addAddrTableBase(); 3060b57cec5SDimitry Andric 3070b57cec5SDimitry Andric MCSymbol *getLabelBegin() const { 308e8d8bef9SDimitry Andric assert(LabelBegin && "LabelBegin is not initialized"); 3090b57cec5SDimitry Andric return LabelBegin; 3100b57cec5SDimitry Andric } 3110b57cec5SDimitry Andric 3120b57cec5SDimitry Andric MCSymbol *getMacroLabelBegin() const { 3130b57cec5SDimitry Andric return MacroLabelBegin; 3140b57cec5SDimitry Andric } 3150b57cec5SDimitry Andric 3160b57cec5SDimitry Andric /// Add a new global name to the compile unit. 3170b57cec5SDimitry Andric void addGlobalName(StringRef Name, const DIE &Die, 3180b57cec5SDimitry Andric const DIScope *Context) override; 3190b57cec5SDimitry Andric 3200b57cec5SDimitry Andric /// Add a new global name present in a type unit to this compile unit. 3210b57cec5SDimitry Andric void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context); 3220b57cec5SDimitry Andric 3230b57cec5SDimitry Andric /// Add a new global type to the compile unit. 3240b57cec5SDimitry Andric void addGlobalType(const DIType *Ty, const DIE &Die, 3250b57cec5SDimitry Andric const DIScope *Context) override; 3260b57cec5SDimitry Andric 3270b57cec5SDimitry Andric /// Add a new global type present in a type unit to this compile unit. 3280b57cec5SDimitry Andric void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context); 3290b57cec5SDimitry Andric 3300b57cec5SDimitry Andric const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; } 3310b57cec5SDimitry Andric const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; } 3320b57cec5SDimitry Andric 3330b57cec5SDimitry Andric /// Add DW_AT_location attribute for a DbgVariable based on provided 3340b57cec5SDimitry Andric /// MachineLocation. 3350b57cec5SDimitry Andric void addVariableAddress(const DbgVariable &DV, DIE &Die, 3360b57cec5SDimitry Andric MachineLocation Location); 3370b57cec5SDimitry Andric /// Add an address attribute to a die based on the location provided. 3380b57cec5SDimitry Andric void addAddress(DIE &Die, dwarf::Attribute Attribute, 3390b57cec5SDimitry Andric const MachineLocation &Location); 3400b57cec5SDimitry Andric 3410b57cec5SDimitry Andric /// Start with the address based on the location provided, and generate the 3420b57cec5SDimitry Andric /// DWARF information necessary to find the actual variable (navigating the 3430b57cec5SDimitry Andric /// extra location information encoded in the type) based on the starting 3440b57cec5SDimitry Andric /// location. Add the DWARF information to the die. 3450b57cec5SDimitry Andric void addComplexAddress(const DbgVariable &DV, DIE &Die, 3460b57cec5SDimitry Andric dwarf::Attribute Attribute, 3470b57cec5SDimitry Andric const MachineLocation &Location); 3480b57cec5SDimitry Andric 3490b57cec5SDimitry Andric /// Add a Dwarf loclistptr attribute data and value. 3500b57cec5SDimitry Andric void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index); 3510b57cec5SDimitry Andric void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie); 3520b57cec5SDimitry Andric 3530b57cec5SDimitry Andric /// Add a Dwarf expression attribute data and value. 3540b57cec5SDimitry Andric void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr); 3550b57cec5SDimitry Andric 3560b57cec5SDimitry Andric void applySubprogramAttributesToDefinition(const DISubprogram *SP, 3570b57cec5SDimitry Andric DIE &SPDie); 3580b57cec5SDimitry Andric 3590b57cec5SDimitry Andric void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie); 3600b57cec5SDimitry Andric 3610b57cec5SDimitry Andric /// getRanges - Get the list of ranges for this unit. 3620b57cec5SDimitry Andric const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; } 3630b57cec5SDimitry Andric SmallVector<RangeSpan, 2> takeRanges() { return std::move(CURanges); } 3640b57cec5SDimitry Andric 3650b57cec5SDimitry Andric void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; } 3660b57cec5SDimitry Andric const MCSymbol *getBaseAddress() const { return BaseAddress; } 3670b57cec5SDimitry Andric 3680b57cec5SDimitry Andric uint64_t getDWOId() const { return DWOId; } 3690b57cec5SDimitry Andric void setDWOId(uint64_t DwoId) { DWOId = DwoId; } 3700b57cec5SDimitry Andric 3710b57cec5SDimitry Andric bool hasDwarfPubSections() const; 3720b57cec5SDimitry Andric 3730b57cec5SDimitry Andric void addBaseTypeRef(DIEValueList &Die, int64_t Idx); 374*06c3fb27SDimitry Andric 375*06c3fb27SDimitry Andric MDNodeSetVector &getDeferredLocalDecls() { return DeferredLocalDecls; } 3760b57cec5SDimitry Andric }; 3770b57cec5SDimitry Andric 3780b57cec5SDimitry Andric } // end namespace llvm 3790b57cec5SDimitry Andric 3800b57cec5SDimitry Andric #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H 381