LLVM 19.0.0git
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
llvm::DPMarker Class Reference

Per-instruction record of debug-info. More...

#include "llvm/IR/DebugProgramInstruction.h"

Public Member Functions

 DPMarker ()
 
bool empty () const
 
const BasicBlockgetParent () const
 
BasicBlockgetParent ()
 
void removeMarker ()
 Handle the removal of a marker: the position of debug-info has gone away, but the stored debug records should not.
 
void dump () const
 
void removeFromParent ()
 
void eraseFromParent ()
 
void print (raw_ostream &O, bool IsForDebug=false) const
 Implement operator<< on DPMarker.
 
void print (raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const
 
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgValueRange ()
 Produce a range over all the DPValues in this Marker.
 
iterator_range< simple_ilist< DbgRecord >::const_iteratorgetDbgValueRange () const
 
void absorbDebugValues (DPMarker &Src, bool InsertAtHead)
 Transfer any DPValues from Src into this DPMarker.
 
void absorbDebugValues (iterator_range< DbgRecord::self_iterator > Range, DPMarker &Src, bool InsertAtHead)
 Transfer the DPValues in Range from Src into this DPMarker.
 
void insertDPValue (DbgRecord *New, bool InsertAtHead)
 Insert a DPValue into this DPMarker, at the end of the list.
 
void insertDPValue (DbgRecord *New, DbgRecord *InsertBefore)
 Insert a DPValue prior to a DPValue contained within this marker.
 
void insertDPValueAfter (DbgRecord *New, DbgRecord *InsertAfter)
 Insert a DPValue after a DPValue contained within this marker.
 
iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom (DPMarker *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere, bool InsertAtHead=false)
 Clone all DPMarkers from From into this marker.
 
void dropDbgValues ()
 Erase all DPValues in this DPMarker.
 
void dropOneDbgValue (DbgRecord *DR)
 Erase a single DbgRecord from this marker.
 

Static Public Member Functions

static iterator_range< simple_ilist< DbgRecord >::iterator > getEmptyDPValueRange ()
 

Public Attributes

InstructionMarkedInstr = nullptr
 Link back to the Instruction that owns this marker.
 
simple_ilist< DbgRecordStoredDPValues
 List of DbgRecords, the non-instruction equivalent of llvm.dbg.
 

Static Public Attributes

static DPMarker EmptyDPMarker
 We generally act like all llvm Instructions have a range of DPValues attached to them, but in reality sometimes we don't allocate the DPMarker to save time and memory, but still have to return ranges of DPValues.
 

Detailed Description

Per-instruction record of debug-info.

If an Instruction is the position of some debugging information, it points at a DPMarker storing that info. Each marker points back at the instruction that owns it. Various utilities are provided for manipulating the DbgRecords contained within this marker.

This class has a rough surface area, because it's needed to preserve the one arefact that we can't yet eliminate from the intrinsic / dbg.value debug-info design: the order of records is significant, and duplicates can exist. Thus, if one has a run of debug-info records such as: dbg.value(... foo = barinst dbg.value(... and remove barinst, then the dbg.values must be preserved in the correct order. Hence, the use of iterators to select positions to insert things into, or the occasional InsertAtHead parameter indicating that new records should go at the start of the list.

There are only five or six places in LLVM that truly rely on this ordering, which we can improve in the future. Additionally, many improvements in the way that debug-info is stored can be achieved in this class, at a future date.

Definition at line 469 of file DebugProgramInstruction.h.

Constructor & Destructor Documentation

◆ DPMarker()

llvm::DPMarker::DPMarker ( )
inline

Definition at line 471 of file DebugProgramInstruction.h.

Member Function Documentation

◆ absorbDebugValues() [1/2]

void llvm::DPMarker::absorbDebugValues ( DPMarker Src,
bool  InsertAtHead 
)

Transfer any DPValues from Src into this DPMarker.

If InsertAtHead is true, place them before existing DPValues, otherwise afterwards.

Definition at line 605 of file DebugProgramInstruction.cpp.

References llvm::DbgRecord::setMarker(), and StoredDPValues.

Referenced by llvm::Instruction::adoptDbgValues(), llvm::BasicBlock::reinsertInstInDPValues(), and removeMarker().

◆ absorbDebugValues() [2/2]

void llvm::DPMarker::absorbDebugValues ( iterator_range< DbgRecord::self_iterator Range,
DPMarker Src,
bool  InsertAtHead 
)

Transfer the DPValues in Range from Src into this DPMarker.

If InsertAtHead is true, place them before existing DPValues, otherwise

Definition at line 613 of file DebugProgramInstruction.cpp.

References StoredDPValues.

◆ cloneDebugInfoFrom()

iterator_range< simple_ilist< DbgRecord >::iterator > llvm::DPMarker::cloneDebugInfoFrom ( DPMarker From,
std::optional< simple_ilist< DbgRecord >::iterator >  FromHere,
bool  InsertAtHead = false 
)

Clone all DPMarkers from From into this marker.

There are numerous options to customise the source/destination, due to gnarliness, see class comment. FromHere If non-null, copy from FromHere to the end of From's DPValues InsertAtHead Place the cloned DPValues at the start of StoredDPValues

Returns
Range over all the newly cloned DPValues

Definition at line 625 of file DebugProgramInstruction.cpp.

References llvm::First, From, llvm::make_range(), and StoredDPValues.

Referenced by llvm::Instruction::cloneDebugInfoFrom(), and llvm::JumpThreadingPass::cloneInstructions().

◆ dropDbgValues()

void llvm::DPMarker::dropDbgValues ( )

Erase all DPValues in this DPMarker.

Definition at line 504 of file DebugProgramInstruction.cpp.

References llvm::DbgRecord::deleteRecord(), and StoredDPValues.

Referenced by llvm::Instruction::dropDbgValues(), and eraseFromParent().

◆ dropOneDbgValue()

void llvm::DPMarker::dropOneDbgValue ( DbgRecord DR)

Erase a single DbgRecord from this marker.

In an ideal future, we would never erase an assignment in this way, but it's the equivalent to erasing a debug intrinsic from a block.

Definition at line 513 of file DebugProgramInstruction.cpp.

References assert(), llvm::DbgRecord::deleteRecord(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DbgRecord::getMarker(), and StoredDPValues.

Referenced by llvm::Instruction::dropOneDbgValue().

◆ dump()

LLVM_DUMP_METHOD void DPMarker::dump ( ) const

Definition at line 5216 of file AsmWriter.cpp.

References llvm::dbgs(), and print().

◆ empty()

bool llvm::DPMarker::empty ( ) const
inline

Definition at line 481 of file DebugProgramInstruction.h.

References StoredDPValues.

Referenced by llvm::Instruction::insertBefore().

◆ eraseFromParent()

void llvm::DPMarker::eraseFromParent ( )

◆ getDbgValueRange() [1/2]

iterator_range< DbgRecord::self_iterator > llvm::DPMarker::getDbgValueRange ( )

Produce a range over all the DPValues in this Marker.

Definition at line 569 of file DebugProgramInstruction.cpp.

References llvm::make_range(), and StoredDPValues.

Referenced by llvm::BasicBlock::convertFromNewDbgValues(), llvm::getDbgValueRange(), and getNextNode().

◆ getDbgValueRange() [2/2]

iterator_range< DbgRecord::const_self_iterator > llvm::DPMarker::getDbgValueRange ( ) const

Definition at line 573 of file DebugProgramInstruction.cpp.

References llvm::make_range(), and StoredDPValues.

◆ getEmptyDPValueRange()

static iterator_range< simple_ilist< DbgRecord >::iterator > llvm::DPMarker::getEmptyDPValueRange ( )
inlinestatic

◆ getParent() [1/2]

BasicBlock * llvm::DPMarker::getParent ( )

Definition at line 523 of file DebugProgramInstruction.cpp.

References llvm::Instruction::getParent(), and MarkedInstr.

◆ getParent() [2/2]

const BasicBlock * llvm::DPMarker::getParent ( ) const

◆ insertDPValue() [1/2]

void llvm::DPMarker::insertDPValue ( DbgRecord New,
bool  InsertAtHead 
)

Insert a DPValue into this DPMarker, at the end of the list.

If InsertAtHead is true, at the start.

Definition at line 587 of file DebugProgramInstruction.cpp.

References StoredDPValues.

Referenced by llvm::BasicBlock::convertToNewDbgValues(), llvm::DbgRecord::insertBefore(), and llvm::BasicBlock::insertDPValueAfter().

◆ insertDPValue() [2/2]

void llvm::DPMarker::insertDPValue ( DbgRecord New,
DbgRecord InsertBefore 
)

Insert a DPValue prior to a DPValue contained within this marker.

Definition at line 592 of file DebugProgramInstruction.cpp.

References assert(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DbgRecord::getMarker(), and StoredDPValues.

◆ insertDPValueAfter()

void llvm::DPMarker::insertDPValueAfter ( DbgRecord New,
DbgRecord InsertAfter 
)

Insert a DPValue after a DPValue contained within this marker.

Definition at line 598 of file DebugProgramInstruction.cpp.

References assert(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DbgRecord::getMarker(), and StoredDPValues.

Referenced by llvm::DbgRecord::insertAfter().

◆ print() [1/2]

void DPMarker::print ( raw_ostream O,
bool  IsForDebug = false 
) const

Implement operator<< on DPMarker.

Definition at line 4903 of file AsmWriter.cpp.

References getModuleFromDPI(), and print().

Referenced by dump(), llvm::operator<<(), and print().

◆ print() [2/2]

void DPMarker::print ( raw_ostream ROS,
ModuleSlotTracker MST,
bool  IsForDebug 
) const

◆ removeFromParent()

void llvm::DPMarker::removeFromParent ( )

Definition at line 557 of file DebugProgramInstruction.cpp.

References llvm::Instruction::DbgMarker, and MarkedInstr.

Referenced by eraseFromParent().

◆ removeMarker()

void llvm::DPMarker::removeMarker ( )

Handle the removal of a marker: the position of debug-info has gone away, but the stored debug records should not.

Drop them onto the next instruction, or otherwise work out what to do with them.

Definition at line 525 of file DebugProgramInstruction.cpp.

References absorbDebugValues(), llvm::Instruction::DbgMarker, eraseFromParent(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::BasicBlock::getNextMarker(), getParent(), llvm::Instruction::getParent(), MarkedInstr, llvm::BasicBlock::setTrailingDPValues(), and StoredDPValues.

Referenced by llvm::Instruction::handleMarkerRemoval().

Member Data Documentation

◆ EmptyDPMarker

DPMarker llvm::DPMarker::EmptyDPMarker
static

We generally act like all llvm Instructions have a range of DPValues attached to them, but in reality sometimes we don't allocate the DPMarker to save time and memory, but still have to return ranges of DPValues.

When we need to describe such an unallocated DPValue range, use this static markers range instead. This will bite us if someone tries to insert a DPValue in that range, but they should be using the Official (TM) API for that.

Definition at line 542 of file DebugProgramInstruction.h.

Referenced by getEmptyDPValueRange().

◆ MarkedInstr

Instruction* llvm::DPMarker::MarkedInstr = nullptr

Link back to the Instruction that owns this marker.

Can be null during operations that move a marker from one instruction to another.

Definition at line 474 of file DebugProgramInstruction.h.

Referenced by llvm::Instruction::adoptDbgValues(), llvm::BasicBlock::createMarker(), eraseFromParent(), llvm::DbgRecord::getInstruction(), getNextNode(), llvm::DbgRecord::getParent(), getParent(), removeFromParent(), removeMarker(), and rewriteDebugUsers().

◆ StoredDPValues

simple_ilist<DbgRecord> llvm::DPMarker::StoredDPValues

List of DbgRecords, the non-instruction equivalent of llvm.dbg.

  • intrinsics. There is a one-to-one relationship between each debug intrinsic in a block and each DbgRecord once the representation has been converted, and the ordering is meaningful in the same way.

Definition at line 480 of file DebugProgramInstruction.h.

Referenced by absorbDebugValues(), llvm::Instruction::adoptDbgValues(), cloneDebugInfoFrom(), dropDbgValues(), dropOneDbgValue(), empty(), llvm::Instruction::getDbgReinsertionPosition(), getDbgValueRange(), getEmptyDPValueRange(), insertDPValue(), insertDPValueAfter(), llvm::BasicBlock::reinsertInstInDPValues(), llvm::DbgRecord::removeFromParent(), and removeMarker().


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