13#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H 
   14#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H 
   75  DIE *TheDIE = 
nullptr;
 
   80      : Entity(
N), InlinedAt(IA), SubclassID(
ID) {}
 
 
   94    switch (
N->getDbgEntityID()) {
 
 
 
  132  std::unique_ptr<DbgValueLoc> ValueLoc;
 
 
  144  unsigned DebugLocListIndex;
 
  146  std::optional<uint8_t> DebugLocListTagOffset;
 
  149  explicit Multi(
unsigned DebugLocListIndex,
 
  150                 std::optional<uint8_t> DebugLocListTagOffset)
 
  151      : DebugLocListIndex(DebugLocListIndex),
 
  152        DebugLocListTagOffset(DebugLocListTagOffset) {}
 
 
  155    return DebugLocListTagOffset;
 
 
 
  164    assert((!
E || 
E->isValid()) && 
"Expected valid expression");
 
  165    assert(FI != std::numeric_limits<int>::max() && 
"Expected valid index");
 
 
 
  181    std::optional<const DIExpression *> NonVariadicExpr =
 
  183    assert(NonVariadicExpr && *NonVariadicExpr);
 
 
 
 
  225  template <
typename T> 
bool holds()
 const {
 
  226    return std::holds_alternative<T>(*
this);
 
 
  229  template <
typename T> 
auto &
get() noexcept {
 
  231    return *std::get_if<T>(
this);
 
 
  234  template <
typename T> 
const auto &
get() 
const noexcept {
 
  236    return *std::get_if<T>(
this);
 
 
  256      return dwarf::DW_TAG_formal_parameter;
 
  258    return dwarf::DW_TAG_variable;
 
 
 
  307    return dwarf::DW_TAG_label;
 
 
 
  323      : Register(
Reg), Value(Val) {
 
  324    assert(
Reg && 
"Parameter register cannot be undef");
 
 
 
  362  std::vector<SymbolCU> ArangeLabels;
 
  411      TypeUnitsUnderConstruction;
 
  419  unsigned NumTypeUnitsCreated = 0;
 
  422  bool UseGNUTLSOpcode;
 
  425  bool UseDWARF2Bitfields;
 
  428  bool UseAllLinkageNames;
 
  431  bool UseInlineStrings = 
false;
 
  434  bool UseRangesSection = 
true;
 
  438  bool UseSectionsAsReferences = 
false;
 
  441  bool UseARangesSection = 
false;
 
  444  bool GenerateTypeUnits;
 
  447  bool UseDebugMacroSection;
 
  450  bool EnableOpConvert;
 
  477  bool HasAppleExtensionAttributes;
 
  484  bool UseSegmentedStringOffsetsTable;
 
  489  bool EmitDebugEntryValues;
 
  541  void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &
CU,
 
  543                                             const MDNode *Scope);
 
  545  DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
 
  548                                  const DILocation *Location,
 
  549                                  const MCSymbol *Sym = 
nullptr);
 
  552  void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
 
  555  void constructCallSiteEntryDIEs(
const DISubprogram &SP, DwarfCompileUnit &
CU,
 
  556                                  DIE &ScopeDIE, 
const MachineFunction &MF);
 
  558  template <
typename DataT>
 
  559  void addAccelNameImpl(
const DwarfUnit &Unit,
 
  561                        AccelTable<DataT> &AppleAccel, StringRef Name,
 
  564  void finishEntityDefinitions();
 
  566  void finishSubprogramDefinitions();
 
  570  void finalizeModuleInfo();
 
  573  void emitDebugInfo();
 
  576  void emitAbbreviations();
 
  579  void emitStringOffsetsTableHeader();
 
  582  template <
typename AccelTableT>
 
  583  void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
 
  586  void emitAccelDebugNames();
 
  589  void emitAccelNames();
 
  593  void emitAccelObjC();
 
  596  void emitAccelNamespaces();
 
  599  void emitAccelTypes();
 
  602  void emitDebugPubSections();
 
  604  void emitDebugPubSection(
bool GnuStyle, StringRef Name,
 
  605                           DwarfCompileUnit *TheU,
 
  606                           const StringMap<const DIE *> &Globals);
 
  615  void emitDebugLocDWO();
 
  617  void emitDebugLocImpl(MCSection *Sec);
 
  620  void emitDebugARanges();
 
  623  void emitDebugRanges();
 
  624  void emitDebugRangesDWO();
 
  625  void emitDebugRangesImpl(
const DwarfFile &Holder, MCSection *Section);
 
  628  void emitDebugMacinfo();
 
  630  void emitDebugMacinfoDWO();
 
  631  void emitDebugMacinfoImpl(MCSection *Section);
 
  632  void emitMacro(DIMacro &M);
 
  633  void emitMacroFile(DIMacroFile &
F, DwarfCompileUnit &U);
 
  634  void emitMacroFileImpl(DIMacroFile &
F, DwarfCompileUnit &U,
 
  635                         unsigned StartFile, 
unsigned EndFile,
 
  636                         StringRef (*MacroFormToString)(
unsigned Form));
 
  637  void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
 
  642  void initSkeletonUnit(
const DwarfUnit &U, DIE &Die,
 
  643                        std::unique_ptr<DwarfCompileUnit> NewU);
 
  652  DwarfCompileUnit &constructSkeletonCU(
const DwarfCompileUnit &
CU);
 
  655  void emitDebugInfoDWO();
 
  658  void emitDebugAbbrevDWO();
 
  661  void emitDebugLineDWO();
 
  664  void emitStringOffsetsTableHeaderDWO();
 
  667  void emitDebugStrDWO();
 
  670  void emitDebugAddr();
 
  674  void addGnuPubAttributes(DwarfCompileUnit &U, DIE &
D) 
const;
 
  678  DwarfCompileUnit &getOrCreateDwarfCompileUnit(
const DICompileUnit *DIUnit);
 
  679  void finishUnitAttributes(
const DICompileUnit *DIUnit,
 
  680                            DwarfCompileUnit &NewCU);
 
  686                        unsigned Flags, StringRef Location = {});
 
  689  void collectEntityInfo(DwarfCompileUnit &TheCU, 
const DISubprogram *SP,
 
  690                         DenseSet<InlinedEntity> &ProcessedVars);
 
  696  bool buildLocationList(SmallVectorImpl<DebugLocEntry> &
DebugLoc,
 
  700  void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
 
  701                                      DenseSet<InlinedEntity> &
P);
 
  704  void emitSectionReference(
const DwarfCompileUnit &
CU);
 
  706  void findForceIsStmtInstrs(
const MachineFunction *MF);
 
  711  void computeKeyInstructions(
const MachineFunction *MF);
 
  804    return UseSectionsAsReferences;
 
 
  819    return HasAppleExtensionAttributes;
 
 
  833    return UseSegmentedStringOffsetsTable;
 
 
  837    return EmitDebugEntryValues;
 
 
  841    return EnableOpConvert;
 
 
  906    return CUDieMap.lookup(Die);
 
 
  914    return StringTypeLocMap.lookup(ST);
 
 
  920      StringTypeLocMap[ST] = 
Loc;
 
 
  945    return LocalDeclsPerLS[S];
 
 
  952      CurrentDebugNames = &AccelDebugNames;
 
  955      CurrentDebugNames = &AccelTypeUnitsDebugNames;
 
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
static void recordSourceLine(AsmPrinter &Asm, unsigned Line, unsigned Col, const MDNode *S, unsigned Flags, unsigned CUID, uint16_t DwarfVersion, ArrayRef< std::unique_ptr< DwarfCompileUnit > > DCUs, StringRef Comment={})
Register a source line with debug info.
This file contains constants used for implementing Dwarf debug support.
This file implements a map that provides insertion order iteration.
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...
This class is intended to be used as a driving class for all asm writers.
Basic type, like 'int' or 'float'.
A structured debug information entry.
static LLVM_ABI std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
StringRef getName() const
Tagged DWARF-like metadata node.
String type, Fortran CHARACTER(n)
Subprogram description. Uses SubclassData1.
StringRef getName() const
unsigned getRegister() const
DbgCallSiteParam(unsigned Reg, DbgValueLoc Val)
DbgValueLoc getValue() const
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
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.
const Loc::Variant & asVariant() const
bool isArtificial() const
Return true if DbgVariable is artificial.
dwarf::Tag getTag() const
bool isObjectPointer() const
const DILocalVariable * getVariable() const
DbgVariable(const DILocalVariable *V, const DILocation *IA)
Construct a DbgVariable.
auto & get() noexcept
Asserting, noexcept member alternative to std::get.
StringRef getName() const
const DIType * getType() const
const auto & get() const noexcept
Asserting, noexcept member alternative to std::get.
Loc::Variant & asVariant()
To workaround P2162R0 https://github.com/cplusplus/papers/issues/873 the base class subobject needs t...
static bool classof(const DbgEntity *N)
bool holds() const
Member shorthand for std::holds_alternative.
DebugHandlerBase(AsmPrinter *A)
Byte stream of .debug_loc entries.
bool useSegmentedStringOffsetsTable() const
Returns whether to generate a string offsets table with (possibly shared) contributions from each CU ...
MDNodeSet & getLocalDeclsForScope(const DILocalScope *S)
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 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 addAccelNamespace(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
void setCurrentDWARF5AccelTable(const DWARF5AccelTableKind Kind)
Sets the current DWARF5AccelTable to use.
bool alwaysUseRanges(const DwarfCompileUnit &) const
Returns whether range encodings should be used for single entry range lists.
void beginModule(Module *M) override
Emit all Dwarf sections that should come prior to the content.
void addSubprogramNames(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, const DISubprogram *SP, DIE &Die)
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
void insertSectionLabel(const MCSymbol *S)
void addAccelObjC(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const 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()
DWARF5AccelTable & getCurrentDWARF5AccelTable()
Returns either CU or TU DWARF5AccelTable.
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)
DwarfCompileUnit & getOrCreateAbstractSubprogramCU(const DISubprogram *SP, DwarfCompileUnit &SrcCU)
Find the matching DwarfCompileUnit for the given SP referenced from SrcCU.
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit the location for a debug loc entry, including the size header.
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.
unsigned getDwarfCompileUnitIDForLineTable(const DwarfCompileUnit &CU)
Get Dwarf compile unit ID for line table.
const MachineInstr * emitInitialLocDirective(const MachineFunction &MF, unsigned CUID)
Emits inital debug location directive.
void setTheAccelTableKind(AccelTableKind K)
Seet TheAccelTableKind.
bool useDWARF2Bitfields() const
Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
bool useAddrOffsetExpressions() const
bool useRangesSection() const
Returns whether ranges section should be emitted.
void addAccelName(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
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 addAccelType(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die, char Flags)
void beginCodeAlignment(const MachineBasicBlock &MBB) override
Process beginning of code alignment.
DwarfDebug(AsmPrinter *A)
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()
This dwarf writer support class manages information associated with a source file.
This class is used to track scope information.
Multi-value location description.
Multi(unsigned DebugLocListIndex, std::optional< uint8_t > DebugLocListTagOffset)
unsigned getDebugLocListIndex() const
std::optional< uint8_t > getDebugLocListTagOffset() const
Single value location description.
Single(DbgValueLoc ValueLoc)
const DbgValueLoc & getValueLoc() const
const DIExpression * getExpr() const
Wrapper class representing physical registers. Should be passed by value.
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.
A vector that has set insertion semantics.
Implements a dense probed hash-table based set with some number of buckets stored inline.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
std::variant< std::monostate, Loc::Single, Loc::Multi, Loc::MMI, Loc::EntryValue > Variant
Alias for the std::variant specialization base class of DbgVariable.
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
SmallVector< DbgCallSiteParam, 4 > ParamSet
Collection used for storing debug call site parameters.
AccelTableKind
The kind of accelerator tables we should emit.
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
@ Dwarf
DWARF v5 .debug_names.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
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.
Represents an entry-value location, or a fragment of one.
friend bool operator<(const EntryValueInfo &LHS, const EntryValueInfo &RHS)
Operator enabling sorting based on fragment offset.
const DIExpression & Expr
const DIExpression * Expr
friend bool operator<(const FrameIndexExpr &LHS, const FrameIndexExpr &RHS)
Operator enabling sorting based on fragment offset.
Single location defined by (potentially multiple) EntryValueInfo.
void addExpr(MCRegister Reg, const DIExpression &Expr)
std::set< EntryValueInfo > EntryValues
EntryValue(MCRegister Reg, const DIExpression &Expr)
Single location defined by (potentially multiple) MMI entries.
void addFrameIndexExpr(const DIExpression *Expr, int FI)
std::set< FrameIndexExpr > FrameIndexExprs
const std::set< FrameIndexExpr > & getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
MMI(const DIExpression *E, int FI)
Helper used to pair up a symbol and its DWARF compile unit.
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym)