14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
45 class DwarfCompileUnit;
49 class MachineModuleInfo;
60 : Line(L), Column(C), SourceID(S), Label(label) {}
85 DIE *TheDIE =
nullptr;
86 unsigned DebugLocListIndex = ~0u;
97 : Var(V), IA(IA), DD(DD) {}
101 assert(Expr.empty() &&
"Already initialized?");
102 assert(FrameIndex.
empty() &&
"Already initialized?");
103 assert(!MInsn &&
"Already initialized?");
105 assert((!E || E->
isValid()) &&
"Expected valid expression");
106 assert(~FI &&
"Expected valid index");
114 assert(Expr.empty() &&
"Already initialized?");
115 assert(FrameIndex.
empty() &&
"Already initialized?");
116 assert(!MInsn &&
"Already initialized?");
119 assert(IA == DbgValue->
getDebugLoc()->getInlinedAt() &&
"Wrong inlined-at");
123 if (E->getNumElements())
140 assert(DebugLocListIndex == ~0U && !MInsn &&
"not an MMI entry");
141 assert(V.DebugLocListIndex == ~0U && !V.MInsn &&
"not an MMI entry");
142 assert(V.Var == Var &&
"conflicting variable");
143 assert(V.IA == IA &&
"conflicting inlined-at location");
145 assert(!FrameIndex.
empty() &&
"Expected an MMI entry");
146 assert(!V.FrameIndex.
empty() &&
"Expected an MMI entry");
147 assert(Expr.size() == FrameIndex.
size() &&
"Mismatched expressions");
148 assert(V.Expr.size() == V.FrameIndex.
size() &&
"Mismatched expressions");
150 Expr.append(V.Expr.begin(), V.Expr.end());
153 return E && E->isBitPiece();
154 }) &&
"conflicting locations for variable");
159 if (Var->
getTag() == dwarf::DW_TAG_arg_variable)
160 return dwarf::DW_TAG_formal_parameter;
162 return dwarf::DW_TAG_variable;
182 assert(MInsn &&
"Expected DBG_VALUE, not MMI variable");
183 assert(FrameIndex.
empty() &&
"Expected DBG_VALUE, not MMI variable");
185 (Expr.empty() || (Expr.size() == 1 && Expr.back()->getNumElements())) &&
186 "Invalid Expr for DBG_VALUE");
187 return !Expr.empty();
227 std::vector<SymbolCU> ArangeLabels;
296 TypeUnitsUnderConstruction;
299 bool HasDwarfPubSections;
306 bool UsedNonDefaultText;
309 bool UseGNUTLSOpcode;
312 unsigned DwarfVersion;
319 bool HasDwarfAccelTables;
361 DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
363 DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
365 void ensureAbstractVariableIsCreated(InlinedVariable Var,
367 void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
373 void constructAbstractSubprogramScopeDIE(
LexicalScope *Scope);
376 unsigned computeSizeAndOffset(
DIE *Die,
unsigned Offset);
379 void computeSizeAndOffsets();
382 void collectDeadVariables();
384 void finishVariableDefinitions();
386 void finishSubprogramDefinitions();
390 void finalizeModuleInfo();
393 void emitDebugInfo();
396 void emitAbbreviations();
403 void emitAccelNames();
407 void emitAccelObjC();
410 void emitAccelNamespaces();
413 void emitAccelTypes();
419 void emitDebugPubNames(
bool GnuStyle =
false);
425 void emitDebugPubTypes(
bool GnuStyle =
false);
427 void emitDebugPubSection(
438 void emitDebugLocDWO();
441 void emitDebugARanges();
444 void emitDebugRanges();
447 void emitDebugInlineInfo();
453 std::unique_ptr<DwarfUnit> NewU);
464 void emitDebugInfoDWO();
467 void emitDebugAbbrevDWO();
470 void emitDebugLineDWO();
473 void emitDebugStrDWO();
490 void recordSourceLine(
unsigned Line,
unsigned Col,
const MDNode *Scope,
495 void identifyScopeMarkers();
512 LabelsBeforeInsn.insert(std::make_pair(MI,
nullptr));
517 LabelsAfterInsn.insert(std::make_pair(MI,
nullptr));
595 return Ref.
resolve(TypeIdentifierMap);
600 return TypeIdentifierMap;
605 return CUDieMap.lookup(CU);
628 ScopesWithImportedEntities.
begin(), ScopesWithImportedEntities.
end(),
629 std::pair<const MDNode *, const MDNode *>(Scope,
nullptr),
646 return ProcessedSPNodes;
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry)
Emit the location for a debug loc entry, including the size header.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void push_back(const T &Elt)
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override
For symbols that have a size designated (e.g.
const MachineInstr * getMInsn() const
bool isArtificial() const
unsigned getDebugLocListIndex() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
const MachineFunction * getCurrentFunction() const
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
DenseSet - This implements a dense probed hash-table based set.
SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
Collects and handles AsmPrinter objects required to build debug or EH information.
Collects and handles dwarf debug information.
bool useDwarfAccelTables() const
Returns whether or not to emit tables that dwarf consumers can use to accelerate lookup.
This class implements a map that also provides access to all stored values in a deterministic order...
StringRef getName() const
bool hasComplexAddress() const
LexicalScope - This class is used to track scope information.
bool useGNUTLSOpcode() const
Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opc...
const DILocation * getInlinedAt() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
void addAccelNamespace(StringRef Name, const DIE &Die)
void initializeDbgValue(const MachineInstr *DbgValue)
Initialize from a DBG_VALUE instruction.
bool isObjectPointer() const
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
bool isArtificial() const
Return true if DbgVariable is artificial.
This class is used to record source line correspondence.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
const ArrayRef< int > getFrameIndex() const
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null. ...
Pointer union between a subclass of DINode and MDString.
StringRef getName() const
T * resolve(const MapTy &Map) const
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
AddressPool & getAddressPool()
iterator_range< ImportedEntityMap::const_iterator > findImportedEntitiesForScope(const MDNode *Scope) const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
This class is used to track local variable information.
const ArrayRef< const DIExpression * > getExpression() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getSourceID() const
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support...
This dwarf writer support class manages information associated with a source file.
void endModule() override
Emit all Dwarf sections that should come after the content.
const DIType * getType() const
Allocate memory in an ever growing pool, as if by bump-pointer.
void addMMIEntry(const DbgVariable &V)
MCSymbol * getLabel() const
DIE - A structured debug information entry.
This class is intended to be used as a driving class for all asm writers.
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.
T * resolve(TypedDINodeRef< T > Ref) const
Find the MDNode for the given reference.
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
void addAccelType(StringRef Name, const DIE &Die, char Flags)
DwarfDebug(AsmPrinter *A, Module *M)
void endFunction(const MachineFunction *MF) override
Gather and emit post-function debug information.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Helper used to pair up a symbol and its DWARF compile unit.
bool isObjectPointer() const
void initializeMMI(const DIExpression *E, int FI)
Initialize from the MMI table.
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym)
DbgVariable(const DILocalVariable *V, const DILocation *IA, DwarfDebug *DD)
Construct a DbgVariable.
An imported module (C++ using directive or similar).
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
void setPrevCU(const DwarfCompileUnit *PrevCU)
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
void beginFunction(const MachineFunction *MF) override
Gather pre-function debug information.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getColumn() const
void beginModule()
Emit all Dwarf sections that should come prior to the content.
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
bool isSubprogramContext(const MDNode *Context)
isSubprogramContext - Return true if Context is either a subprogram or another context nested inside ...
DwarfCompileUnit * lookupUnit(const DIE *CU) const
Find the DwarfCompileUnit for the given CU Die.
void addAccelName(StringRef Name, const DIE &Die)
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry)
Emit an entry for the debug loc section.
A range adaptor for a pair of iterators.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
const DILocalVariable * getVariable() const
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool isArtificial() const
void endInstruction() override
Process end of an instruction.
SmallPtrSet< const MDNode *, 16 > & getProcessedSPNodes()
Representation of each machine instruction.
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
const SmallVectorImpl< std::unique_ptr< DwarfUnit > > & getUnits()
dwarf::Tag getTag() const
bool all_of(R &&Range, UnaryPredicate &&P)
Provide wrappers to std::all_of which take ranges instead of having to pass being/end explicitly...
const DITypeIdentifierMap & getTypeIdentifierMap() const
Return the TypeIdentifierMap.
void addSubprogramNames(const DISubprogram *SP, DIE &Die)
void setDebugLocListIndex(unsigned O)
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
bool isBlockByrefVariable() const
bool isObjectPointer() const
std::pair< const DILocalVariable *, const DILocation * > InlinedVariable
void addAccelObjC(StringRef Name, const DIE &Die)
StringRef - Represent a constant reference to a string, i.e.
Byte stream of .debug_loc entries.
unsigned getDwarfVersion() const
Returns the Dwarf Version.
Function object to check whether the first component of a std::pair compares less than the first comp...
MachineModuleInfo - This class contains meta information specific to a module.