18 :
Ref(const_cast<
T *>(Param)) {}
34 Variable(DVI->getVariable()),
Expression(DVI->getExpression()),
36 switch (DVI->getIntrinsicID()) {
37 case Intrinsic::dbg_value:
40 case Intrinsic::dbg_declare:
43 case Intrinsic::dbg_assign: {
54 "Trying to create a DbgVariableRecord with an invalid intrinsic type!");
62 AddressExpression(DVR.AddressExpression) {}
77 AddressExpression(AddressExpression) {}
82 delete cast<DbgVariableRecord>(
this);
85 delete cast<DbgLabelRecord>(
this);
94 cast<DbgVariableRecord>(
this)->print(O, IsForDebug);
97 cast<DbgLabelRecord>(
this)->print(O, IsForDebug);
104 bool IsForDebug)
const {
107 cast<DbgVariableRecord>(
this)->print(O, MST, IsForDebug);
110 cast<DbgLabelRecord>(
this)->print(O, MST, IsForDebug);
121 return cast<DbgVariableRecord>(
this)->isIdenticalToWhenDefined(
122 *cast<DbgVariableRecord>(&R));
124 return cast<DbgLabelRecord>(
this)->getLabel() ==
125 cast<DbgLabelRecord>(R).getLabel();
138 return cast<DbgVariableRecord>(
this)->createDebugIntrinsic(M, InsertBefore);
140 return cast<DbgLabelRecord>(
this)->createDebugIntrinsic(M, InsertBefore);
147 assert(Label &&
"Unexpected nullptr");
148 assert((isa<DILabel>(Label) || Label->isTemporary()) &&
149 "Label type must be or resolve to a DILabel");
153 assert(Label &&
"Unexpected nullptr");
168 Expression(Expression), AddressExpression(AddressExpression) {}
190 NewDbgVariableRecord->insertBefore(&InsertBefore);
191 return NewDbgVariableRecord;
207 NewDVRDeclare->insertBefore(&InsertBefore);
208 return NewDVRDeclare;
224 auto *Link = LinkedInstr->
getMetadata(LLVMContext::MD_DIAssignID);
225 assert(Link &&
"Linked instruction must have DIAssign metadata attached");
229 LinkedInstr->
getParent()->insertDbgRecordAfter(NewDVRAssign, LinkedInstr);
243 if (
auto *VAM = dyn_cast<ValueAsMetadata>(MD))
247 if (
auto *AL = dyn_cast<DIArgList>(MD))
252 assert(cast<MDNode>(MD)->getNumOperands() == 0);
268 if (
auto *AL = dyn_cast<DIArgList>(MD))
269 return AL->getArgs()[OpIdx]->getValue();
272 assert(isa<ValueAsMetadata>(MD) &&
273 "Attempted to get location operand from DbgVariableRecord with none.");
274 auto *V = cast<ValueAsMetadata>(MD);
275 assert(OpIdx == 0 &&
"Operand Index must be 0 for a debug intrinsic with a "
276 "single location operand.");
277 return V->getValue();
281 return isa<MetadataAsValue>(V) ? dyn_cast<ValueAsMetadata>(
282 cast<MetadataAsValue>(V)->getMetadata())
289 assert(NewValue &&
"Values must be non-null");
292 if (DbgAssignAddrReplaced)
296 auto OldIt =
find(Locations, OldValue);
297 if (OldIt == Locations.end()) {
298 if (AllowEmpty || DbgAssignAddrReplaced)
306 ? cast<MetadataAsValue>(NewValue)->getMetadata()
315 for (
auto *VMD : Locations)
326 ? cast<MetadataAsValue>(NewValue)->getMetadata()
344 "NewExpr for debug variable intrinsic does not reference every "
345 "location operand.");
351 for (
auto *VMD : NewValues)
361 if (!RemovedValues.
insert(OldValue).second)
380 return Fragment->SizeInBits;
387 return cast<DbgVariableRecord>(
this)->clone();
389 return cast<DbgLabelRecord>(
this)->clone();
406 getDebugLoc()->getScope()->getSubprogram()->getUnit();
408 "Cannot clone from BasicBlock that is not part of a Module or "
433 "DbgVariableRecord's RawLocation should be non-null.");
435 Value *AssignArgs[] = {
448 DVI = cast<DbgVariableIntrinsic>(
470 DbgLabel->insertBefore(InsertBefore);
476 if (
auto *V = dyn_cast_or_null<ValueAsMetadata>(MD))
477 return V->getValue();
480 assert((!MD || !cast<MDNode>(MD)->getNumOperands()) &&
481 "Expected an empty MDNode");
500 return !
Addr || isa<UndefValue>(
Addr);
537 "Cannot insert a DbgRecord that is already has a DbgMarker!");
539 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
545 "Cannot insert a DbgRecord that is already has a DbgMarker!");
547 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
553 "Canot move a DbgRecord that does not currently have a DbgMarker!");
559 "Canot move a DbgRecord that does not currently have a DbgMarker!");
656 New->setMarker(
this);
660 "DbgRecord 'InsertBefore' must be contained in this DbgMarker!");
662 New->setMarker(
this);
666 "DbgRecord 'InsertAfter' must be contained in this DbgMarker!");
668 New->setMarker(
this);
673 for (
DbgRecord &DVR : Src.StoredDbgRecords)
701 if (from_here.has_value())
709 New->setMarker(
this);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static SymbolRef::Type getType(const Symbol *Sym)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
LLVM Basic Block Representation.
void setTrailingDbgRecords(DbgMarker *M)
Record that the collection of DbgRecords in M "trails" after the last instruction of this block.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
LLVMContext & getContext() const
Get the context in which this basic block lives.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setTailCall(bool IsTc=true)
static DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
static std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
This represents the llvm.dbg.assign instruction.
This is the common base class for debug info intrinsics.
This represents the llvm.dbg.label instruction.
Records a position in IR for a source label (DILabel).
DbgLabelRecord * clone() const
static DbgLabelRecord * createUnresolvedDbgLabelRecord(MDNode *Label, MDNode *DL)
For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved MDNodes.
DILabel * getLabel() const
DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
This class is used to track label information.
Per-instruction record of debug-info.
Instruction * MarkedInstr
Link back to the Instruction that owns 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 insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter)
Insert a DbgRecord after a DbgRecord contained within this marker.
void removeMarker()
Handle the removal of a marker: the position of debug-info has gone away, but the stored debug record...
void absorbDebugValues(DbgMarker &Src, bool InsertAtHead)
Transfer any DbgRecords from Src into this DbgMarker.
void dropDbgRecords()
Erase all DbgRecords in this DbgMarker.
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange()
Produce a range over all the DbgRecords in this Marker.
void dropOneDbgRecord(DbgRecord *DR)
Erase a single DbgRecord from this marker.
const BasicBlock * getParent() const
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
void insertDbgRecord(DbgRecord *New, bool InsertAtHead)
Insert a DbgRecord into this DbgMarker, at the end of the list.
static DbgMarker EmptyDbgMarker
We generally act like all llvm Instructions have a range of DbgRecords attached to them,...
A typed tracking MDNode reference that does not require a definition for its parameter type.
T * get() const
Get the underlying type.
DbgRecordParamRef()=default
Base class for non-instruction debug metadata records that have positions within IR.
void insertAfter(DbgRecord *InsertAfter)
void print(raw_ostream &O, bool IsForDebug=false) const
bool isEquivalentTo(const DbgRecord &R) const
Same as isIdenticalToWhenDefined but checks DebugLoc too.
DebugLoc getDebugLoc() const
DbgInfoIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgRecord back into an appropriate llvm.dbg.
Kind RecordKind
Subclass discriminator.
void deleteRecord()
Methods that dispatch to subclass implementations.
void insertBefore(DbgRecord *InsertBefore)
void moveBefore(DbgRecord *MoveBefore)
const Instruction * getInstruction() const
void moveAfter(DbgRecord *MoveAfter)
bool isIdenticalToWhenDefined(const DbgRecord &R) const
DbgMarker * Marker
Marker that this DbgRecord is linked into.
void setMarker(DbgMarker *M)
DbgRecord * clone() const
LLVMContext & getContext()
const BasicBlock * getParent() const
This is the common base class for debug info intrinsics for variables.
Metadata * getRawLocation() const
Iterator for ValueAsMetadata that internally uses direct pointer iteration over either a ValueAsMetad...
Record of a variable value-assignment, aka a non instruction representation of the dbg....
DbgVariableRecord(const DbgVariableIntrinsic *DVI)
Create a new DbgVariableRecord representing the intrinsic DVI, for example the assignment represented...
LocationType getType() const
bool isKillAddress() const
Check whether this kills the address component.
DbgRecordParamRef< DILocalVariable > Variable
bool isKillLocation() const
DIAssignID * getAssignID() const
std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
DbgVariableRecord * clone() const
static DbgVariableRecord * createUnresolvedDbgVariableRecord(LocationType Type, Metadata *Val, MDNode *Variable, MDNode *Expression, MDNode *AssignID, Metadata *Address, MDNode *AddressExpression, MDNode *DI)
Used to create DbgVariableRecords during parsing, where some metadata references may still be unresol...
void setRawLocation(Metadata *NewLocation)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
static DbgVariableRecord * createDbgVariableRecord(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
static DbgVariableRecord * createDVRDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
Value * getAddress() const
void setExpression(DIExpression *NewExpr)
DIExpression * getExpression() const
Value * getVariableLocationOp(unsigned OpIdx) const
void setKillAddress()
Kill the address component.
DILocalVariable * getVariable() const
void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
void setAssignId(DIAssignID *New)
void setAddress(Value *V)
static DbgVariableRecord * createDVRAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
unsigned getNumVariableLocationOps() const
DbgVariableIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgVariableRecord back into a dbg.value intrinsic.
Metadata * getRawAddress() const
void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
std::optional< DbgVariableFragmentInfo > getFragment() const
static DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
DbgRecordParamRef< DIExpression > AddressExpression
DIExpression * getAddressExpression() const
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...
std::array< Metadata *, 3 > DebugValues
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Class representing an expression and its matching format.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Module * getParent()
Get the module that this global value is contained inside of...
DbgMarker * DebugMarker
Optional marker recording the position for debugging information that takes effect immediately before...
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
This is an important class for using LLVM in a threaded context.
LLVMContext & getContext() const
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
const ParentTy * getParent() const
self_iterator getIterator()
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, false >::type iterator
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
static ValueAsMetadata * getAsMetadata(Value *V)
@ Ref
The access may reference the value stored in memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.