19 :
Ref(const_cast<
T *>(Param)) {}
35 Variable(DVI->getVariable()),
Expression(DVI->getExpression()),
37 switch (DVI->getIntrinsicID()) {
38 case Intrinsic::dbg_value:
41 case Intrinsic::dbg_declare:
44 case Intrinsic::dbg_assign: {
55 "Trying to create a DbgVariableRecord with an invalid intrinsic type!");
63 AddressExpression(DVR.AddressExpression) {}
78 AddressExpression(AddressExpression) {}
83 delete cast<DbgVariableRecord>(
this);
86 delete cast<DbgLabelRecord>(
this);
95 cast<DbgVariableRecord>(
this)->print(O, IsForDebug);
98 cast<DbgLabelRecord>(
this)->print(O, IsForDebug);
105 bool IsForDebug)
const {
108 cast<DbgVariableRecord>(
this)->print(O, MST, IsForDebug);
111 cast<DbgLabelRecord>(
this)->print(O, MST, IsForDebug);
122 return cast<DbgVariableRecord>(
this)->isIdenticalToWhenDefined(
123 *cast<DbgVariableRecord>(&R));
125 return cast<DbgLabelRecord>(
this)->getLabel() ==
126 cast<DbgLabelRecord>(R).getLabel();
139 return cast<DbgVariableRecord>(
this)->createDebugIntrinsic(M, InsertBefore);
141 return cast<DbgLabelRecord>(
this)->createDebugIntrinsic(M, InsertBefore);
148 assert(Label &&
"Unexpected nullptr");
149 assert((isa<DILabel>(Label) || Label->isTemporary()) &&
150 "Label type must be or resolve to a DILabel");
154 assert(Label &&
"Unexpected nullptr");
169 Expression(Expression), AddressExpression(AddressExpression) {}
191 NewDbgVariableRecord->insertBefore(&InsertBefore);
192 return NewDbgVariableRecord;
208 NewDVRDeclare->insertBefore(&InsertBefore);
209 return NewDVRDeclare;
225 auto *Link = LinkedInstr->
getMetadata(LLVMContext::MD_DIAssignID);
226 assert(Link &&
"Linked instruction must have DIAssign metadata attached");
230 LinkedInstr->
getParent()->insertDbgRecordAfter(NewDVRAssign, LinkedInstr);
244 if (
auto *VAM = dyn_cast<ValueAsMetadata>(MD))
248 if (
auto *AL = dyn_cast<DIArgList>(MD))
253 assert(cast<MDNode>(MD)->getNumOperands() == 0);
269 if (
auto *AL = dyn_cast<DIArgList>(MD))
270 return AL->getArgs()[
OpIdx]->getValue();
273 assert(isa<ValueAsMetadata>(MD) &&
274 "Attempted to get location operand from DbgVariableRecord with none.");
275 auto *V = cast<ValueAsMetadata>(MD);
276 assert(
OpIdx == 0 &&
"Operand Index must be 0 for a debug intrinsic with a "
277 "single location operand.");
278 return V->getValue();
282 return isa<MetadataAsValue>(V) ? dyn_cast<ValueAsMetadata>(
283 cast<MetadataAsValue>(V)->getMetadata())
290 assert(NewValue &&
"Values must be non-null");
293 if (DbgAssignAddrReplaced)
297 auto OldIt =
find(Locations, OldValue);
298 if (OldIt == Locations.end()) {
299 if (AllowEmpty || DbgAssignAddrReplaced)
307 ? cast<MetadataAsValue>(NewValue)->getMetadata()
316 for (
auto *VMD : Locations)
327 ? cast<MetadataAsValue>(NewValue)->getMetadata()
345 "NewExpr for debug variable intrinsic does not reference every "
346 "location operand.");
352 for (
auto *VMD : NewValues)
362 if (!RemovedValues.
insert(OldValue).second)
381 return Fragment->SizeInBits;
388 return cast<DbgVariableRecord>(
this)->clone();
390 return cast<DbgLabelRecord>(
this)->clone();
407 getDebugLoc()->getScope()->getSubprogram()->getUnit();
409 "Cannot clone from BasicBlock that is not part of a Module or "
434 "DbgVariableRecord's RawLocation should be non-null.");
436 Value *AssignArgs[] = {
449 DVI = cast<DbgVariableIntrinsic>(
477 if (
auto *V = dyn_cast_or_null<ValueAsMetadata>(MD))
478 return V->getValue();
481 assert((!MD || !cast<MDNode>(MD)->getNumOperands()) &&
482 "Expected an empty MDNode");
501 return !
Addr || isa<UndefValue>(
Addr);
538 "Cannot insert a DbgRecord that is already has a DbgMarker!");
540 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
546 "Cannot insert a DbgRecord that is already has a DbgMarker!");
548 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
555 "Cannot insert a DbgRecord that is already has a DbgMarker!");
556 assert(InsertBefore->getMarker() &&
557 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
559 InsertBefore->getMarker()->insertDbgRecord(
this, &*InsertBefore);
563 "Cannot insert a DbgRecord that is already has a DbgMarker!");
564 assert(InsertAfter->getMarker() &&
565 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
567 InsertAfter->getMarker()->insertDbgRecordAfter(
this, &*InsertAfter);
572 "Canot move a DbgRecord that does not currently have a DbgMarker!");
578 "Canot move a DbgRecord that does not currently have a DbgMarker!");
585 "Canot move a DbgRecord that does not currently have a DbgMarker!");
591 "Canot move a DbgRecord that does not currently have a DbgMarker!");
688 New->setMarker(
this);
692 "DbgRecord 'InsertBefore' must be contained in this DbgMarker!");
694 New->setMarker(
this);
698 "DbgRecord 'InsertAfter' must be contained in this DbgMarker!");
700 New->setMarker(
this);
705 for (
DbgRecord &DVR : Src.StoredDbgRecords)
733 if (from_here.has_value())
741 New->setMarker(
this);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
#define LLVM_EXPORT_TEMPLATE
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.
MachineInstr unsigned OpIdx
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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.
LLVM_ABI 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...
LLVM_ABI 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 LLVM_ABI DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
LLVM_ABI bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
static LLVM_ABI std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
LLVM_ABI 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).
LLVM_ABI DbgLabelRecord * clone() const
static LLVM_ABI DbgLabelRecord * createUnresolvedDbgLabelRecord(MDNode *Label, MDNode *DL)
For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved MDNodes.
DILabel * getLabel() const
LLVM_ABI DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
This class is used to track label information.
Per-instruction record of debug-info.
LLVM_ABI void removeFromParent()
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
LLVM_ABI 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.
LLVM_ABI void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter)
Insert a DbgRecord after a DbgRecord contained within this marker.
LLVM_ABI void removeMarker()
Handle the removal of a marker: the position of debug-info has gone away, but the stored debug record...
LLVM_ABI void absorbDebugValues(DbgMarker &Src, bool InsertAtHead)
Transfer any DbgRecords from Src into this DbgMarker.
LLVM_ABI void dropDbgRecords()
Erase all DbgRecords in this DbgMarker.
LLVM_ABI iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange()
Produce a range over all the DbgRecords in this Marker.
LLVM_ABI void dropOneDbgRecord(DbgRecord *DR)
Erase a single DbgRecord from this marker.
LLVM_ABI const BasicBlock * getParent() const
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
LLVM_ABI void eraseFromParent()
LLVM_ABI void insertDbgRecord(DbgRecord *New, bool InsertAtHead)
Insert a DbgRecord into this DbgMarker, at the end of the list.
static LLVM_ABI 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.
LLVM_ABI void insertAfter(DbgRecord *InsertAfter)
LLVM_ABI void removeFromParent()
LLVM_ABI Function * getFunction()
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
LLVM_ABI BasicBlock * getBlock()
LLVM_ABI bool isEquivalentTo(const DbgRecord &R) const
Same as isIdenticalToWhenDefined but checks DebugLoc too.
simple_ilist< DbgRecord >::iterator self_iterator
DebugLoc getDebugLoc() const
LLVM_ABI DbgInfoIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgRecord back into an appropriate llvm.dbg.
Kind RecordKind
Subclass discriminator.
LLVM_ABI void deleteRecord()
Methods that dispatch to subclass implementations.
LLVM_ABI void insertBefore(DbgRecord *InsertBefore)
LLVM_ABI void eraseFromParent()
LLVM_ABI void moveBefore(DbgRecord *MoveBefore)
LLVM_ABI Module * getModule()
LLVM_ABI const Instruction * getInstruction() const
LLVM_ABI void moveAfter(DbgRecord *MoveAfter)
LLVM_ABI bool isIdenticalToWhenDefined(const DbgRecord &R) const
DbgMarker * Marker
Marker that this DbgRecord is linked into.
void setMarker(DbgMarker *M)
LLVM_ABI DbgRecord * clone() const
LLVM_ABI LLVMContext & getContext()
LLVM_ABI 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....
LLVM_ABI DbgVariableRecord(const DbgVariableIntrinsic *DVI)
Create a new DbgVariableRecord representing the intrinsic DVI, for example the assignment represented...
LocationType getType() const
LLVM_ABI bool isKillAddress() const
Check whether this kills the address component.
DbgRecordParamRef< DILocalVariable > Variable
LLVM_ABI bool isKillLocation() const
LLVM_ABI DIAssignID * getAssignID() const
LLVM_ABI std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
LLVM_ABI DbgVariableRecord * clone() const
LLVM_ABI void setKillLocation()
static LLVM_ABI 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 LLVM_ABI DbgVariableRecord * createDbgVariableRecord(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
static LLVM_ABI DbgVariableRecord * createDVRDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
LLVM_ABI Value * getAddress() const
void setExpression(DIExpression *NewExpr)
DIExpression * getExpression() const
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
LLVM_ABI void setKillAddress()
Kill the address component.
DILocalVariable * getVariable() const
LLVM_ABI 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.
LLVM_ABI void setAssignId(DIAssignID *New)
void setAddress(Value *V)
static LLVM_ABI DbgVariableRecord * createDVRAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
LLVM_ABI unsigned getNumVariableLocationOps() const
LLVM_ABI DbgVariableIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgVariableRecord back into a dbg.value intrinsic.
Metadata * getRawAddress() const
LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
LLVM_ABI std::optional< DbgVariableFragmentInfo > getFragment() const
static LLVM_ABI DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
DbgRecordParamRef< DIExpression > AddressExpression
DIExpression * getAddressExpression() const
LLVM_ABI 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...
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
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 LLVM_ABI 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.
LLVM_ABI 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.