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/DIE.h" 260b57cec5SDimitry Andric #include "llvm/CodeGen/LexicalScopes.h" 270b57cec5SDimitry Andric #include "llvm/IR/DebugInfoMetadata.h" 280b57cec5SDimitry Andric #include "llvm/Support/Casting.h" 290b57cec5SDimitry Andric #include <algorithm> 300b57cec5SDimitry Andric #include <cassert> 310b57cec5SDimitry Andric #include <cstdint> 320b57cec5SDimitry Andric #include <memory> 330b57cec5SDimitry Andric 340b57cec5SDimitry Andric namespace llvm { 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric class AsmPrinter; 370b57cec5SDimitry Andric class DwarfFile; 380b57cec5SDimitry Andric class GlobalVariable; 390b57cec5SDimitry Andric class MCExpr; 400b57cec5SDimitry Andric class MCSymbol; 410b57cec5SDimitry Andric class MDNode; 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric class DwarfCompileUnit final : public DwarfUnit { 440b57cec5SDimitry Andric /// A numeric ID unique among all CUs in the module 450b57cec5SDimitry Andric unsigned UniqueID; 460b57cec5SDimitry Andric bool HasRangeLists = false; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding 490b57cec5SDimitry Andric /// the need to search for it in applyStmtList. 500b57cec5SDimitry Andric DIE::value_iterator StmtListValue; 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric /// Skeleton unit associated with this unit. 530b57cec5SDimitry Andric DwarfCompileUnit *Skeleton = nullptr; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric /// The start of the unit within its section. 560b57cec5SDimitry Andric MCSymbol *LabelBegin; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric /// The start of the unit macro info within macro section. 590b57cec5SDimitry Andric MCSymbol *MacroLabelBegin; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric using ImportedEntityList = SmallVector<const MDNode *, 8>; 620b57cec5SDimitry Andric using ImportedEntityMap = DenseMap<const MDNode *, ImportedEntityList>; 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric ImportedEntityMap ImportedEntities; 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric /// GlobalNames - A map of globally visible named entities for this unit. 670b57cec5SDimitry Andric StringMap<const DIE *> GlobalNames; 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric /// GlobalTypes - A map of globally visible types for this unit. 700b57cec5SDimitry Andric StringMap<const DIE *> GlobalTypes; 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric // List of ranges for a given compile unit. 730b57cec5SDimitry Andric SmallVector<RangeSpan, 2> CURanges; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric // The base address of this unit, if any. Used for relative references in 760b57cec5SDimitry Andric // ranges/locs. 770b57cec5SDimitry Andric const MCSymbol *BaseAddress = nullptr; 780b57cec5SDimitry Andric 790b57cec5SDimitry Andric DenseMap<const MDNode *, DIE *> AbstractSPDies; 800b57cec5SDimitry Andric DenseMap<const DINode *, std::unique_ptr<DbgEntity>> AbstractEntities; 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric /// DWO ID for correlating skeleton and split units. 830b57cec5SDimitry Andric uint64_t DWOId = 0; 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric /// Construct a DIE for the given DbgVariable without initializing the 860b57cec5SDimitry Andric /// DbgVariable's DIE reference. 870b57cec5SDimitry Andric DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract); 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric bool isDwoUnit() const override; 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric DenseMap<const MDNode *, DIE *> &getAbstractSPDies() { 920b57cec5SDimitry Andric if (isDwoUnit() && !DD->shareAcrossDWOCUs()) 930b57cec5SDimitry Andric return AbstractSPDies; 940b57cec5SDimitry Andric return DU->getAbstractSPDies(); 950b57cec5SDimitry Andric } 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric DenseMap<const DINode *, std::unique_ptr<DbgEntity>> &getAbstractEntities() { 980b57cec5SDimitry Andric if (isDwoUnit() && !DD->shareAcrossDWOCUs()) 990b57cec5SDimitry Andric return AbstractEntities; 1000b57cec5SDimitry Andric return DU->getAbstractEntities(); 1010b57cec5SDimitry Andric } 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) override; 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric public: 1060b57cec5SDimitry Andric DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, 1070b57cec5SDimitry Andric DwarfDebug *DW, DwarfFile *DWU); 1080b57cec5SDimitry Andric 1090b57cec5SDimitry Andric bool hasRangeLists() const { return HasRangeLists; } 1100b57cec5SDimitry Andric unsigned getUniqueID() const { return UniqueID; } 1110b57cec5SDimitry Andric 1120b57cec5SDimitry Andric DwarfCompileUnit *getSkeleton() const { 1130b57cec5SDimitry Andric return Skeleton; 1140b57cec5SDimitry Andric } 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric bool includeMinimalInlineScopes() const; 1170b57cec5SDimitry Andric 1180b57cec5SDimitry Andric void initStmtList(); 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE. 1210b57cec5SDimitry Andric void applyStmtList(DIE &D); 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andric /// A pair of GlobalVariable and DIExpression. 1240b57cec5SDimitry Andric struct GlobalExpr { 1250b57cec5SDimitry Andric const GlobalVariable *Var; 1260b57cec5SDimitry Andric const DIExpression *Expr; 1270b57cec5SDimitry Andric }; 1280b57cec5SDimitry Andric 1290b57cec5SDimitry Andric struct BaseTypeRef { 1300b57cec5SDimitry Andric BaseTypeRef(unsigned BitSize, dwarf::TypeKind Encoding) : 1310b57cec5SDimitry Andric BitSize(BitSize), Encoding(Encoding) {} 1320b57cec5SDimitry Andric unsigned BitSize; 1330b57cec5SDimitry Andric dwarf::TypeKind Encoding; 1340b57cec5SDimitry Andric DIE *Die = nullptr; 1350b57cec5SDimitry Andric }; 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric std::vector<BaseTypeRef> ExprRefedBaseTypes; 1380b57cec5SDimitry Andric 1390b57cec5SDimitry Andric /// Get or create global variable DIE. 1400b57cec5SDimitry Andric DIE * 1410b57cec5SDimitry Andric getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, 1420b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andric DIE *getOrCreateCommonBlock(const DICommonBlock *CB, 1450b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1460b57cec5SDimitry Andric 1470b57cec5SDimitry Andric void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV, 1480b57cec5SDimitry Andric ArrayRef<GlobalExpr> GlobalExprs); 1490b57cec5SDimitry Andric 1500b57cec5SDimitry Andric /// addLabelAddress - Add a dwarf label attribute data and value using 1510b57cec5SDimitry Andric /// either DW_FORM_addr or DW_FORM_GNU_addr_index. 1520b57cec5SDimitry Andric void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, 1530b57cec5SDimitry Andric const MCSymbol *Label); 1540b57cec5SDimitry Andric 1550b57cec5SDimitry Andric /// addLocalLabelAddress - Add a dwarf label attribute data and value using 1560b57cec5SDimitry Andric /// DW_FORM_addr only. 1570b57cec5SDimitry Andric void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, 1580b57cec5SDimitry Andric const MCSymbol *Label); 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andric DwarfCompileUnit &getCU() override { return *this; } 1610b57cec5SDimitry Andric 1620b57cec5SDimitry Andric unsigned getOrCreateSourceID(const DIFile *File) override; 1630b57cec5SDimitry Andric 1640b57cec5SDimitry Andric void addImportedEntity(const DIImportedEntity* IE) { 1650b57cec5SDimitry Andric DIScope *Scope = IE->getScope(); 1660b57cec5SDimitry Andric assert(Scope && "Invalid Scope encoding!"); 1670b57cec5SDimitry Andric if (!isa<DILocalScope>(Scope)) 1680b57cec5SDimitry Andric // No need to add imported enities that are not local declaration. 1690b57cec5SDimitry Andric return; 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andric auto *LocalScope = cast<DILocalScope>(Scope)->getNonLexicalBlockFileScope(); 1720b57cec5SDimitry Andric ImportedEntities[LocalScope].push_back(IE); 1730b57cec5SDimitry Andric } 1740b57cec5SDimitry Andric 1750b57cec5SDimitry Andric /// addRange - Add an address range to the list of ranges for this unit. 1760b57cec5SDimitry Andric void addRange(RangeSpan Range); 1770b57cec5SDimitry Andric 1780b57cec5SDimitry Andric void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End); 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andric /// Find DIE for the given subprogram and attach appropriate 1810b57cec5SDimitry Andric /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global 1820b57cec5SDimitry Andric /// variables in this scope then create and insert DIEs for these 1830b57cec5SDimitry Andric /// variables. 1840b57cec5SDimitry Andric DIE &updateSubprogramScopeDIE(const DISubprogram *SP); 1850b57cec5SDimitry Andric 1860b57cec5SDimitry Andric void constructScopeDIE(LexicalScope *Scope, 1870b57cec5SDimitry Andric SmallVectorImpl<DIE *> &FinalChildren); 1880b57cec5SDimitry Andric 1890b57cec5SDimitry Andric /// A helper function to construct a RangeSpanList for a given 1900b57cec5SDimitry Andric /// lexical scope. 1910b57cec5SDimitry Andric void addScopeRangeList(DIE &ScopeDIE, SmallVector<RangeSpan, 2> Range); 1920b57cec5SDimitry Andric 1930b57cec5SDimitry Andric void attachRangesOrLowHighPC(DIE &D, SmallVector<RangeSpan, 2> Ranges); 1940b57cec5SDimitry Andric 1950b57cec5SDimitry Andric void attachRangesOrLowHighPC(DIE &D, 1960b57cec5SDimitry Andric const SmallVectorImpl<InsnRange> &Ranges); 1970b57cec5SDimitry Andric 1980b57cec5SDimitry Andric /// This scope represents inlined body of a function. Construct 1990b57cec5SDimitry Andric /// DIE to represent this concrete inlined copy of the function. 2000b57cec5SDimitry Andric DIE *constructInlinedScopeDIE(LexicalScope *Scope); 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andric /// Construct new DW_TAG_lexical_block for this scope and 2030b57cec5SDimitry Andric /// attach DW_AT_low_pc/DW_AT_high_pc labels. 2040b57cec5SDimitry Andric DIE *constructLexicalScopeDIE(LexicalScope *Scope); 2050b57cec5SDimitry Andric 2060b57cec5SDimitry Andric /// constructVariableDIE - Construct a DIE for the given DbgVariable. 2070b57cec5SDimitry Andric DIE *constructVariableDIE(DbgVariable &DV, bool Abstract = false); 2080b57cec5SDimitry Andric 2090b57cec5SDimitry Andric DIE *constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope, 2100b57cec5SDimitry Andric DIE *&ObjectPointer); 2110b57cec5SDimitry Andric 2120b57cec5SDimitry Andric /// Construct a DIE for the given DbgLabel. 2130b57cec5SDimitry Andric DIE *constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope); 2140b57cec5SDimitry Andric 2150b57cec5SDimitry Andric /// A helper function to create children of a Scope DIE. 2160b57cec5SDimitry Andric DIE *createScopeChildrenDIE(LexicalScope *Scope, 2170b57cec5SDimitry Andric SmallVectorImpl<DIE *> &Children, 2180b57cec5SDimitry Andric bool *HasNonScopeChildren = nullptr); 2190b57cec5SDimitry Andric 2200b57cec5SDimitry Andric void createBaseTypeDIEs(); 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andric /// Construct a DIE for this subprogram scope. 2230b57cec5SDimitry Andric DIE &constructSubprogramScopeDIE(const DISubprogram *Sub, 2240b57cec5SDimitry Andric LexicalScope *Scope); 2250b57cec5SDimitry Andric 2260b57cec5SDimitry Andric DIE *createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE); 2270b57cec5SDimitry Andric 2280b57cec5SDimitry Andric void constructAbstractSubprogramScopeDIE(LexicalScope *Scope); 2290b57cec5SDimitry Andric 230*8bcb0991SDimitry Andric /// This takes a DWARF 5 tag and returns it or a GNU analog. 231*8bcb0991SDimitry Andric dwarf::Tag getDwarf5OrGNUTag(dwarf::Tag Tag) const; 232*8bcb0991SDimitry Andric 233*8bcb0991SDimitry Andric /// This takes a DWARF 5 attribute and returns it or a GNU analog. 234*8bcb0991SDimitry Andric dwarf::Attribute getDwarf5OrGNUAttr(dwarf::Attribute Attr) const; 235*8bcb0991SDimitry Andric 236*8bcb0991SDimitry Andric /// This takes a DWARF 5 location atom and either returns it or a GNU analog. 237*8bcb0991SDimitry Andric dwarf::LocationAtom getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const; 238*8bcb0991SDimitry Andric 2390b57cec5SDimitry Andric /// Construct a call site entry DIE describing a call within \p Scope to a 240*8bcb0991SDimitry Andric /// callee described by \p CalleeSP. 241*8bcb0991SDimitry Andric /// \p IsTail specifies whether the call is a tail call. 242*8bcb0991SDimitry Andric /// \p PCAddr (used for GDB + DWARF 4 tuning) points to the PC value after 243*8bcb0991SDimitry Andric /// the call instruction. 244*8bcb0991SDimitry Andric /// \p PCOffset (used for cases other than GDB + DWARF 4 tuning) must be 245*8bcb0991SDimitry Andric /// non-zero for non-tail calls (in the case of non-gdb tuning, since for 246*8bcb0991SDimitry Andric /// GDB + DWARF 5 tuning we still generate PC info for tail calls) or be the 2470b57cec5SDimitry Andric /// function-local offset to PC value after the call instruction. 248*8bcb0991SDimitry Andric /// \p CallReg is a register location for an indirect call. For direct calls 249*8bcb0991SDimitry Andric /// the \p CallReg is set to 0. 250*8bcb0991SDimitry Andric DIE &constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP, 251*8bcb0991SDimitry Andric bool IsTail, const MCSymbol *PCAddr, 252*8bcb0991SDimitry Andric const MCExpr *PCOffset, unsigned CallReg); 253*8bcb0991SDimitry Andric /// Construct call site parameter DIEs for the \p CallSiteDIE. The \p Params 254*8bcb0991SDimitry Andric /// were collected by the \ref collectCallSiteParameters. 255*8bcb0991SDimitry Andric /// Note: The order of parameters does not matter, since debuggers recognize 256*8bcb0991SDimitry Andric /// call site parameters by the DW_AT_location attribute. 257*8bcb0991SDimitry Andric void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE, 258*8bcb0991SDimitry Andric SmallVector<DbgCallSiteParam, 4> &Params); 2590b57cec5SDimitry Andric 2600b57cec5SDimitry Andric /// Construct import_module DIE. 2610b57cec5SDimitry Andric DIE *constructImportedEntityDIE(const DIImportedEntity *Module); 2620b57cec5SDimitry Andric 2630b57cec5SDimitry Andric void finishSubprogramDefinition(const DISubprogram *SP); 2640b57cec5SDimitry Andric void finishEntityDefinition(const DbgEntity *Entity); 2650b57cec5SDimitry Andric 2660b57cec5SDimitry Andric /// Find abstract variable associated with Var. 2670b57cec5SDimitry Andric using InlinedEntity = DbgValueHistoryMap::InlinedEntity; 2680b57cec5SDimitry Andric DbgEntity *getExistingAbstractEntity(const DINode *Node); 2690b57cec5SDimitry Andric void createAbstractEntity(const DINode *Node, LexicalScope *Scope); 2700b57cec5SDimitry Andric 2710b57cec5SDimitry Andric /// Set the skeleton unit associated with this unit. 2720b57cec5SDimitry Andric void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; } 2730b57cec5SDimitry Andric 2740b57cec5SDimitry Andric unsigned getHeaderSize() const override { 2750b57cec5SDimitry Andric // DWARF v5 added the DWO ID to the header for split/skeleton units. 2760b57cec5SDimitry Andric unsigned DWOIdSize = 2770b57cec5SDimitry Andric DD->getDwarfVersion() >= 5 && DD->useSplitDwarf() ? sizeof(uint64_t) 2780b57cec5SDimitry Andric : 0; 2790b57cec5SDimitry Andric return DwarfUnit::getHeaderSize() + DWOIdSize; 2800b57cec5SDimitry Andric } 2810b57cec5SDimitry Andric unsigned getLength() { 2820b57cec5SDimitry Andric return sizeof(uint32_t) + // Length field 2830b57cec5SDimitry Andric getHeaderSize() + getUnitDie().getSize(); 2840b57cec5SDimitry Andric } 2850b57cec5SDimitry Andric 2860b57cec5SDimitry Andric void emitHeader(bool UseOffsets) override; 2870b57cec5SDimitry Andric 2880b57cec5SDimitry Andric /// Add the DW_AT_addr_base attribute to the unit DIE. 2890b57cec5SDimitry Andric void addAddrTableBase(); 2900b57cec5SDimitry Andric 2910b57cec5SDimitry Andric MCSymbol *getLabelBegin() const { 2920b57cec5SDimitry Andric assert(getSection()); 2930b57cec5SDimitry Andric return LabelBegin; 2940b57cec5SDimitry Andric } 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric MCSymbol *getMacroLabelBegin() const { 2970b57cec5SDimitry Andric return MacroLabelBegin; 2980b57cec5SDimitry Andric } 2990b57cec5SDimitry Andric 3000b57cec5SDimitry Andric /// Add a new global name to the compile unit. 3010b57cec5SDimitry Andric void addGlobalName(StringRef Name, const DIE &Die, 3020b57cec5SDimitry Andric const DIScope *Context) override; 3030b57cec5SDimitry Andric 3040b57cec5SDimitry Andric /// Add a new global name present in a type unit to this compile unit. 3050b57cec5SDimitry Andric void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context); 3060b57cec5SDimitry Andric 3070b57cec5SDimitry Andric /// Add a new global type to the compile unit. 3080b57cec5SDimitry Andric void addGlobalType(const DIType *Ty, const DIE &Die, 3090b57cec5SDimitry Andric const DIScope *Context) override; 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andric /// Add a new global type present in a type unit to this compile unit. 3120b57cec5SDimitry Andric void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context); 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andric const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; } 3150b57cec5SDimitry Andric const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; } 3160b57cec5SDimitry Andric 3170b57cec5SDimitry Andric /// Add DW_AT_location attribute for a DbgVariable based on provided 3180b57cec5SDimitry Andric /// MachineLocation. 3190b57cec5SDimitry Andric void addVariableAddress(const DbgVariable &DV, DIE &Die, 3200b57cec5SDimitry Andric MachineLocation Location); 3210b57cec5SDimitry Andric /// Add an address attribute to a die based on the location provided. 3220b57cec5SDimitry Andric void addAddress(DIE &Die, dwarf::Attribute Attribute, 3230b57cec5SDimitry Andric const MachineLocation &Location); 3240b57cec5SDimitry Andric 3250b57cec5SDimitry Andric /// Start with the address based on the location provided, and generate the 3260b57cec5SDimitry Andric /// DWARF information necessary to find the actual variable (navigating the 3270b57cec5SDimitry Andric /// extra location information encoded in the type) based on the starting 3280b57cec5SDimitry Andric /// location. Add the DWARF information to the die. 3290b57cec5SDimitry Andric void addComplexAddress(const DbgVariable &DV, DIE &Die, 3300b57cec5SDimitry Andric dwarf::Attribute Attribute, 3310b57cec5SDimitry Andric const MachineLocation &Location); 3320b57cec5SDimitry Andric 3330b57cec5SDimitry Andric /// Add a Dwarf loclistptr attribute data and value. 3340b57cec5SDimitry Andric void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index); 3350b57cec5SDimitry Andric void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie); 3360b57cec5SDimitry Andric 3370b57cec5SDimitry Andric /// Add a Dwarf expression attribute data and value. 3380b57cec5SDimitry Andric void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr); 3390b57cec5SDimitry Andric 3400b57cec5SDimitry Andric /// Add an attribute containing an address expression to \p Die. 3410b57cec5SDimitry Andric void addAddressExpr(DIE &Die, dwarf::Attribute Attribute, const MCExpr *Expr); 3420b57cec5SDimitry Andric 3430b57cec5SDimitry Andric void applySubprogramAttributesToDefinition(const DISubprogram *SP, 3440b57cec5SDimitry Andric DIE &SPDie); 3450b57cec5SDimitry Andric 3460b57cec5SDimitry Andric void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie); 3470b57cec5SDimitry Andric 3480b57cec5SDimitry Andric /// getRanges - Get the list of ranges for this unit. 3490b57cec5SDimitry Andric const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; } 3500b57cec5SDimitry Andric SmallVector<RangeSpan, 2> takeRanges() { return std::move(CURanges); } 3510b57cec5SDimitry Andric 3520b57cec5SDimitry Andric void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; } 3530b57cec5SDimitry Andric const MCSymbol *getBaseAddress() const { return BaseAddress; } 3540b57cec5SDimitry Andric 3550b57cec5SDimitry Andric uint64_t getDWOId() const { return DWOId; } 3560b57cec5SDimitry Andric void setDWOId(uint64_t DwoId) { DWOId = DwoId; } 3570b57cec5SDimitry Andric 3580b57cec5SDimitry Andric bool hasDwarfPubSections() const; 3590b57cec5SDimitry Andric 3600b57cec5SDimitry Andric void addBaseTypeRef(DIEValueList &Die, int64_t Idx); 3610b57cec5SDimitry Andric }; 3620b57cec5SDimitry Andric 3630b57cec5SDimitry Andric } // end namespace llvm 3640b57cec5SDimitry Andric 3650b57cec5SDimitry Andric #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H 366