#include "DwarfCompileUnit.h"
#include "AddressPool.h"
#include "DwarfExpression.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolWasm.h"
#include "llvm/MC/MachineLocation.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <iterator>
#include <optional>
#include <string>
#include <utility>
usingnamespacellvm;
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."));
static bool AddLinkageNamesToDeclCallOriginsForTuning(const DwarfDebug *DD) { … }
static dwarf::Tag GetCompileUnitType(UnitKind Kind, DwarfDebug *DW) { … }
DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const DICompileUnit *Node,
AsmPrinter *A, DwarfDebug *DW,
DwarfFile *DWU, UnitKind Kind)
: … { … }
void DwarfCompileUnit::addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
const MCSymbol *Label) { … }
void DwarfCompileUnit::addLocalLabelAddress(DIE &Die,
dwarf::Attribute Attribute,
const MCSymbol *Label) { … }
unsigned DwarfCompileUnit::getOrCreateSourceID(const DIFile *File) { … }
DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
const DIGlobalVariable *GV, ArrayRef<GlobalExpr> GlobalExprs) { … }
void DwarfCompileUnit::addLocationAttribute(
DIE *VariableDIE, const DIGlobalVariable *GV, ArrayRef<GlobalExpr> GlobalExprs) { … }
DIE *DwarfCompileUnit::getOrCreateCommonBlock(
const DICommonBlock *CB, ArrayRef<GlobalExpr> GlobalExprs) { … }
void DwarfCompileUnit::addRange(RangeSpan Range) { … }
void DwarfCompileUnit::initStmtList() { … }
void DwarfCompileUnit::applyStmtList(DIE &D) { … }
void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin,
const MCSymbol *End) { … }
void DwarfCompileUnit::addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName,
uint64_t GlobalIndex) { … }
DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) { … }
void DwarfCompileUnit::constructScopeDIE(LexicalScope *Scope,
DIE &ParentScopeDIE) { … }
void DwarfCompileUnit::addScopeRangeList(DIE &ScopeDIE,
SmallVector<RangeSpan, 2> Range) { … }
void DwarfCompileUnit::attachRangesOrLowHighPC(
DIE &Die, SmallVector<RangeSpan, 2> Ranges) { … }
void DwarfCompileUnit::attachRangesOrLowHighPC(
DIE &Die, const SmallVectorImpl<InsnRange> &Ranges) { … }
DIE *DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope,
DIE &ParentScopeDIE) { … }
DIE *DwarfCompileUnit::constructLexicalScopeDIE(LexicalScope *Scope) { … }
DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV, bool Abstract) { … }
void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
const Loc::Single &Single, const DbgVariable &DV, DIE &VariableDie) { … }
void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
const Loc::Multi &Multi, const DbgVariable &DV, DIE &VariableDie) { … }
void DwarfCompileUnit::applyConcreteDbgVariableAttributes(const Loc::MMI &MMI,
const DbgVariable &DV,
DIE &VariableDie) { … }
void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
const Loc::EntryValue &EntryValue, const DbgVariable &DV,
DIE &VariableDie) { … }
void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
const std::monostate &, const DbgVariable &DV, DIE &VariableDie) { … }
DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV,
const LexicalScope &Scope,
DIE *&ObjectPointer) { … }
DIE *DwarfCompileUnit::constructLabelDIE(DbgLabel &DL,
const LexicalScope &Scope) { … }
static SmallVector<const DIVariable *, 2> dependencies(DbgVariable *Var) { … }
static SmallVector<DbgVariable *, 8>
sortLocalVars(SmallVectorImpl<DbgVariable *> &Input) { … }
DIE &DwarfCompileUnit::constructSubprogramScopeDIE(const DISubprogram *Sub,
LexicalScope *Scope) { … }
DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,
DIE &ScopeDIE) { … }
void DwarfCompileUnit::constructAbstractSubprogramScopeDIE(
LexicalScope *Scope) { … }
bool DwarfCompileUnit::useGNUAnalogForDwarf5Feature() const { … }
dwarf::Tag DwarfCompileUnit::getDwarf5OrGNUTag(dwarf::Tag Tag) const { … }
dwarf::Attribute
DwarfCompileUnit::getDwarf5OrGNUAttr(dwarf::Attribute Attr) const { … }
dwarf::LocationAtom
DwarfCompileUnit::getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const { … }
DIE &DwarfCompileUnit::constructCallSiteEntryDIE(DIE &ScopeDIE,
const DISubprogram *CalleeSP,
bool IsTail,
const MCSymbol *PCAddr,
const MCSymbol *CallAddr,
unsigned CallReg) { … }
void DwarfCompileUnit::constructCallSiteParmEntryDIEs(
DIE &CallSiteDIE, SmallVector<DbgCallSiteParam, 4> &Params) { … }
DIE *DwarfCompileUnit::constructImportedEntityDIE(
const DIImportedEntity *Module) { … }
DIE *DwarfCompileUnit::getOrCreateImportedEntityDIE(
const DIImportedEntity *IE) { … }
void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) { … }
void DwarfCompileUnit::finishEntityDefinition(const DbgEntity *Entity) { … }
DbgEntity *DwarfCompileUnit::getExistingAbstractEntity(const DINode *Node) { … }
void DwarfCompileUnit::createAbstractEntity(const DINode *Node,
LexicalScope *Scope) { … }
void DwarfCompileUnit::emitHeader(bool UseOffsets) { … }
bool DwarfCompileUnit::hasDwarfPubSections() const { … }
void DwarfCompileUnit::addGlobalName(StringRef Name, const DIE &Die,
const DIScope *Context) { … }
void DwarfCompileUnit::addGlobalNameForTypeUnit(StringRef Name,
const DIScope *Context) { … }
void DwarfCompileUnit::addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
const DIScope *Context) { … }
void DwarfCompileUnit::addGlobalTypeUnitType(const DIType *Ty,
const DIScope *Context) { … }
void DwarfCompileUnit::addVariableAddress(const DbgVariable &DV, DIE &Die,
MachineLocation Location) { … }
void DwarfCompileUnit::addAddress(DIE &Die, dwarf::Attribute Attribute,
const MachineLocation &Location) { … }
void DwarfCompileUnit::addComplexAddress(const DIExpression *DIExpr, DIE &Die,
dwarf::Attribute Attribute,
const MachineLocation &Location) { … }
void DwarfCompileUnit::addLocationList(DIE &Die, dwarf::Attribute Attribute,
unsigned Index) { … }
void DwarfCompileUnit::applyCommonDbgVariableAttributes(const DbgVariable &Var,
DIE &VariableDie) { … }
void DwarfCompileUnit::applyLabelAttributes(const DbgLabel &Label,
DIE &LabelDie) { … }
void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
const MCExpr *Expr) { … }
void DwarfCompileUnit::applySubprogramAttributesToDefinition(
const DISubprogram *SP, DIE &SPDie) { … }
bool DwarfCompileUnit::isDwoUnit() const { … }
void DwarfCompileUnit::finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) { … }
bool DwarfCompileUnit::includeMinimalInlineScopes() const { … }
void DwarfCompileUnit::addAddrTableBase() { … }
void DwarfCompileUnit::addBaseTypeRef(DIEValueList &Die, int64_t Idx) { … }
void DwarfCompileUnit::createBaseTypeDIEs() { … }
DIE *DwarfCompileUnit::getLexicalBlockDIE(const DILexicalBlock *LB) { … }
DIE *DwarfCompileUnit::getOrCreateContextDIE(const DIScope *Context) { … }