LLVM 23.0.0git
llvm::NVPTXDwarfDebug Class Reference

NVPTXDwarfDebug - NVPTX-specific DwarfDebug implementation. More...

#include "Target/NVPTX/NVPTXDwarfDebug.h"

Inheritance diagram for llvm::NVPTXDwarfDebug:
[legend]

Public Member Functions

 NVPTXDwarfDebug (AsmPrinter *A)
 Constructor - Pass through to DwarfDebug constructor.
Public Member Functions inherited from llvm::DwarfDebug
 DwarfDebug (AsmPrinter *A)
 ~DwarfDebug () override
void beginModule (Module *M) override
 Emit all Dwarf sections that should come prior to the content.
void endModule () override
 Emit all Dwarf sections that should come after the content.
const MachineInstremitInitialLocDirective (const MachineFunction &MF, unsigned CUID)
 Emits inital debug location directive.
void beginInstruction (const MachineInstr *MI) override
 Process beginning of an instruction.
void beginCodeAlignment (const MachineBasicBlock &MBB) override
 Process beginning of code alignment.
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 addArangeLabel (SymbolCU SCU)
 Add a label so that arange data can be generated for it.
void setSymbolSize (const MCSymbol *Sym, uint64_t Size) override
 For symbols that have a size designated (e.g.
bool useAllLinkageNames () const
 Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
bool useGNUTLSOpcode () const
 Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opcode.
bool useDWARF2Bitfields () const
 Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
bool useInlineStrings () const
 Returns whether to use inline strings.
bool useRangesSection () const
 Returns whether ranges section should be emitted.
bool alwaysUseRanges (const DwarfCompileUnit &) const
 Returns whether range encodings should be used for single entry range lists.
bool useAddrOffsetExpressions () const
bool useAddrOffsetForm () const
bool useSectionsAsReferences () const
 Returns whether to use sections as labels rather than temp symbols.
bool generateTypeUnits () const
 Returns whether to generate DWARF v4 type units.
AccelTableKind getAccelTableKind () const
 Returns what kind (if any) of accelerator tables to emit.
void setTheAccelTableKind (AccelTableKind K)
 Seet TheAccelTableKind.
bool useAppleExtensionAttributes () const
bool useSplitDwarf () const
 Returns whether or not to change the current debug info for the split dwarf proposal support.
bool useSegmentedStringOffsetsTable () const
 Returns whether to generate a string offsets table with (possibly shared) contributions from each CU and type unit.
bool emitDebugEntryValues () const
bool useOpConvert () const
bool shareAcrossDWOCUs () const
uint16_t getDwarfVersion () const
 Returns the Dwarf Version.
dwarf::Form getDwarfSectionOffsetForm () const
 Returns a suitable DWARF form to represent a section offset, i.e.
const DwarfCompileUnitgetPrevCU () const
 Returns the previous CU that was being updated.
void setPrevCU (const DwarfCompileUnit *PrevCU)
void terminateLineTable (const DwarfCompileUnit *CU)
 Terminate the line table by adding the last range label.
const DebugLocStreamgetDebugLocs () const
 Returns the entries for the .debug_loc section.
void emitDebugLocEntry (ByteStreamer &Streamer, const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
 Emit an entry for the debug loc section.
void emitDebugLocEntryLocation (const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
 Emit the location for a debug loc entry, including the size header.
void addSubprogramNames (const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, const DISubprogram *SP, DIE &Die)
AddressPoolgetAddressPool ()
void addAccelName (const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
void addAccelObjC (const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
void addAccelNamespace (const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
void addAccelType (const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die, char Flags)
const MachineFunctiongetCurrentFunction () const
bool isLexicalScopeDIENull (LexicalScope *Scope)
 A helper function to check whether the DIE for a given Scope is going to be null.
DwarfCompileUnitlookupCU (const DIE *Die)
 Find the matching DwarfCompileUnit for the given CU DIE.
const DwarfCompileUnitlookupCU (const DIE *Die) const
DwarfCompileUnitgetOrCreateAbstractSubprogramCU (const DISubprogram *SP, DwarfCompileUnit &SrcCU)
 Find the matching DwarfCompileUnit for the given SP referenced from SrcCU.
unsigned getStringTypeLoc (const DIStringType *ST) const
void addStringTypeLoc (const DIStringType *ST, unsigned Loc)
bool tuneForGDB () const
bool tuneForLLDB () const
bool tuneForSCE () const
bool tuneForDBX () const
const MCSymbolgetSectionLabel (const MCSection *S)
void insertSectionLabel (const MCSymbol *S)
std::optional< MD5::MD5ResultgetMD5AsBytes (const DIFile *File) const
 If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
MDNodeSetgetLocalDeclsForScope (const DILocalScope *S)
void setCurrentDWARF5AccelTable (const DWARF5AccelTableKind Kind)
 Sets the current DWARF5AccelTable to use.
DWARF5AccelTablegetCurrentDWARF5AccelTable ()
 Returns either CU or TU DWARF5AccelTable.
Public Member Functions inherited from llvm::DebugHandlerBase
 ~DebugHandlerBase () override
void endInstruction () override
 Process end of an instruction.
void beginFunction (const MachineFunction *MF) override
 Gather pre-function debug information.
void endFunction (const MachineFunction *MF) override
 Gather post-function debug information.
void beginBasicBlockSection (const MachineBasicBlock &MBB) override
 Process the beginning of a new basic-block-section within a function.
void endBasicBlockSection (const MachineBasicBlock &MBB) override
 Process the end of a basic-block-section within a function.
MCSymbolgetLabelBeforeInsn (const MachineInstr *MI)
 Return Label preceding the instruction.
MCSymbolgetLabelAfterInsn (const MachineInstr *MI)
 Return Label immediately following the instruction.
const InstructionOrderinggetInstOrdering () const
const LexicalScopesgetLexicalScopes () const
Public Member Functions inherited from llvm::AsmPrinterHandler
virtual ~AsmPrinterHandler ()
 Pin vtables to this file.
virtual void markFunctionEnd ()
virtual void beginFunclet (const MachineBasicBlock &MBB, MCSymbol *Sym=nullptr)
 Emit target-specific EH funclet machinery.
virtual void endFunclet ()

Protected Member Functions

void initializeTargetDebugInfo (const MachineFunction &MF) override
 Override to collect inlined_at locations.
void recordTargetSourceLine (const DebugLoc &DL, unsigned Flags) override
 Override to record source line information with inlined_at support.
Protected Member Functions inherited from llvm::DwarfDebug
void beginFunctionImpl (const MachineFunction *MF) override
 Gather pre-function debug information.
void endFunctionImpl (const MachineFunction *MF) override
 Gather and emit post-function debug information.
unsigned getDwarfCompileUnitIDForLineTable (const DwarfCompileUnit &CU)
 Get Dwarf compile unit ID for line table.
void skippedNonDebugFunction () override
const SmallVectorImpl< std::unique_ptr< DwarfCompileUnit > > & getUnits ()
Protected Member Functions inherited from llvm::DebugHandlerBase
 DebugHandlerBase (AsmPrinter *A)
void identifyScopeMarkers ()
 Indentify instructions that are marking the beginning of or ending of a scope.
void requestLabelBeforeInsn (const MachineInstr *MI)
 Ensure that a label will be emitted before MI.
void requestLabelAfterInsn (const MachineInstr *MI)
 Ensure that a label will be emitted after MI.

Additional Inherited Members

Public Types inherited from llvm::DwarfDebug
enum class  MinimizeAddrInV5 {
  Default , Disabled , Ranges , Expressions ,
  Form
}
enum class  DWARF5AccelTableKind { CU = 0 , TU = 1 }
Static Public Member Functions inherited from llvm::DwarfDebug
static uint64_t makeTypeSignature (StringRef Identifier)
 Perform an MD5 checksum of Identifier and return the lower 64 bits.
static void emitDebugLocValue (const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
Static Public Member Functions inherited from llvm::DebugHandlerBase
static uint64_t getBaseTypeSize (const DIType *Ty)
 If this type is derived from a base type then return base type size.
static bool isUnsignedDIType (const DIType *Ty)
 Return true if type encoding is unsigned.
Protected Attributes inherited from llvm::DwarfDebug
DwarfFile InfoHolder
 Holder for the file specific debug information.
Protected Attributes inherited from llvm::DebugHandlerBase
AsmPrinterAsm = nullptr
 Target of debug info emission.
MachineModuleInfoMMI = nullptr
 Collected machine module information.
DebugLoc PrevInstLoc
 Previous instruction's location information.
MCSymbolPrevLabel = nullptr
const MachineBasicBlockPrevInstBB = nullptr
const MachineInstrPrologEndLoc
 This location indicates end of function prologue and beginning of function body.
const MachineBasicBlockEpilogBeginBlock = nullptr
 This block includes epilogue instructions.
const MachineInstrCurMI = nullptr
 If nonnull, stores the current machine instruction we're processing.
LexicalScopes LScopes
DbgValueHistoryMap DbgValues
 History of DBG_VALUE and clobber instructions for each user variable.
DbgLabelInstrMap DbgLabels
 Mapping of inlined labels and DBG_LABEL machine instruction.
DenseMap< const MachineInstr *, MCSymbol * > LabelsBeforeInsn
 Maps instruction with label emitted before instruction.
DenseMap< const MachineInstr *, MCSymbol * > LabelsAfterInsn
 Maps instruction with label emitted after instruction.

Detailed Description

NVPTXDwarfDebug - NVPTX-specific DwarfDebug implementation.

Inherits from DwarfDebug to provide enhanced line information with inlined_at support.

Definition at line 26 of file NVPTXDwarfDebug.h.

Constructor & Destructor Documentation

◆ NVPTXDwarfDebug()

NVPTXDwarfDebug::NVPTXDwarfDebug ( AsmPrinter * A)

Constructor - Pass through to DwarfDebug constructor.

Definition at line 36 of file NVPTXDwarfDebug.cpp.

References A(), and llvm::DwarfDebug::DwarfDebug().

Member Function Documentation

◆ initializeTargetDebugInfo()

void NVPTXDwarfDebug::initializeTargetDebugInfo ( const MachineFunction & MF)
overrideprotectedvirtual

Override to collect inlined_at locations.

NVPTX-specific debug info initialization.

Reimplemented from llvm::DwarfDebug.

Definition at line 174 of file NVPTXDwarfDebug.cpp.

◆ recordTargetSourceLine()

void NVPTXDwarfDebug::recordTargetSourceLine ( const DebugLoc & DL,
unsigned Flags )
overrideprotectedvirtual

Override to record source line information with inlined_at support.

NVPTX-specific source line recording with inlined_at support.

Why this exists: NVPTX supports an "enhanced lineinfo" mode where inlining context is carried via line-table directives, rather than full DWARF DIEs. This is conceptually similar to proposals[1] for richer DWARF line tables that carry inline call context and callee identity in the line table. NVPTX implements this via target-specific .loc extensions in the PTX ISA[3].

How it impacts PTX assembly generation:

  • When enabled (PTX ISA >= 7.2 + line-tables-only / debug-directives-only), we emit multiple consecutive .loc directives for a single inlined instruction: the instruction's own location and its inlined_at parent chain.
  • During emission we use MCStreamer::emitDwarfLocDirectiveWithInlinedAt to emit an enhanced .loc directive[3] that carries the extra function_name and inlined_at operands in the PTX assembly stream.

Example (conceptual PTX .loc sequence for an inlined callsite): .loc 1 16 3 // caller location .loc 1 5 3, function_name $L__info_stringN, inlined_at 1 16 3 // inlined callee location Here, $L__info_stringN is a label (or label+immediate) referring into .debug_str.

How this impacts DWARF : DWARF generation tools that consume this PTX(e.g. ptxas assembler) can use the inlined_at and function_name operands to extend the DWARF v2 line table information. This adds:

  • a context column[2]: the inlined_at <file> <line> <col> information populates an inlining "context" (a reference to the parent/callsite row) enabling reconstruction of inline call chains from the line table.
  • a function_name column[2]: the .loc ... function_name <sym> identifies the inlined callee associated with a non-zero context.

References:

Reimplemented from llvm::DwarfDebug.

Definition at line 81 of file NVPTXDwarfDebug.cpp.

References llvm::DebugHandlerBase::Asm, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), DL, llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::getDISubprogram(), llvm::DwarfDebug::getDwarfVersion(), llvm::MachineFunction::getFunction(), llvm::NVPTXSubtarget::getPTXVersion(), llvm::Function::getSubprogram(), llvm::MachineFunction::getSubtarget(), llvm::DwarfDebug::getUnits(), llvm::DwarfDebug::InfoHolder, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), LineInfoWithInlinedAt, llvm::DICompileUnit::LineTablesOnly, llvm_unreachable, llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().


The documentation for this class was generated from the following files: