DwarfCompileUnit.h [plain text]
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
#include "DwarfUnit.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/Support/Dwarf.h"
namespace llvm {
class AsmPrinter;
class DIE;
class DwarfDebug;
class DwarfFile;
class MCSymbol;
class LexicalScope;
class DwarfCompileUnit : public DwarfUnit {
DIE::value_iterator StmtListValue;
DwarfCompileUnit *Skeleton;
MCSymbol *LabelBegin;
typedef llvm::SmallVector<const MDNode *, 8> ImportedEntityList;
typedef llvm::DenseMap<const MDNode *, ImportedEntityList>
ImportedEntityMap;
ImportedEntityMap ImportedEntities;
StringMap<const DIE *> GlobalNames;
StringMap<const DIE *> GlobalTypes;
SmallVector<RangeSpanList, 1> CURangeLists;
SmallVector<RangeSpan, 2> CURanges;
const MCSymbol *BaseAddress;
DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract);
bool isDwoUnit() const override;
bool includeMinimalInlineScopes() const;
public:
DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU);
DwarfCompileUnit *getSkeleton() const {
return Skeleton;
}
void initStmtList();
void applyStmtList(DIE &D);
DIE *getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV);
void addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
const MCSymbol *Label);
void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute,
const MCSymbol *Label);
DIE::value_iterator addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
const MCSymbol *Hi, const MCSymbol *Lo);
DwarfCompileUnit &getCU() override { return *this; }
unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
void addImportedEntity(const DIImportedEntity* IE) {
ImportedEntities[IE->getScope()].push_back(IE);
}
void addRange(RangeSpan Range);
void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End);
DIE::value_iterator addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
const MCSymbol *Label,
const MCSymbol *Sec);
DIE &updateSubprogramScopeDIE(const DISubprogram *SP);
void constructScopeDIE(LexicalScope *Scope,
SmallVectorImpl<DIE *> &FinalChildren);
void addScopeRangeList(DIE &ScopeDIE, SmallVector<RangeSpan, 2> Range);
void attachRangesOrLowHighPC(DIE &D, SmallVector<RangeSpan, 2> Ranges);
void attachRangesOrLowHighPC(DIE &D,
const SmallVectorImpl<InsnRange> &Ranges);
DIE *constructInlinedScopeDIE(LexicalScope *Scope);
DIE *constructLexicalScopeDIE(LexicalScope *Scope);
DIE *constructVariableDIE(DbgVariable &DV, bool Abstract = false);
DIE *constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope,
DIE *&ObjectPointer);
DIE *createScopeChildrenDIE(LexicalScope *Scope,
SmallVectorImpl<DIE *> &Children,
unsigned *ChildScopeCount = nullptr);
void constructSubprogramScopeDIE(LexicalScope *Scope);
DIE *createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE);
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
DIE *constructImportedEntityDIE(const DIImportedEntity *Module);
void finishSubprogramDefinition(const DISubprogram *SP);
void collectDeadVariables(const DISubprogram *SP);
void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
const MCSymbol *getSectionSym() const {
assert(Section);
return Section->getBeginSymbol();
}
unsigned getLength() {
return sizeof(uint32_t) + getHeaderSize() + UnitDie.getSize();
}
void emitHeader(bool UseOffsets) override;
MCSymbol *getLabelBegin() const {
assert(Section);
return LabelBegin;
}
void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) override;
void addGlobalType(const DIType *Ty, const DIE &Die,
const DIScope *Context) override;
const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
void addVariableAddress(const DbgVariable &DV, DIE &Die,
MachineLocation Location);
void addAddress(DIE &Die, dwarf::Attribute Attribute,
const MachineLocation &Location);
void addComplexAddress(const DbgVariable &DV, DIE &Die,
dwarf::Attribute Attribute,
const MachineLocation &Location);
void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index);
void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie);
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
void applySubprogramAttributesToDefinition(const DISubprogram *SP,
DIE &SPDie);
const SmallVectorImpl<RangeSpanList> &getRangeLists() const {
return (Skeleton ? Skeleton : this)->CURangeLists;
}
const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; }
SmallVector<RangeSpan, 2> takeRanges() { return std::move(CURanges); }
void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; }
const MCSymbol *getBaseAddress() const { return BaseAddress; }
};
}
#endif