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 <cstdint> 290b57cec5SDimitry Andric #include <memory> 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric namespace llvm { 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric class AsmPrinter; 34e8d8bef9SDimitry Andric class DIE; 35e8d8bef9SDimitry Andric class DIELoc; 36e8d8bef9SDimitry Andric class DIEValueList; 370b57cec5SDimitry Andric class DwarfFile; 380b57cec5SDimitry Andric class GlobalVariable; 390b57cec5SDimitry Andric class MCExpr; 400b57cec5SDimitry Andric class MCSymbol; 410b57cec5SDimitry Andric class MDNode; 420b57cec5SDimitry Andric 43480093f4SDimitry Andric enum class UnitKind { Skeleton, Full }; 44480093f4SDimitry Andric 450b57cec5SDimitry Andric class DwarfCompileUnit final : public DwarfUnit { 460b57cec5SDimitry Andric bool HasRangeLists = false; 470b57cec5SDimitry Andric 485ffd83dbSDimitry Andric /// The start of the unit line section, this is also 495ffd83dbSDimitry Andric /// reused in appyStmtList. 505ffd83dbSDimitry Andric MCSymbol *LineTableStartSym; 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric /// Skeleton unit associated with this unit. 530b57cec5SDimitry Andric DwarfCompileUnit *Skeleton = nullptr; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric /// The start of the unit macro info within macro section. 560b57cec5SDimitry Andric MCSymbol *MacroLabelBegin; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric /// GlobalNames - A map of globally visible named entities for this unit. 590b57cec5SDimitry Andric StringMap<const DIE *> GlobalNames; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric /// GlobalTypes - A map of globally visible types for this unit. 620b57cec5SDimitry Andric StringMap<const DIE *> GlobalTypes; 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric // List of ranges for a given compile unit. 650b57cec5SDimitry Andric SmallVector<RangeSpan, 2> CURanges; 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric // The base address of this unit, if any. Used for relative references in 680b57cec5SDimitry Andric // ranges/locs. 690b57cec5SDimitry Andric const MCSymbol *BaseAddress = nullptr; 700b57cec5SDimitry Andric 7106c3fb27SDimitry Andric using MDNodeSetVector = 7206c3fb27SDimitry Andric SetVector<const MDNode *, SmallVector<const MDNode *, 4>, 7306c3fb27SDimitry Andric SmallPtrSet<const MDNode *, 4>>; 7406c3fb27SDimitry Andric 7506c3fb27SDimitry Andric // List of entities (either static locals, types or imports) that 7606c3fb27SDimitry Andric // belong to subprograms within this CU. 7706c3fb27SDimitry Andric MDNodeSetVector DeferredLocalDecls; 7806c3fb27SDimitry Andric 7906c3fb27SDimitry Andric // List of concrete lexical block scopes belong to subprograms within this CU. 8006c3fb27SDimitry Andric DenseMap<const DILocalScope *, DIE *> LexicalBlockDIEs; 8106c3fb27SDimitry Andric 8206c3fb27SDimitry Andric // List of abstract local scopes (either DISubprogram or DILexicalBlock). 8306c3fb27SDimitry Andric DenseMap<const DILocalScope *, DIE *> AbstractLocalScopeDIEs; 8406c3fb27SDimitry Andric 850b57cec5SDimitry Andric DenseMap<const DINode *, std::unique_ptr<DbgEntity>> AbstractEntities; 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric /// DWO ID for correlating skeleton and split units. 880b57cec5SDimitry Andric uint64_t DWOId = 0; 890b57cec5SDimitry Andric 9004eeddc0SDimitry Andric const DIFile *LastFile = nullptr; 9104eeddc0SDimitry Andric unsigned LastFileID; 9204eeddc0SDimitry Andric 935f757f3fSDimitry Andric /// \anchor applyConcreteDbgVariableAttribute 945f757f3fSDimitry Andric /// \name applyConcreteDbgVariableAttribute 955f757f3fSDimitry Andric /// Overload set which applies attributes to \c VariableDie based on 965f757f3fSDimitry Andric /// the active variant of \c DV, which is passed as the first argument. 975f757f3fSDimitry Andric ///@{ 985f757f3fSDimitry Andric 995f757f3fSDimitry Andric /// See \ref applyConcreteDbgVariableAttribute 1005f757f3fSDimitry Andric void applyConcreteDbgVariableAttributes(const Loc::Single &Single, 1015f757f3fSDimitry Andric const DbgVariable &DV, 1025f757f3fSDimitry Andric DIE &VariableDie); 1035f757f3fSDimitry Andric /// See \ref applyConcreteDbgVariableAttribute 1045f757f3fSDimitry Andric void applyConcreteDbgVariableAttributes(const Loc::Multi &Multi, 1055f757f3fSDimitry Andric const DbgVariable &DV, 1065f757f3fSDimitry Andric DIE &VariableDie); 1075f757f3fSDimitry Andric /// See \ref applyConcreteDbgVariableAttribute 1085f757f3fSDimitry Andric void applyConcreteDbgVariableAttributes(const Loc::MMI &MMI, 1095f757f3fSDimitry Andric const DbgVariable &DV, 1105f757f3fSDimitry Andric DIE &VariableDie); 1115f757f3fSDimitry Andric /// See \ref applyConcreteDbgVariableAttribute 1125f757f3fSDimitry Andric void applyConcreteDbgVariableAttributes(const Loc::EntryValue &EntryValue, 1135f757f3fSDimitry Andric const DbgVariable &DV, 1145f757f3fSDimitry Andric DIE &VariableDie); 1155f757f3fSDimitry Andric /// See \ref applyConcreteDbgVariableAttribute 1165f757f3fSDimitry Andric void applyConcreteDbgVariableAttributes(const std::monostate &, 1175f757f3fSDimitry Andric const DbgVariable &DV, 1185f757f3fSDimitry Andric DIE &VariableDie); 1195f757f3fSDimitry Andric 1205f757f3fSDimitry Andric ///@} 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andric bool isDwoUnit() const override; 1230b57cec5SDimitry Andric getAbstractScopeDIEs()12406c3fb27SDimitry Andric DenseMap<const DILocalScope *, DIE *> &getAbstractScopeDIEs() { 1250b57cec5SDimitry Andric if (isDwoUnit() && !DD->shareAcrossDWOCUs()) 12606c3fb27SDimitry Andric return AbstractLocalScopeDIEs; 12706c3fb27SDimitry Andric return DU->getAbstractScopeDIEs(); 1280b57cec5SDimitry Andric } 1290b57cec5SDimitry Andric getAbstractEntities()1300b57cec5SDimitry Andric DenseMap<const DINode *, std::unique_ptr<DbgEntity>> &getAbstractEntities() { 1310b57cec5SDimitry Andric if (isDwoUnit() && !DD->shareAcrossDWOCUs()) 1320b57cec5SDimitry Andric return AbstractEntities; 1330b57cec5SDimitry Andric return DU->getAbstractEntities(); 1340b57cec5SDimitry Andric } 1350b57cec5SDimitry Andric 1360b57cec5SDimitry Andric void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) override; 1370b57cec5SDimitry Andric 13806c3fb27SDimitry Andric /// Add info for Wasm-global-based relocation. 13906c3fb27SDimitry Andric void addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName, 14006c3fb27SDimitry Andric uint64_t GlobalIndex); 14106c3fb27SDimitry Andric 1420b57cec5SDimitry Andric public: 1430b57cec5SDimitry Andric DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, 144480093f4SDimitry Andric DwarfDebug *DW, DwarfFile *DWU, 145480093f4SDimitry Andric UnitKind Kind = UnitKind::Full); 1460b57cec5SDimitry Andric hasRangeLists()1470b57cec5SDimitry Andric bool hasRangeLists() const { return HasRangeLists; } 1480b57cec5SDimitry Andric getSkeleton()1490b57cec5SDimitry Andric DwarfCompileUnit *getSkeleton() const { 1500b57cec5SDimitry Andric return Skeleton; 1510b57cec5SDimitry Andric } 1520b57cec5SDimitry Andric 1530b57cec5SDimitry Andric bool includeMinimalInlineScopes() const; 1540b57cec5SDimitry Andric 1550b57cec5SDimitry Andric void initStmtList(); 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andric /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE. 1580b57cec5SDimitry Andric void applyStmtList(DIE &D); 1590b57cec5SDimitry Andric 1605ffd83dbSDimitry Andric /// Get line table start symbol for this unit. getLineTableStartSym()1615ffd83dbSDimitry Andric MCSymbol *getLineTableStartSym() const { return LineTableStartSym; } 1625ffd83dbSDimitry Andric 1630b57cec5SDimitry Andric /// A pair of GlobalVariable and DIExpression. 1640b57cec5SDimitry Andric struct GlobalExpr { 1650b57cec5SDimitry Andric const GlobalVariable *Var; 1660b57cec5SDimitry Andric const DIExpression *Expr; 1670b57cec5SDimitry Andric }; 1680b57cec5SDimitry Andric 1690b57cec5SDimitry Andric struct BaseTypeRef { BaseTypeRefBaseTypeRef1700b57cec5SDimitry Andric BaseTypeRef(unsigned BitSize, dwarf::TypeKind Encoding) : 1710b57cec5SDimitry Andric BitSize(BitSize), Encoding(Encoding) {} 1720b57cec5SDimitry Andric unsigned BitSize; 1730b57cec5SDimitry Andric dwarf::TypeKind Encoding; 1740b57cec5SDimitry Andric DIE *Die = nullptr; 1750b57cec5SDimitry Andric }; 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andric std::vector<BaseTypeRef> ExprRefedBaseTypes; 1780b57cec5SDimitry Andric 1790b57cec5SDimitry Andric /// Get or create global variable DIE. 1800b57cec5SDimitry Andric DIE * 1810b57cec5SDimitry Andric getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, 1820b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1830b57cec5SDimitry Andric 1840b57cec5SDimitry Andric DIE *getOrCreateCommonBlock(const DICommonBlock *CB, 1850b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1860b57cec5SDimitry Andric 1870b57cec5SDimitry Andric void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV, 1880b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1890b57cec5SDimitry Andric 1900b57cec5SDimitry Andric /// addLabelAddress - Add a dwarf label attribute data and value using 1910b57cec5SDimitry Andric /// either DW_FORM_addr or DW_FORM_GNU_addr_index. 1920b57cec5SDimitry Andric void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, 1930b57cec5SDimitry Andric const MCSymbol *Label); 1940b57cec5SDimitry Andric 1950b57cec5SDimitry Andric /// addLocalLabelAddress - Add a dwarf label attribute data and value using 1960b57cec5SDimitry Andric /// DW_FORM_addr only. 1970b57cec5SDimitry Andric void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, 1980b57cec5SDimitry Andric const MCSymbol *Label); 1990b57cec5SDimitry Andric getCU()2000b57cec5SDimitry Andric DwarfCompileUnit &getCU() override { return *this; } 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andric unsigned getOrCreateSourceID(const DIFile *File) override; 2030b57cec5SDimitry Andric 2040b57cec5SDimitry Andric /// addRange - Add an address range to the list of ranges for this unit. 2050b57cec5SDimitry Andric void addRange(RangeSpan Range); 2060b57cec5SDimitry Andric 2070b57cec5SDimitry Andric void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End); 2080b57cec5SDimitry Andric 2090b57cec5SDimitry Andric /// Find DIE for the given subprogram and attach appropriate 2100b57cec5SDimitry Andric /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global 2110b57cec5SDimitry Andric /// variables in this scope then create and insert DIEs for these 2120b57cec5SDimitry Andric /// variables. 2130b57cec5SDimitry Andric DIE &updateSubprogramScopeDIE(const DISubprogram *SP); 2140b57cec5SDimitry Andric 2154824e7fdSDimitry Andric void constructScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE); 2160b57cec5SDimitry Andric 2170b57cec5SDimitry Andric /// A helper function to construct a RangeSpanList for a given 2180b57cec5SDimitry Andric /// lexical scope. 2190b57cec5SDimitry Andric void addScopeRangeList(DIE &ScopeDIE, SmallVector<RangeSpan, 2> Range); 2200b57cec5SDimitry Andric 2210b57cec5SDimitry Andric void attachRangesOrLowHighPC(DIE &D, SmallVector<RangeSpan, 2> Ranges); 2220b57cec5SDimitry Andric 2230b57cec5SDimitry Andric void attachRangesOrLowHighPC(DIE &D, 2240b57cec5SDimitry Andric const SmallVectorImpl<InsnRange> &Ranges); 2250b57cec5SDimitry Andric 226bdd1243dSDimitry Andric /// This scope represents an inlined body of a function. Construct a 2270b57cec5SDimitry Andric /// DIE to represent this concrete inlined copy of the function. 228bdd1243dSDimitry Andric DIE *constructInlinedScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE); 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric /// Construct new DW_TAG_lexical_block for this scope and 2310b57cec5SDimitry Andric /// attach DW_AT_low_pc/DW_AT_high_pc labels. 2320b57cec5SDimitry Andric DIE *constructLexicalScopeDIE(LexicalScope *Scope); 2330b57cec5SDimitry Andric 23406c3fb27SDimitry Andric /// Get a DIE for the given DILexicalBlock. 23506c3fb27SDimitry Andric /// Note that this function assumes that the DIE has been already created 23606c3fb27SDimitry Andric /// and it's an error, if it hasn't. 23706c3fb27SDimitry Andric DIE *getLexicalBlockDIE(const DILexicalBlock *LB); 23806c3fb27SDimitry Andric 2395f757f3fSDimitry Andric /// Construct a DIE for the given DbgVariable. 2400b57cec5SDimitry Andric DIE *constructVariableDIE(DbgVariable &DV, bool Abstract = false); 2410b57cec5SDimitry Andric 2425f757f3fSDimitry Andric /// Convenience overload which writes the DIE pointer into an out variable 2435f757f3fSDimitry Andric /// ObjectPointer in addition to returning it. 2440b57cec5SDimitry Andric DIE *constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope, 2450b57cec5SDimitry Andric DIE *&ObjectPointer); 2460b57cec5SDimitry Andric 2470b57cec5SDimitry Andric /// Construct a DIE for the given DbgLabel. 2480b57cec5SDimitry Andric DIE *constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope); 2490b57cec5SDimitry Andric 2500b57cec5SDimitry Andric void createBaseTypeDIEs(); 2510b57cec5SDimitry Andric 25206c3fb27SDimitry Andric /// Construct a DIE for a given scope. 25306c3fb27SDimitry Andric /// This instance of 'getOrCreateContextDIE()' can handle DILocalScope. 25406c3fb27SDimitry Andric DIE *getOrCreateContextDIE(const DIScope *Ty) override; 25506c3fb27SDimitry Andric 2560b57cec5SDimitry Andric /// Construct a DIE for this subprogram scope. 2570b57cec5SDimitry Andric DIE &constructSubprogramScopeDIE(const DISubprogram *Sub, 2580b57cec5SDimitry Andric LexicalScope *Scope); 2590b57cec5SDimitry Andric 2600b57cec5SDimitry Andric DIE *createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE); 2610b57cec5SDimitry Andric 2620b57cec5SDimitry Andric void constructAbstractSubprogramScopeDIE(LexicalScope *Scope); 2630b57cec5SDimitry Andric 2645ffd83dbSDimitry Andric /// Whether to use the GNU analog for a DWARF5 tag, attribute, or location 2655ffd83dbSDimitry Andric /// atom. Only applicable when emitting otherwise DWARF4-compliant debug info. 2665ffd83dbSDimitry Andric bool useGNUAnalogForDwarf5Feature() const; 2675ffd83dbSDimitry Andric 2688bcb0991SDimitry Andric /// This takes a DWARF 5 tag and returns it or a GNU analog. 2698bcb0991SDimitry Andric dwarf::Tag getDwarf5OrGNUTag(dwarf::Tag Tag) const; 2708bcb0991SDimitry Andric 2718bcb0991SDimitry Andric /// This takes a DWARF 5 attribute and returns it or a GNU analog. 2728bcb0991SDimitry Andric dwarf::Attribute getDwarf5OrGNUAttr(dwarf::Attribute Attr) const; 2738bcb0991SDimitry Andric 2748bcb0991SDimitry Andric /// This takes a DWARF 5 location atom and either returns it or a GNU analog. 2758bcb0991SDimitry Andric dwarf::LocationAtom getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const; 2768bcb0991SDimitry Andric 2770b57cec5SDimitry Andric /// Construct a call site entry DIE describing a call within \p Scope to a 27869ade1e0SDimitry Andric /// callee described by \p CalleeSP. 2798bcb0991SDimitry Andric /// \p IsTail specifies whether the call is a tail call. 2805ffd83dbSDimitry Andric /// \p PCAddr points to the PC value after the call instruction. 2815ffd83dbSDimitry Andric /// \p CallAddr points to the PC value at the call instruction (or is null). 2828bcb0991SDimitry Andric /// \p CallReg is a register location for an indirect call. For direct calls 2838bcb0991SDimitry Andric /// the \p CallReg is set to 0. 28469ade1e0SDimitry Andric DIE &constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP, 28569ade1e0SDimitry Andric bool IsTail, const MCSymbol *PCAddr, 2865ffd83dbSDimitry Andric const MCSymbol *CallAddr, unsigned CallReg); 2878bcb0991SDimitry Andric /// Construct call site parameter DIEs for the \p CallSiteDIE. The \p Params 2888bcb0991SDimitry Andric /// were collected by the \ref collectCallSiteParameters. 2898bcb0991SDimitry Andric /// Note: The order of parameters does not matter, since debuggers recognize 2908bcb0991SDimitry Andric /// call site parameters by the DW_AT_location attribute. 2918bcb0991SDimitry Andric void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE, 2928bcb0991SDimitry Andric SmallVector<DbgCallSiteParam, 4> &Params); 2930b57cec5SDimitry Andric 29406c3fb27SDimitry Andric /// Get or create a DIE for an imported entity. 29506c3fb27SDimitry Andric DIE *getOrCreateImportedEntityDIE(const DIImportedEntity *IE); 29606c3fb27SDimitry Andric DIE *constructImportedEntityDIE(const DIImportedEntity *IE); 2970b57cec5SDimitry Andric 2980b57cec5SDimitry Andric void finishSubprogramDefinition(const DISubprogram *SP); 2990b57cec5SDimitry Andric void finishEntityDefinition(const DbgEntity *Entity); 3000b57cec5SDimitry Andric 3010b57cec5SDimitry Andric /// Find abstract variable associated with Var. 3020b57cec5SDimitry Andric using InlinedEntity = DbgValueHistoryMap::InlinedEntity; 3030b57cec5SDimitry Andric DbgEntity *getExistingAbstractEntity(const DINode *Node); 3040b57cec5SDimitry Andric void createAbstractEntity(const DINode *Node, LexicalScope *Scope); 3050b57cec5SDimitry Andric 3060b57cec5SDimitry Andric /// Set the skeleton unit associated with this unit. setSkeleton(DwarfCompileUnit & Skel)3070b57cec5SDimitry Andric void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; } 3080b57cec5SDimitry Andric getHeaderSize()3090b57cec5SDimitry Andric unsigned getHeaderSize() const override { 3100b57cec5SDimitry Andric // DWARF v5 added the DWO ID to the header for split/skeleton units. 3110b57cec5SDimitry Andric unsigned DWOIdSize = 3120b57cec5SDimitry Andric DD->getDwarfVersion() >= 5 && DD->useSplitDwarf() ? sizeof(uint64_t) 3130b57cec5SDimitry Andric : 0; 3140b57cec5SDimitry Andric return DwarfUnit::getHeaderSize() + DWOIdSize; 3150b57cec5SDimitry Andric } getLength()3160b57cec5SDimitry Andric unsigned getLength() { 317e8d8bef9SDimitry Andric return Asm->getUnitLengthFieldByteSize() + // Length field 3180b57cec5SDimitry Andric getHeaderSize() + getUnitDie().getSize(); 3190b57cec5SDimitry Andric } 3200b57cec5SDimitry Andric 3210b57cec5SDimitry Andric void emitHeader(bool UseOffsets) override; 3220b57cec5SDimitry Andric 3230b57cec5SDimitry Andric /// Add the DW_AT_addr_base attribute to the unit DIE. 3240b57cec5SDimitry Andric void addAddrTableBase(); 3250b57cec5SDimitry Andric getMacroLabelBegin()3260b57cec5SDimitry Andric MCSymbol *getMacroLabelBegin() const { 3270b57cec5SDimitry Andric return MacroLabelBegin; 3280b57cec5SDimitry Andric } 3290b57cec5SDimitry Andric 3300b57cec5SDimitry Andric /// Add a new global name to the compile unit. 3310b57cec5SDimitry Andric void addGlobalName(StringRef Name, const DIE &Die, 3320b57cec5SDimitry Andric const DIScope *Context) override; 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andric /// Add a new global name present in a type unit to this compile unit. 3350b57cec5SDimitry Andric void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context); 3360b57cec5SDimitry Andric 3370b57cec5SDimitry Andric /// Add a new global type to the compile unit. 3380b57cec5SDimitry Andric void addGlobalType(const DIType *Ty, const DIE &Die, 3390b57cec5SDimitry Andric const DIScope *Context) override; 3400b57cec5SDimitry Andric 3410b57cec5SDimitry Andric /// Add a new global type present in a type unit to this compile unit. 3420b57cec5SDimitry Andric void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context); 3430b57cec5SDimitry Andric getGlobalNames()3440b57cec5SDimitry Andric const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; } getGlobalTypes()3450b57cec5SDimitry Andric const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; } 3460b57cec5SDimitry Andric 3470b57cec5SDimitry Andric /// Add DW_AT_location attribute for a DbgVariable based on provided 3480b57cec5SDimitry Andric /// MachineLocation. 3490b57cec5SDimitry Andric void addVariableAddress(const DbgVariable &DV, DIE &Die, 3500b57cec5SDimitry Andric MachineLocation Location); 3510b57cec5SDimitry Andric /// Add an address attribute to a die based on the location provided. 3520b57cec5SDimitry Andric void addAddress(DIE &Die, dwarf::Attribute Attribute, 3530b57cec5SDimitry Andric const MachineLocation &Location); 3540b57cec5SDimitry Andric 3550b57cec5SDimitry Andric /// Start with the address based on the location provided, and generate the 3560b57cec5SDimitry Andric /// DWARF information necessary to find the actual variable (navigating the 3570b57cec5SDimitry Andric /// extra location information encoded in the type) based on the starting 3580b57cec5SDimitry Andric /// location. Add the DWARF information to the die. 3595f757f3fSDimitry Andric void addComplexAddress(const DIExpression *DIExpr, DIE &Die, 3600b57cec5SDimitry Andric dwarf::Attribute Attribute, 3610b57cec5SDimitry Andric const MachineLocation &Location); 3620b57cec5SDimitry Andric 3630b57cec5SDimitry Andric /// Add a Dwarf loclistptr attribute data and value. 3640b57cec5SDimitry Andric void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index); 3655f757f3fSDimitry Andric 3665f757f3fSDimitry Andric /// Add attributes to \p Var which reflect the common attributes of \p 3675f757f3fSDimitry Andric /// VariableDie, namely those which are not dependant on the active variant. 3685f757f3fSDimitry Andric void applyCommonDbgVariableAttributes(const DbgVariable &Var, 3695f757f3fSDimitry Andric DIE &VariableDie); 3700b57cec5SDimitry Andric 3710b57cec5SDimitry Andric /// Add a Dwarf expression attribute data and value. 3720b57cec5SDimitry Andric void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr); 3730b57cec5SDimitry Andric 3740b57cec5SDimitry Andric void applySubprogramAttributesToDefinition(const DISubprogram *SP, 3750b57cec5SDimitry Andric DIE &SPDie); 3760b57cec5SDimitry Andric 3770b57cec5SDimitry Andric void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie); 3780b57cec5SDimitry Andric 3790b57cec5SDimitry Andric /// getRanges - Get the list of ranges for this unit. getRanges()3800b57cec5SDimitry Andric const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; } takeRanges()3810b57cec5SDimitry Andric SmallVector<RangeSpan, 2> takeRanges() { return std::move(CURanges); } 3820b57cec5SDimitry Andric setBaseAddress(const MCSymbol * Base)3830b57cec5SDimitry Andric void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; } getBaseAddress()3840b57cec5SDimitry Andric const MCSymbol *getBaseAddress() const { return BaseAddress; } 3850b57cec5SDimitry Andric getDWOId()3860b57cec5SDimitry Andric uint64_t getDWOId() const { return DWOId; } setDWOId(uint64_t DwoId)3870b57cec5SDimitry Andric void setDWOId(uint64_t DwoId) { DWOId = DwoId; } 3880b57cec5SDimitry Andric 3890b57cec5SDimitry Andric bool hasDwarfPubSections() const; 3900b57cec5SDimitry Andric 3910b57cec5SDimitry Andric void addBaseTypeRef(DIEValueList &Die, int64_t Idx); 39206c3fb27SDimitry Andric getDeferredLocalDecls()39306c3fb27SDimitry Andric MDNodeSetVector &getDeferredLocalDecls() { return DeferredLocalDecls; } 3940b57cec5SDimitry Andric }; 3950b57cec5SDimitry Andric 3960b57cec5SDimitry Andric } // end namespace llvm 3970b57cec5SDimitry Andric 3980b57cec5SDimitry Andric #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H 399