20 : Ref(const_cast<
T *>(Param)) {}
23 : Ref(const_cast<
MDNode *>(Param)) {}
37 Variable(DVI->getVariable()),
Expression(DVI->getExpression()),
39 switch (DVI->getIntrinsicID()) {
40 case Intrinsic::dbg_value:
41 Type = LocationType::Value;
43 case Intrinsic::dbg_declare:
44 Type = LocationType::Declare;
46 case Intrinsic::dbg_assign: {
47 Type = LocationType::Assign;
50 resetDebugValue(1, Assign->getRawAddress());
51 AddressExpression = Assign->getAddressExpression();
52 setAssignId(Assign->getAssignID());
57 "Trying to create a DbgVariableRecord with an invalid intrinsic type!");
80 AddressExpression(AddressExpression) {}
107 bool IsForDebug)
const {
150 assert(Label &&
"Unexpected nullptr");
152 "Label type must be or resolve to a DILabel");
156 assert(Label &&
"Unexpected nullptr");
161 return new DbgLabelRecord(Label,
DL);
193 NewDbgVariableRecord->insertBefore(&InsertBefore);
194 return NewDbgVariableRecord;
210 NewDVRDeclare->insertBefore(&InsertBefore);
211 return NewDVRDeclare;
227 auto *Link = LinkedInstr->
getMetadata(LLVMContext::MD_DIAssignID);
228 assert(Link &&
"Linked instruction must have DIAssign metadata attached");
232 LinkedInstr->
getParent()->insertDbgRecordAfter(NewDVRAssign, LinkedInstr);
272 return AL->getArgs()[
OpIdx]->getValue();
276 "Attempted to get location operand from DbgVariableRecord with none.");
278 assert(
OpIdx == 0 &&
"Operand Index must be 0 for a debug intrinsic with a "
279 "single location operand.");
280 return V->getValue();
292 assert(NewValue &&
"Values must be non-null");
295 if (DbgAssignAddrReplaced)
299 auto OldIt =
find(Locations, OldValue);
300 if (OldIt == Locations.end()) {
301 if (AllowEmpty || DbgAssignAddrReplaced)
318 for (
auto *VMD : Locations)
347 "NewExpr for debug variable intrinsic does not reference every "
348 "location operand.");
354 for (
auto *VMD : NewValues)
364 if (!RemovedValues.
insert(OldValue).second)
383 return Fragment->SizeInBits;
409 getDebugLoc()->getScope()->getSubprogram()->getUnit();
411 "Cannot clone from BasicBlock that is not part of a Module or "
436 "DbgVariableRecord's RawLocation should be non-null.");
438 Value *AssignArgs[] = {
480 return V->getValue();
484 "Expected an empty MDNode");
507 return Marker->MarkedInstr;
511 return Marker->MarkedInstr->getParent();
540 "Cannot insert a DbgRecord that is already has a DbgMarker!");
542 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
548 "Cannot insert a DbgRecord that is already has a DbgMarker!");
550 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
557 "Cannot insert a DbgRecord that is already has a DbgMarker!");
558 assert(InsertBefore->getMarker() &&
559 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
561 InsertBefore->getMarker()->insertDbgRecord(
this, &*InsertBefore);
565 "Cannot insert a DbgRecord that is already has a DbgMarker!");
566 assert(InsertAfter->getMarker() &&
567 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
569 InsertAfter->getMarker()->insertDbgRecordAfter(
this, &*InsertAfter);
574 "Canot move a DbgRecord that does not currently have a DbgMarker!");
580 "Canot move a DbgRecord that does not currently have a DbgMarker!");
587 "Canot move a DbgRecord that does not currently have a DbgMarker!");
593 "Canot move a DbgRecord that does not currently have a DbgMarker!");
650 NextIt->DebugMarker =
this;
690 New->setMarker(
this);
694 "DbgRecord 'InsertBefore' must be contained in this DbgMarker!");
696 New->setMarker(
this);
700 "DbgRecord 'InsertAfter' must be contained in this DbgMarker!");
702 New->setMarker(
this);
707 for (
DbgRecord &DVR : Src.StoredDbgRecords)
735 if (from_here.has_value())
743 New->setMarker(
this);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_EXPORT_TEMPLATE
static ValueAsMetadata * getAsMetadata(Value *V)
MachineInstr unsigned OpIdx
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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.
LLVM_ABI DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
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
This class is used to track label information.
Per-instruction record of debug-info.
LLVM_ABI void insertDbgRecordAfter(DbgRecord *New, DbgRecord *InsertAfter)
Insert a DbgRecord after a DbgRecord contained within this marker.
LLVM_ABI void removeFromParent()
LLVM_ABI void dropOneDbgRecord(DbgRecord *DR)
Erase a single DbgRecord from this marker.
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
LLVM_ABI void eraseFromParent()
static LLVM_ABI DbgMarker EmptyDbgMarker
We generally act like all llvm Instructions have a range of DbgRecords attached to them,...
LLVM_ABI iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange()
Produce a range over all the DbgRecords in this Marker.
LLVM_ABI const BasicBlock * getParent() const
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 insertDbgRecord(DbgRecord *New, bool InsertAtHead)
Insert a DbgRecord into this DbgMarker, at the end of the list.
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
LLVM_ABI void absorbDebugValues(DbgMarker &Src, bool InsertAtHead)
Transfer any DbgRecords from Src into this DbgMarker.
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 dropDbgRecords()
Erase all DbgRecords in this DbgMarker.
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 LLVMContext & getContext()
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
LLVM_ABI void insertAfter(DbgRecord *InsertAfter)
LLVM_ABI void moveAfter(DbgRecord *MoveAfter)
LLVM_ABI void insertBefore(DbgRecord *InsertBefore)
LLVM_ABI bool isEquivalentTo(const DbgRecord &R) const
Same as isIdenticalToWhenDefined but checks DebugLoc too.
LLVM_ABI void removeFromParent()
DbgRecord(Kind RecordKind, DebugLoc DL)
LLVM_ABI void moveBefore(DbgRecord *MoveBefore)
simple_ilist< DbgRecord >::iterator self_iterator
DebugLoc getDebugLoc() const
LLVM_ABI void eraseFromParent()
Kind RecordKind
Subclass discriminator.
LLVM_ABI bool isIdenticalToWhenDefined(const DbgRecord &R) const
LLVM_ABI DbgRecord * clone() const
LLVM_ABI void deleteRecord()
Methods that dispatch to subclass implementations.
LLVM_ABI Module * getModule()
LLVM_ABI BasicBlock * getBlock()
DbgMarker * Marker
Marker that this DbgRecord is linked into.
void setMarker(DbgMarker *M)
LLVM_ABI DbgInfoIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgRecord back into an appropriate llvm.dbg.
LLVM_ABI const BasicBlock * getParent() const
LLVM_ABI const Instruction * getInstruction() const
LLVM_ABI Function * getFunction()
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 void setKillAddress()
Kill the address component.
LLVM_ABI bool isKillLocation() const
LLVM_ABI std::optional< DbgVariableFragmentInfo > getFragment() const
LLVM_ABI void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
LocationType getType() const
DbgRecordParamRef< DIExpression > Expression
LLVM_ABI Value * getAddress() const
LocationType Type
Classification of the debug-info record that this DbgVariableRecord represents.
LLVM_ABI bool isKillAddress() const
Check whether this kills the address component.
DbgRecordParamRef< DILocalVariable > Variable
LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
LLVM_ABI unsigned getNumVariableLocationOps() const
LLVM_ABI DbgVariableRecord * clone() const
LLVM_ABI DIAssignID * getAssignID() const
static LLVM_ABI DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
LLVM_ABI void setAssignId(DIAssignID *New)
static LLVM_ABI DbgVariableRecord * createDVRAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
void setRawLocation(Metadata *NewLocation)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
void setExpression(DIExpression *NewExpr)
DIExpression * getExpression() const
static LLVM_ABI DbgVariableRecord * createDVRDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
static LLVM_ABI DbgVariableRecord * createDbgVariableRecord(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
LLVM_ABI std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
DILocalVariable * getVariable() const
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...
LLVM_ABI void setKillLocation()
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
void setAddress(Value *V)
Metadata * getRawAddress() const
friend class DebugValueUser
LLVM_ABI DbgVariableRecord(const DbgVariableIntrinsic *DVI)
Create a new DbgVariableRecord representing the intrinsic DVI, for example the assignment represented...
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
DbgRecordParamRef< DIExpression > AddressExpression
DIExpression * getAddressExpression() const
LLVM_ABI DbgVariableIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgVariableRecord back into a dbg.value 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.
ilist_select_iterator_type< OptionsT, false, false > 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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto dyn_cast_or_null(const Y &Val)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.