13#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
14#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
51class DwarfCompileUnit;
75 DIE *TheDIE =
nullptr;
80 : Entity(
N), InlinedAt(IA), SubclassID(
ID) {}
94 switch (
N->getDbgEntityID()) {
117 unsigned DebugLocListIndex = ~0u;
119 std::optional<uint8_t> DebugLocListTagOffset;
122 std::unique_ptr<DbgValueLoc> ValueLoc =
nullptr;
124 struct FrameIndexExpr {
141 assert(FrameIndexExprs.
empty() &&
"Already initialized?");
142 assert(!ValueLoc.get() &&
"Already initialized?");
144 assert((!
E ||
E->isValid()) &&
"Expected valid expression");
145 assert(FI != std::numeric_limits<int>::max() &&
"Expected valid index");
152 assert(FrameIndexExprs.
empty() &&
"Already initialized?");
153 assert(!ValueLoc &&
"Already initialized?");
154 assert(!
Value.getExpression()->isFragment() &&
"Fragments not supported.");
156 ValueLoc = std::make_unique<DbgValueLoc>(
Value);
157 if (
auto *
E = ValueLoc->getExpression())
158 if (
E->getNumElements())
167 return cast<DILocalVariable>(
getEntity());
171 assert(ValueLoc.get() && FrameIndexExprs.
size() <= 1);
172 return FrameIndexExprs.
size() ? FrameIndexExprs[0].Expr :
nullptr;
179 return DebugLocListTagOffset;
192 return dwarf::DW_TAG_formal_parameter;
194 return dwarf::DW_TAG_variable;
215 assert(ValueLoc.get() &&
"Expected DBG_VALUE, not MMI variable");
217 (FrameIndexExprs.
size() == 1 &&
218 FrameIndexExprs[0].Expr->getNumElements())) &&
219 "Invalid Expr for DBG_VALUE");
220 return !FrameIndexExprs.
empty();
252 return dwarf::DW_TAG_label;
269 assert(
Reg &&
"Parameter register cannot be undef");
307 std::vector<SymbolCU> ArangeLabels;
349 TypeUnitsUnderConstruction;
352 bool UseGNUTLSOpcode;
355 bool UseDWARF2Bitfields;
358 bool UseAllLinkageNames;
361 bool UseInlineStrings =
false;
364 bool UseRangesSection =
true;
368 bool UseSectionsAsReferences =
false;
371 bool UseLocSection =
true;
374 bool GenerateTypeUnits;
377 bool UseDebugMacroSection;
380 bool EnableOpConvert;
398 bool HasAppleExtensionAttributes;
405 bool UseSegmentedStringOffsetsTable;
410 bool EmitDebugEntryValues;
459 void ensureAbstractEntityIsCreated(DwarfCompileUnit &
CU,
461 const MDNode *Scope);
462 void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &
CU,
464 const MDNode *Scope);
466 DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
469 const DILocation *Location,
470 const MCSymbol *Sym =
nullptr);
473 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
476 void constructCallSiteEntryDIEs(
const DISubprogram &SP, DwarfCompileUnit &
CU,
477 DIE &ScopeDIE,
const MachineFunction &MF);
479 template <
typename DataT>
480 void addAccelNameImpl(
const DICompileUnit &
CU, AccelTable<DataT> &AppleAccel,
481 StringRef
Name,
const DIE &Die);
483 void finishEntityDefinitions();
485 void finishSubprogramDefinitions();
489 void finalizeModuleInfo();
492 void emitDebugInfo();
495 void emitAbbreviations();
498 void emitStringOffsetsTableHeader();
501 template <
typename AccelTableT>
502 void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
505 void emitAccelDebugNames();
508 void emitAccelNames();
512 void emitAccelObjC();
515 void emitAccelNamespaces();
518 void emitAccelTypes();
521 void emitDebugPubSections();
523 void emitDebugPubSection(
bool GnuStyle, StringRef
Name,
524 DwarfCompileUnit *TheU,
525 const StringMap<const DIE *> &Globals);
534 void emitDebugLocDWO();
536 void emitDebugLocImpl(MCSection *Sec);
539 void emitDebugARanges();
542 void emitDebugRanges();
543 void emitDebugRangesDWO();
544 void emitDebugRangesImpl(
const DwarfFile &Holder, MCSection *Section);
547 void emitDebugMacinfo();
549 void emitDebugMacinfoDWO();
550 void emitDebugMacinfoImpl(MCSection *Section);
551 void emitMacro(DIMacro &M);
552 void emitMacroFile(DIMacroFile &
F, DwarfCompileUnit &U);
553 void emitMacroFileImpl(DIMacroFile &
F, DwarfCompileUnit &U,
554 unsigned StartFile,
unsigned EndFile,
555 StringRef (*MacroFormToString)(
unsigned Form));
556 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
561 void initSkeletonUnit(
const DwarfUnit &U, DIE &Die,
562 std::unique_ptr<DwarfCompileUnit> NewU);
571 DwarfCompileUnit &constructSkeletonCU(
const DwarfCompileUnit &
CU);
574 void emitDebugInfoDWO();
577 void emitDebugAbbrevDWO();
580 void emitDebugLineDWO();
583 void emitStringOffsetsTableHeaderDWO();
586 void emitDebugStrDWO();
589 void emitDebugAddr();
593 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &
D)
const;
597 DwarfCompileUnit &getOrCreateDwarfCompileUnit(
const DICompileUnit *DIUnit);
598 void finishUnitAttributes(
const DICompileUnit *DIUnit,
599 DwarfCompileUnit &NewCU);
602 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
603 const DIImportedEntity *
N);
608 void recordSourceLine(
unsigned Line,
unsigned Col,
const MDNode *Scope,
612 void collectEntityInfo(DwarfCompileUnit &TheCU,
const DISubprogram *SP,
613 DenseSet<InlinedEntity> &ProcessedVars);
619 bool buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
623 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
624 DenseSet<InlinedEntity> &
P);
627 void emitSectionReference(
const DwarfCompileUnit &
CU);
645 DwarfDebug(AsmPrinter *
A);
717 return UseSectionsAsReferences;
732 return HasAppleExtensionAttributes;
746 return UseSegmentedStringOffsetsTable;
750 return EmitDebugEntryValues;
754 return EnableOpConvert;
812 return CUDieMap.
lookup(Die);
816 return StringTypeLocMap.
lookup(ST);
822 StringTypeLocMap[ST] = Loc;
This file defines the StringMap class.
This file contains support for writing accelerator tables.
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file contains constants used for implementing Dwarf debug support.
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Class recording the (high level) value of a variable.
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class is intended to be used as a driving class for all asm writers.
Allocate memory in an ever growing pool, as if by bump-pointer.
Basic type, like 'int' or 'float'.
A structured debug information entry.
StringRef getName() const
Tagged DWARF-like metadata node.
String type, Fortran CHARACTER(n)
StringRef getName() const
Used for tracking debug info about call site parameters.
unsigned getRegister() const
DbgCallSiteParam(unsigned Reg, DbgValueLoc Val)
DbgValueLoc getValue() const
This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...
virtual ~DbgEntity()=default
static bool classof(const DbgEntity *N)
const DINode * getEntity() const
Accessors.
DbgEntityKind getDbgEntityID() const
DbgEntity(const DINode *N, const DILocation *IA, DbgEntityKind ID)
const DILocation * getInlinedAt() const
This class is used to track label information.
dwarf::Tag getTag() const
Translate tag to proper Dwarf tag.
static bool classof(const DbgEntity *N)
DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym=nullptr)
Symbol before DBG_LABEL instruction.
StringRef getName() const
const MCSymbol * getSymbol() const
const DILabel * getLabel() const
Accessors.
SmallVector< Entry, 4 > Entries
std::pair< const DINode *, const DILocation * > InlinedEntity
The location of a single variable, composed of an expression and 0 or more DbgValueLocEntries.
This class is used to track local variable information.
bool hasComplexAddress() const
bool isArtificial() const
Return true if DbgVariable is artificial.
dwarf::Tag getTag() const
void initializeMMI(const DIExpression *E, int FI)
Initialize from the MMI table.
bool isObjectPointer() const
const DILocalVariable * getVariable() const
void setDebugLocListIndex(unsigned O)
std::optional< uint8_t > getDebugLocListTagOffset() const
DbgVariable(const DILocalVariable *V, const DILocation *IA)
Frame index + expression.
void initializeDbgValue(DbgValueLoc Value)
unsigned getDebugLocListIndex() const
StringRef getName() const
const DIType * getType() const
static bool classof(const DbgEntity *N)
bool hasFrameIndexExprs() const
const DbgValueLoc * getValueLoc() const
const DIExpression * getSingleExpression() const
void addMMIEntry(const DbgVariable &V)
ArrayRef< FrameIndexExpr > getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
void setDebugLocListTagOffset(uint8_t O)
Base class for debug information backends.
Byte stream of .debug_loc entries.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Collects and handles dwarf debug information.
bool useSegmentedStringOffsetsTable() const
Returns whether to generate a string offsets table with (possibly shared) contributions from each CU ...
std::optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
bool alwaysUseRanges() const
Returns whether range encodings should be used for single entry range lists.
bool useGNUTLSOpcode() const
Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opc...
bool useAddrOffsetForm() const
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override
For symbols that have a size designated (e.g.
bool emitDebugEntryValues() const
const DwarfCompileUnit * lookupCU(const DIE *Die) const
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit an entry for the debug loc section.
void beginModule(Module *M) override
Emit all Dwarf sections that should come prior to the content.
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
void insertSectionLabel(const MCSymbol *S)
void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP, DIE &Die)
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
bool useAppleExtensionAttributes() const
void setPrevCU(const DwarfCompileUnit *PrevCU)
const MachineFunction * getCurrentFunction() const
void skippedNonDebugFunction() override
bool useInlineStrings() const
Returns whether to use inline strings.
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
bool generateTypeUnits() const
Returns whether to generate DWARF v4 type units.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
AddressPool & getAddressPool()
void addAccelNamespace(const DICompileUnit &CU, StringRef Name, const DIE &Die)
void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die, char Flags)
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
bool shareAcrossDWOCUs() const
bool useOpConvert() const
void terminateLineTable(const DwarfCompileUnit *CU)
Terminate the line table by adding the last range label.
void endFunctionImpl(const MachineFunction *MF) override
Gather and emit post-function debug information.
void addStringTypeLoc(const DIStringType *ST, unsigned Loc)
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit the location for a debug loc entry, including the size header.
void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die)
DwarfCompileUnit * lookupCU(const DIE *Die)
Find the matching DwarfCompileUnit for the given CU DIE.
const MCSymbol * getSectionLabel(const MCSection *S)
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
bool useLocSection() const
Returns whether .debug_loc section should be emitted.
unsigned getDwarfCompileUnitIDForLineTable(const DwarfCompileUnit &CU)
Get Dwarf compile unit ID for line table.
bool useDWARF2Bitfields() const
Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
DebugLoc emitInitialLocDirective(const MachineFunction &MF, unsigned CUID)
Emits inital debug location directive.
bool useAddrOffsetExpressions() const
bool useRangesSection() const
Returns whether ranges section should be emitted.
unsigned getStringTypeLoc(const DIStringType *ST) const
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null.
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, const DICompositeType *CTy)
Add a DIE to the set of types that we're going to pull into type units.
void endModule() override
Emit all Dwarf sections that should come after the content.
void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die)
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
AccelTableKind getAccelTableKind() const
Returns what kind (if any) of accelerator tables to emit.
static uint64_t makeTypeSignature(StringRef Identifier)
Perform an MD5 checksum of Identifier and return the lower 64 bits.
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
const SmallVectorImpl< std::unique_ptr< DwarfCompileUnit > > & getUnits()
LexicalScope - This class is used to track scope information.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Representation of each machine instruction.
This class implements a map that also provides access to all stored values in a deterministic order.
A Module instance is used to store all the information related to an LLVM module.
Wrapper class representing virtual and physical registers.
A vector that has set insertion semantics.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
AccelTableKind
The kind of accelerator tables we should emit.
@ Dwarf
DWARF v5 .debug_names.
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
DebuggerKind
Identify a debugger for "tuning" the debug info.
@ SCE
Tune debug info for SCE targets (e.g. PS4).
@ DBX
Tune debug info for dbx.
@ Default
No specific tuning requested.
@ GDB
Tune debug info for gdb.
@ LLDB
Tune debug info for lldb.
@ Default
The result values are uniform if and only if all operands are uniform.
constexpr std::nullopt_t None
Helper used to pair up a symbol and its DWARF compile unit.
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym)