Go to the documentation of this file.
13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
14 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
51 class DwarfCompileUnit;
52 class DwarfExpression;
56 class MachineFunction;
75 DIE *TheDIE =
nullptr;
80 : Entity(
N), InlinedAt(IA), SubclassID(
ID) {}
94 switch (
N->getDbgEntityID()) {
117 unsigned DebugLocListIndex = ~0u;
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");
147 FrameIndexExprs.push_back({FI,
E});
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())
159 FrameIndexExprs.push_back({0,
E});
167 return cast<DILocalVariable>(
getEntity());
171 assert(ValueLoc.get() && FrameIndexExprs.size() <= 1);
172 return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr :
nullptr;
190 return dwarf::DW_TAG_formal_parameter;
192 return dwarf::DW_TAG_variable;
213 assert(ValueLoc.get() &&
"Expected DBG_VALUE, not MMI variable");
214 assert((FrameIndexExprs.empty() ||
215 (FrameIndexExprs.size() == 1 &&
216 FrameIndexExprs[0].Expr->getNumElements())) &&
217 "Invalid Expr for DBG_VALUE");
218 return !FrameIndexExprs.empty();
250 return dwarf::DW_TAG_label;
267 assert(
Reg &&
"Parameter register cannot be undef");
305 std::vector<SymbolCU> ArangeLabels;
347 TypeUnitsUnderConstruction;
350 bool UseGNUTLSOpcode;
353 bool UseDWARF2Bitfields;
356 bool UseAllLinkageNames;
359 bool UseInlineStrings =
false;
362 bool UseRangesSection =
true;
366 bool UseSectionsAsReferences =
false;
369 bool UseLocSection =
true;
372 bool GenerateTypeUnits;
375 bool UseDebugMacroSection;
378 bool EnableOpConvert;
396 bool HasAppleExtensionAttributes;
403 bool UseSegmentedStringOffsetsTable;
408 bool EmitDebugEntryValues;
457 void ensureAbstractEntityIsCreated(DwarfCompileUnit &
CU,
459 const MDNode *
Scope);
460 void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &
CU,
462 const MDNode *
Scope);
464 DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
467 const DILocation *Location,
471 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *
Scope);
474 void constructCallSiteEntryDIEs(
const DISubprogram &SP, DwarfCompileUnit &
CU,
475 DIE &ScopeDIE,
const MachineFunction &MF);
477 template <
typename DataT>
478 void addAccelNameImpl(
const DICompileUnit &
CU, AccelTable<DataT> &AppleAccel,
479 StringRef
Name,
const DIE &Die);
481 void finishEntityDefinitions();
483 void finishSubprogramDefinitions();
487 void finalizeModuleInfo();
490 void emitDebugInfo();
493 void emitAbbreviations();
496 void emitStringOffsetsTableHeader();
499 template <
typename AccelTableT>
500 void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
503 void emitAccelDebugNames();
506 void emitAccelNames();
510 void emitAccelObjC();
513 void emitAccelNamespaces();
516 void emitAccelTypes();
519 void emitDebugPubSections();
521 void emitDebugPubSection(
bool GnuStyle, StringRef
Name,
522 DwarfCompileUnit *TheU,
523 const StringMap<const DIE *> &Globals);
532 void emitDebugLocDWO();
534 void emitDebugLocImpl(MCSection *Sec);
537 void emitDebugARanges();
540 void emitDebugRanges();
541 void emitDebugRangesDWO();
542 void emitDebugRangesImpl(
const DwarfFile &Holder, MCSection *Section);
545 void emitDebugMacinfo();
547 void emitDebugMacinfoDWO();
548 void emitDebugMacinfoImpl(MCSection *Section);
549 void emitMacro(DIMacro &M);
550 void emitMacroFile(DIMacroFile &
F, DwarfCompileUnit &U);
551 void emitMacroFileImpl(DIMacroFile &
F, DwarfCompileUnit &U,
552 unsigned StartFile,
unsigned EndFile,
553 StringRef (*MacroFormToString)(
unsigned Form));
554 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
559 void initSkeletonUnit(
const DwarfUnit &U, DIE &Die,
560 std::unique_ptr<DwarfCompileUnit> NewU);
569 DwarfCompileUnit &constructSkeletonCU(
const DwarfCompileUnit &
CU);
572 void emitDebugInfoDWO();
575 void emitDebugAbbrevDWO();
578 void emitDebugLineDWO();
581 void emitStringOffsetsTableHeaderDWO();
584 void emitDebugStrDWO();
587 void emitDebugAddr();
591 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &
D)
const;
595 DwarfCompileUnit &getOrCreateDwarfCompileUnit(
const DICompileUnit *DIUnit);
596 void finishUnitAttributes(
const DICompileUnit *DIUnit,
597 DwarfCompileUnit &NewCU);
600 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
601 const DIImportedEntity *
N);
606 void recordSourceLine(
unsigned Line,
unsigned Col,
const MDNode *
Scope,
610 void collectEntityInfo(DwarfCompileUnit &TheCU,
const DISubprogram *SP,
611 DenseSet<InlinedEntity> &ProcessedVars);
617 bool buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
621 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
622 DenseSet<InlinedEntity> &
P);
625 void emitSectionReference(
const DwarfCompileUnit &
CU);
666 DIE &Die,
const DICompositeType *CTy);
715 return UseSectionsAsReferences;
730 return HasAppleExtensionAttributes;
744 return UseSegmentedStringOffsetsTable;
748 return EmitDebugEntryValues;
752 return EnableOpConvert;
810 return CUDieMap.
lookup(Die);
820 StringTypeLocMap[
ST] = Loc;
847 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
Byte stream of .debug_loc entries.
DbgEntity(const DINode *N, const DILocation *IA, DbgEntityKind ID)
const DILocation * getInlinedAt() const
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
AddressPool & getAddressPool()
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit an entry for the debug loc section.
bool useGNUTLSOpcode() const
Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opc...
unsigned getStringTypeLoc(const DIStringType *ST) const
This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...
DebuggerKind
Identify a debugger for "tuning" the debug info.
@ Dwarf
DWARF v5 .debug_names.
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...
dwarf::Tag getTag() const
Translate tag to proper Dwarf tag.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
bool emitDebugEntryValues() const
void initializeDbgValue(DbgValueLoc Value)
String type, Fortran CHARACTER(n)
LexicalScope - This class is used to track scope information.
unsigned getDebugLocListIndex() const
void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die)
Reg
All possible values of the reg field in the ModR/M byte.
void terminateLineTable(const DwarfCompileUnit *CU)
Terminate the line table by adding the last range label.
void skippedNonDebugFunction() override
const DILabel * getLabel() const
Accessors.
StringRef getName() const
const SmallVectorImpl< std::unique_ptr< DwarfCompileUnit > > & getUnits()
void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die)
DbgCallSiteParam(unsigned Reg, DbgValueLoc Val)
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override
For symbols that have a size designated (e.g.
void endModule() override
Emit all Dwarf sections that should come after the content.
This class implements a map that also provides access to all stored values in a deterministic order.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
StringRef getName() const
A structured debug information entry.
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
StringRef getName() const
This class is used to track label information.
@ GDB
Tune debug info for gdb.
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit the location for a debug loc entry, including the size header.
DbgVariable(const DILocalVariable *V, const DILocation *IA)
Frame index + expression.
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.
bool isArtificial() const
Return true if DbgVariable is artificial.
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
void insertSectionLabel(const MCSymbol *S)
void addAccelNamespace(const DICompileUnit &CU, StringRef Name, const DIE &Die)
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null.
DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym=nullptr)
Symbol before DBG_LABEL instruction.
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
Optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP, DIE &Die)
virtual ~DbgEntity()=default
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
const MachineFunction * getCurrentFunction() const
bool alwaysUseRanges() const
Returns whether range encodings should be used for single entry range lists.
bool useAddrOffsetForm() const
bool isObjectPointer() const
std::pair< const DINode *, const DILocation * > InlinedEntity
This class is used to track local variable information.
dwarf::Tag getTag() const
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym)
void addStringTypeLoc(const DIStringType *ST, unsigned Loc)
bool hasFrameIndexExprs() const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Used for tracking debug info about call site parameters.
DwarfCompileUnit * lookupCU(const DIE *Die)
Find the matching DwarfCompileUnit for the given CU DIE.
@ DBX
Tune debug info for dbx.
bool useAddrOffsetExpressions() const
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
Class recording the (high level) value of a variable.
void beginModule(Module *M) override
Emit all Dwarf sections that should come prior to the content.
Representation of each machine instruction.
Collects and handles dwarf debug information.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
AccelTableKind getAccelTableKind() const
Returns what kind (if any) of accelerator tables to emit.
DwarfDebug(AsmPrinter *A)
Allocate memory in an ever growing pool, as if by bump-pointer.
void setDebugLocListIndex(unsigned O)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
DebugLoc emitInitialLocDirective(const MachineFunction &MF, unsigned CUID)
Emits inital debug location directive.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void endFunctionImpl(const MachineFunction *MF) override
Gather and emit post-function debug information.
unsigned getRegister() const
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
SmallVector< Entry, 4 > Entries
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
StringRef getName() const
const DbgValueLoc * getValueLoc() const
Basic type, like 'int' or 'float'.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
void initializeMMI(const DIExpression *E, int FI)
Initialize from the MMI table.
static bool classof(const DbgEntity *N)
StringRef - Represent a constant reference to a string, i.e.
@ Default
No specific tuning requested.
Tagged DWARF-like metadata node.
const DINode * getEntity() const
Accessors.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Machine Check Debug Module
bool generateTypeUnits() const
Returns whether to generate DWARF v4 type units.
void setDebugLocListTagOffset(uint8_t O)
bool shareAcrossDWOCUs() const
Wrapper class representing virtual and physical registers.
const MCSymbol * getSectionLabel(const MCSection *S)
const DwarfCompileUnit * lookupCU(const DIE *Die) const
static bool classof(const DbgEntity *N)
ArrayRef< FrameIndexExpr > getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
bool useLocSection() const
Returns whether .debug_loc section should be emitted.
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
bool useAppleExtensionAttributes() const
unsigned getDwarfCompileUnitIDForLineTable(const DwarfCompileUnit &CU)
Get Dwarf compile unit ID for line table.
const MCSymbol * getSymbol() const
bool useInlineStrings() const
Returns whether to use inline strings.
bool useSegmentedStringOffsetsTable() const
Returns whether to generate a string offsets table with (possibly shared) contributions from each CU ...
@ Default
Platform default.
This class is intended to be used as a driving class for all asm writers.
const DIExpression * getSingleExpression() const
The location of a single variable, composed of an expression and 0 or more DbgValueLocEntries.
bool useOpConvert() const
static uint64_t makeTypeSignature(StringRef Identifier)
Perform an MD5 checksum of Identifier and return the lower 64 bits.
DbgEntityKind getDbgEntityID() const
const DILocalVariable * getVariable() const
Align max(MaybeAlign Lhs, Align Rhs)
void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die, char Flags)
bool useDWARF2Bitfields() const
Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
Base class for debug information backends.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static bool classof(const DbgEntity *N)
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
void setPrevCU(const DwarfCompileUnit *PrevCU)
bool hasComplexAddress() const
bool useRangesSection() const
Returns whether ranges section should be emitted.
void addMMIEntry(const DbgVariable &V)
@ SCE
Tune debug info for SCE targets (e.g. PS4).
A vector that has set insertion semantics.
@ LLDB
Tune debug info for lldb.
Helper used to pair up a symbol and its DWARF compile unit.
LLVM Value Representation.
AccelTableKind
The kind of accelerator tables we should emit.
const DIType * getType() const
Optional< uint8_t > getDebugLocListTagOffset() const
DbgValueLoc getValue() const