LLVM 20.0.0git
|
Per-instruction record of debug-info. More...
#include "llvm/IR/DebugProgramInstruction.h"
Public Member Functions | |
DbgMarker () | |
bool | empty () const |
const BasicBlock * | getParent () const |
BasicBlock * | getParent () |
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 DbgMarker. | |
void | print (raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const |
iterator_range< simple_ilist< DbgRecord >::iterator > | getDbgRecordRange () |
Produce a range over all the DbgRecords in this Marker. | |
iterator_range< simple_ilist< DbgRecord >::const_iterator > | getDbgRecordRange () const |
void | absorbDebugValues (DbgMarker &Src, bool InsertAtHead) |
Transfer any DbgRecords from Src into this DbgMarker. | |
void | absorbDebugValues (iterator_range< DbgRecord::self_iterator > Range, DbgMarker &Src, bool InsertAtHead) |
Transfer the DbgRecords in Range from Src into this DbgMarker. | |
void | insertDbgRecord (DbgRecord *New, bool InsertAtHead) |
Insert a DbgRecord into this DbgMarker, at the end of the list. | |
void | insertDbgRecord (DbgRecord *New, DbgRecord *InsertBefore) |
Insert a DbgRecord prior to a DbgRecord contained within this marker. | |
void | insertDbgRecordAfter (DbgRecord *New, DbgRecord *InsertAfter) |
Insert a DbgRecord after a DbgRecord contained within this marker. | |
iterator_range< simple_ilist< DbgRecord >::iterator > | cloneDebugInfoFrom (DbgMarker *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere, bool InsertAtHead=false) |
Clone all DbgMarkers from From into this marker. | |
void | dropDbgRecords () |
Erase all DbgRecords in this DbgMarker. | |
void | dropOneDbgRecord (DbgRecord *DR) |
Erase a single DbgRecord from this marker. | |
Static Public Member Functions | |
static iterator_range< simple_ilist< DbgRecord >::iterator > | getEmptyDbgRecordRange () |
Public Attributes | |
Instruction * | MarkedInstr = nullptr |
Link back to the Instruction that owns this marker. | |
simple_ilist< DbgRecord > | StoredDbgRecords |
List of DbgRecords, the non-instruction equivalent of llvm.dbg. | |
Static Public Attributes | |
static DbgMarker | EmptyDbgMarker |
We generally act like all llvm Instructions have a range of DbgRecords attached to them, but in reality sometimes we don't allocate the DbgMarker to save time and memory, but still have to return ranges of DbgRecords. | |
Per-instruction record of debug-info.
If an Instruction is the position of some debugging information, it points at a DbgMarker 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 570 of file DebugProgramInstruction.h.
|
inline |
Definition at line 572 of file DebugProgramInstruction.h.
Transfer any DbgRecords from Src
into this DbgMarker.
If InsertAtHead
is true, place them before existing DbgRecords, otherwise afterwards.
Definition at line 670 of file DebugProgramInstruction.cpp.
References llvm::DbgRecord::setMarker(), and StoredDbgRecords.
Referenced by llvm::Instruction::adoptDbgRecords(), llvm::BasicBlock::reinsertInstInDbgRecords(), and removeMarker().
void llvm::DbgMarker::absorbDebugValues | ( | iterator_range< DbgRecord::self_iterator > | Range, |
DbgMarker & | Src, | ||
bool | InsertAtHead | ||
) |
Transfer the DbgRecords in Range
from Src
into this DbgMarker.
If InsertAtHead
is true, place them before existing DbgRecords, otherwise
Definition at line 678 of file DebugProgramInstruction.cpp.
References Range, and StoredDbgRecords.
iterator_range< simple_ilist< DbgRecord >::iterator > llvm::DbgMarker::cloneDebugInfoFrom | ( | DbgMarker * | From, |
std::optional< simple_ilist< DbgRecord >::iterator > | FromHere, | ||
bool | InsertAtHead = false |
||
) |
Clone all DbgMarkers 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 DbgRecords InsertAtHead
Place the cloned DbgRecords at the start of StoredDbgRecords
Definition at line 691 of file DebugProgramInstruction.cpp.
References llvm::First, From, llvm::make_range(), Range, and StoredDbgRecords.
Referenced by llvm::Instruction::cloneDebugInfoFrom(), and llvm::JumpThreadingPass::cloneInstructions().
void llvm::DbgMarker::dropDbgRecords | ( | ) |
Erase all DbgRecords in this DbgMarker.
Definition at line 569 of file DebugProgramInstruction.cpp.
References llvm::DbgRecord::deleteRecord(), and StoredDbgRecords.
Referenced by llvm::Instruction::dropDbgRecords(), and eraseFromParent().
void llvm::DbgMarker::dropOneDbgRecord | ( | 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 578 of file DebugProgramInstruction.cpp.
References assert(), llvm::DbgRecord::deleteRecord(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DbgRecord::getMarker(), and StoredDbgRecords.
Referenced by llvm::Instruction::dropOneDbgRecord().
LLVM_DUMP_METHOD void DbgMarker::dump | ( | ) | const |
Definition at line 5270 of file AsmWriter.cpp.
References llvm::dbgs(), and print().
|
inline |
Definition at line 582 of file DebugProgramInstruction.h.
References StoredDbgRecords.
Referenced by llvm::Instruction::insertBefore().
void llvm::DbgMarker::eraseFromParent | ( | ) |
Definition at line 627 of file DebugProgramInstruction.cpp.
References dropDbgRecords(), MarkedInstr, and removeFromParent().
Referenced by llvm::Instruction::adoptDbgRecords(), llvm::BasicBlock::convertFromNewDbgValues(), llvm::BasicBlock::flushTerminatorDbgRecords(), and removeMarker().
iterator_range< DbgRecord::self_iterator > llvm::DbgMarker::getDbgRecordRange | ( | ) |
Produce a range over all the DbgRecords in this Marker.
Definition at line 634 of file DebugProgramInstruction.cpp.
References llvm::make_range(), and StoredDbgRecords.
Referenced by llvm::BasicBlock::convertFromNewDbgValues(), llvm::getDbgRecordRange(), and getNextNode().
iterator_range< DbgRecord::const_self_iterator > llvm::DbgMarker::getDbgRecordRange | ( | ) | const |
Definition at line 638 of file DebugProgramInstruction.cpp.
References llvm::make_range(), and StoredDbgRecords.
|
inlinestatic |
Definition at line 648 of file DebugProgramInstruction.h.
References EmptyDbgMarker, llvm::make_range(), and StoredDbgRecords.
Referenced by llvm::Instruction::cloneDebugInfoFrom(), and llvm::getDbgRecordRange().
BasicBlock * llvm::DbgMarker::getParent | ( | ) |
Definition at line 588 of file DebugProgramInstruction.cpp.
References llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), and MarkedInstr.
const BasicBlock * llvm::DbgMarker::getParent | ( | ) | const |
Definition at line 584 of file DebugProgramInstruction.cpp.
References llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), and MarkedInstr.
Referenced by formLCSSAForInstructionsImpl(), llvm::DbgRecord::getBlock(), getModuleFromDPI(), llvm::DbgLabelRecord::print(), llvm::DbgVariableRecord::print(), print(), removeMarker(), replaceDbgUsesOutsideBlock(), and RewriteUsesOfClonedInstructions().
Insert a DbgRecord into this DbgMarker, at the end of the list.
If InsertAtHead
is true, at the start.
Definition at line 652 of file DebugProgramInstruction.cpp.
References StoredDbgRecords.
Referenced by llvm::BasicBlock::convertToNewDbgValues(), llvm::DbgRecord::insertBefore(), and llvm::BasicBlock::insertDbgRecordAfter().
Insert a DbgRecord prior to a DbgRecord contained within this marker.
Definition at line 657 of file DebugProgramInstruction.cpp.
References assert(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DbgRecord::getMarker(), and StoredDbgRecords.
Insert a DbgRecord after a DbgRecord contained within this marker.
Definition at line 663 of file DebugProgramInstruction.cpp.
References assert(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::DbgRecord::getMarker(), and StoredDbgRecords.
Referenced by llvm::DbgRecord::insertAfter().
void DbgMarker::print | ( | raw_ostream & | O, |
bool | IsForDebug = false |
||
) | const |
Implement operator<< on DbgMarker.
Definition at line 4957 of file AsmWriter.cpp.
References getModuleFromDPI(), and print().
Referenced by dump(), llvm::operator<<(), and print().
void DbgMarker::print | ( | raw_ostream & | ROS, |
ModuleSlotTracker & | MST, | ||
bool | IsForDebug | ||
) | const |
Definition at line 4969 of file AsmWriter.cpp.
References F, llvm::ModuleSlotTracker::getMachine(), getModuleFromDPI(), getParent(), llvm::ModuleSlotTracker::incorporateFunction(), and OS.
void llvm::DbgMarker::removeFromParent | ( | ) |
Definition at line 622 of file DebugProgramInstruction.cpp.
References llvm::Instruction::DebugMarker, and MarkedInstr.
Referenced by eraseFromParent().
void llvm::DbgMarker::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 590 of file DebugProgramInstruction.cpp.
References absorbDebugValues(), llvm::Instruction::DebugMarker, eraseFromParent(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), getParent(), MarkedInstr, llvm::BasicBlock::setTrailingDbgRecords(), and StoredDbgRecords.
Referenced by llvm::Instruction::handleMarkerRemoval().
|
static |
We generally act like all llvm Instructions have a range of DbgRecords attached to them, but in reality sometimes we don't allocate the DbgMarker to save time and memory, but still have to return ranges of DbgRecords.
When we need to describe such an unallocated DbgRecord range, use this static markers range instead. This will bite us if someone tries to insert a DbgRecord in that range, but they should be using the Official (TM) API for that.
Definition at line 646 of file DebugProgramInstruction.h.
Referenced by getEmptyDbgRecordRange().
Instruction* llvm::DbgMarker::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 575 of file DebugProgramInstruction.h.
Referenced by llvm::Instruction::adoptDbgRecords(), llvm::BasicBlock::createMarker(), eraseFromParent(), llvm::DbgRecord::getInstruction(), getNextNode(), llvm::DbgRecord::getParent(), getParent(), removeFromParent(), removeMarker(), and rewriteDebugUsers().
simple_ilist<DbgRecord> llvm::DbgMarker::StoredDbgRecords |
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
Definition at line 581 of file DebugProgramInstruction.h.
Referenced by absorbDebugValues(), llvm::Instruction::adoptDbgRecords(), cloneDebugInfoFrom(), dropDbgRecords(), dropOneDbgRecord(), empty(), getDbgRecordRange(), llvm::Instruction::getDbgReinsertionPosition(), getEmptyDbgRecordRange(), insertDbgRecord(), insertDbgRecordAfter(), llvm::BasicBlock::reinsertInstInDbgRecords(), llvm::DbgRecord::removeFromParent(), and removeMarker().