LLVM 23.0.0git
DebugProgramInstruction.cpp
Go to the documentation of this file.
1//=====-- DebugProgramInstruction.cpp - Implement DbgRecords/DbgMarkers --====//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/IR/DIBuilder.h"
14
15using namespace llvm;
16
17namespace llvm {
18template <typename T>
20 : Ref(const_cast<T *>(Param)) {}
21template <typename T>
23 : Ref(const_cast<MDNode *>(Param)) {}
24
25template <typename T> T *DbgRecordParamRef<T>::get() const {
26 return cast<T>(Ref);
27}
28
32} // namespace llvm
33
36 DebugValueUser({DVI->getRawLocation(), nullptr, nullptr}),
37 Variable(DVI->getVariable()), Expression(DVI->getExpression()),
38 AddressExpression() {
39 switch (DVI->getIntrinsicID()) {
40 case Intrinsic::dbg_value:
41 Type = LocationType::Value;
42 break;
43 case Intrinsic::dbg_declare:
44 Type = LocationType::Declare;
45 break;
46 case Intrinsic::dbg_assign: {
47 Type = LocationType::Assign;
48 const DbgAssignIntrinsic *Assign =
49 static_cast<const DbgAssignIntrinsic *>(DVI);
50 resetDebugValue(1, Assign->getRawAddress());
51 AddressExpression = Assign->getAddressExpression();
52 setAssignId(Assign->getAssignID());
53 break;
54 }
55 default:
57 "Trying to create a DbgVariableRecord with an invalid intrinsic type!");
58 }
59}
60
66
68 DIExpression *Expr, const DILocation *DI,
70 : DbgRecord(ValueKind, DI), DebugValueUser({Location, nullptr, nullptr}),
71 Type(Type), Variable(DV), Expression(Expr) {}
72
75 DIAssignID *AssignID, Metadata *Address,
77 const DILocation *DI)
78 : DbgRecord(ValueKind, DI), DebugValueUser({Value, Address, AssignID}),
79 Type(LocationType::Assign), Variable(Variable), Expression(Expression),
80 AddressExpression(AddressExpression) {}
81
83 switch (RecordKind) {
84 case ValueKind:
85 delete cast<DbgVariableRecord>(this);
86 return;
87 case LabelKind:
88 delete cast<DbgLabelRecord>(this);
89 return;
90 }
91 llvm_unreachable("unsupported DbgRecord kind");
92}
93
94void DbgRecord::print(raw_ostream &O, bool IsForDebug) const {
95 switch (RecordKind) {
96 case ValueKind:
97 cast<DbgVariableRecord>(this)->print(O, IsForDebug);
98 return;
100 cast<DbgLabelRecord>(this)->print(O, IsForDebug);
101 return;
102 };
103 llvm_unreachable("unsupported DbgRecord kind");
104}
105
107 bool IsForDebug) const {
108 switch (RecordKind) {
109 case ValueKind:
110 cast<DbgVariableRecord>(this)->print(O, MST, IsForDebug);
111 return;
112 case LabelKind:
113 cast<DbgLabelRecord>(this)->print(O, MST, IsForDebug);
114 return;
115 };
116 llvm_unreachable("unsupported DbgRecord kind");
117}
118
120 if (RecordKind != R.RecordKind)
121 return false;
122 switch (RecordKind) {
123 case ValueKind:
124 return cast<DbgVariableRecord>(this)->isIdenticalToWhenDefined(
126 case LabelKind:
127 return cast<DbgLabelRecord>(this)->getLabel() ==
128 cast<DbgLabelRecord>(R).getLabel();
129 };
130 llvm_unreachable("unsupported DbgRecord kind");
131}
132
134 return getDebugLoc() == R.getDebugLoc() && isIdenticalToWhenDefined(R);
135}
136
139 switch (RecordKind) {
140 case ValueKind:
141 return cast<DbgVariableRecord>(this)->createDebugIntrinsic(M, InsertBefore);
142 case LabelKind:
143 return cast<DbgLabelRecord>(this)->createDebugIntrinsic(M, InsertBefore);
144 };
145 llvm_unreachable("unsupported DbgRecord kind");
146}
147
148DbgLabelRecord::DbgLabelRecord(MDNode *Label)
149 : DbgRecord(LabelKind, DebugLoc()), Label(Label) {
150 assert(Label && "Unexpected nullptr");
151 assert((isa<DILabel>(Label) || Label->isTemporary()) &&
152 "Label type must be or resolve to a DILabel");
153}
154DbgLabelRecord::DbgLabelRecord(DILabel *Label, DebugLoc DL)
155 : DbgRecord(LabelKind, DL), Label(Label) {
156 assert(Label && "Unexpected nullptr");
157}
158
160 return new DbgLabelRecord(Label);
161}
162
164 Metadata *Val, MDNode *Variable,
165 MDNode *Expression, MDNode *AssignID,
167 MDNode *AddressExpression)
168 : DbgRecord(ValueKind, DebugLoc()),
169 DebugValueUser({Val, Address, AssignID}), Type(Type), Variable(Variable),
170 Expression(Expression), AddressExpression(AddressExpression) {}
171
179
182 DIExpression *Expr,
183 const DILocation *DI) {
184 return new DbgVariableRecord(ValueAsMetadata::get(Location), DV, Expr, DI,
186}
187
189 Value *Location, DILocalVariable *DV, DIExpression *Expr,
190 const DILocation *DI, DbgVariableRecord &InsertBefore) {
191 auto *NewDbgVariableRecord = createDbgVariableRecord(Location, DV, Expr, DI);
192 NewDbgVariableRecord->insertBefore(&InsertBefore);
193 return NewDbgVariableRecord;
194}
195
203
206 DIExpression *Expr, const DILocation *DI,
207 DbgVariableRecord &InsertBefore) {
208 auto *NewDVRDeclare = createDVRDeclare(Address, DV, Expr, DI);
209 NewDVRDeclare->insertBefore(&InsertBefore);
210 return NewDVRDeclare;
211}
212
220
223 const DILocation *DI, DbgVariableRecord &InsertBefore) {
224 auto *NewDVRCoro = createDVRDeclareValue(Address, DV, Expr, DI);
225 NewDVRCoro->insertBefore(&InsertBefore);
226 return NewDVRCoro;
227}
228
237
239 Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable,
241 const DILocation *DI) {
242 auto *Link = LinkedInstr->getMetadata(LLVMContext::MD_DIAssignID);
243 assert(Link && "Linked instruction must have DIAssign metadata attached");
244 auto *NewDVRAssign = DbgVariableRecord::createDVRAssign(
247 LinkedInstr->getParent()->insertDbgRecordAfter(NewDVRAssign, LinkedInstr);
248 return NewDVRAssign;
249}
250
253 auto *MD = getRawLocation();
254 // If a Value has been deleted, the "location" for this DbgVariableRecord will
255 // be replaced by nullptr. Return an empty range.
256 if (!MD)
257 return {location_op_iterator(static_cast<ValueAsMetadata *>(nullptr)),
258 location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))};
259
260 // If operand is ValueAsMetadata, return a range over just that operand.
261 if (auto *VAM = dyn_cast<ValueAsMetadata>(MD))
262 return {location_op_iterator(VAM), location_op_iterator(VAM + 1)};
263
264 // If operand is DIArgList, return a range over its args.
265 if (auto *AL = dyn_cast<DIArgList>(MD))
266 return {location_op_iterator(AL->args_begin()),
267 location_op_iterator(AL->args_end())};
268
269 // Operand is an empty metadata tuple, so return empty iterator.
270 assert(cast<MDNode>(MD)->getNumOperands() == 0);
271 return {location_op_iterator(static_cast<ValueAsMetadata *>(nullptr)),
272 location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))};
273}
274
276 if (hasArgList())
277 return cast<DIArgList>(getRawLocation())->getArgs().size();
278 return 1;
279}
280
282 auto *MD = getRawLocation();
283 if (!MD)
284 return nullptr;
285
286 if (auto *AL = dyn_cast<DIArgList>(MD))
287 return AL->getArgs()[OpIdx]->getValue();
288 if (isa<MDNode>(MD))
289 return nullptr;
291 "Attempted to get location operand from DbgVariableRecord with none.");
292 auto *V = cast<ValueAsMetadata>(MD);
293 assert(OpIdx == 0 && "Operand Index must be 0 for a debug intrinsic with a "
294 "single location operand.");
295 return V->getValue();
296}
297
303
305 Value *NewValue,
306 bool AllowEmpty) {
307 assert(NewValue && "Values must be non-null");
308
309 bool DbgAssignAddrReplaced = isDbgAssign() && OldValue == getAddress();
310 if (DbgAssignAddrReplaced)
311 setAddress(NewValue);
312
313 auto Locations = location_ops();
314 auto OldIt = find(Locations, OldValue);
315 if (OldIt == Locations.end()) {
316 if (AllowEmpty || DbgAssignAddrReplaced)
317 return;
318 llvm_unreachable("OldValue must be a current location");
319 }
320
321 if (!hasArgList()) {
322 // Set our location to be the MAV wrapping the new Value.
324 ? cast<MetadataAsValue>(NewValue)->getMetadata()
325 : ValueAsMetadata::get(NewValue));
326 return;
327 }
328
329 // We must be referring to a DIArgList, produce a new operands vector with the
330 // old value replaced, generate a new DIArgList and set it as our location.
332 ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
333 for (auto *VMD : Locations)
334 MDs.push_back(VMD == *OldIt ? NewOperand : getAsMetadata(VMD));
336}
337
339 Value *NewValue) {
340 assert(OpIdx < getNumVariableLocationOps() && "Invalid Operand Index");
341
342 if (!hasArgList()) {
344 ? cast<MetadataAsValue>(NewValue)->getMetadata()
345 : ValueAsMetadata::get(NewValue));
346 return;
347 }
348
350 ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
351 for (unsigned Idx = 0; Idx < getNumVariableLocationOps(); ++Idx)
352 MDs.push_back(Idx == OpIdx ? NewOperand
354
356}
357
360 assert(NewExpr->hasAllLocationOps(getNumVariableLocationOps() +
361 NewValues.size()) &&
362 "NewExpr for debug variable intrinsic does not reference every "
363 "location operand.");
364 assert(!is_contained(NewValues, nullptr) && "New values must be non-null");
367 for (auto *VMD : location_ops())
368 MDs.push_back(getAsMetadata(VMD));
369 for (auto *VMD : NewValues)
370 MDs.push_back(getAsMetadata(VMD));
372}
373
375 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
376 // this set anymore.
377 SmallPtrSet<Value *, 4> RemovedValues;
378 for (Value *OldValue : location_ops()) {
379 if (!RemovedValues.insert(OldValue).second)
380 continue;
381 Value *Poison = PoisonValue::get(OldValue->getType());
383 }
384}
385
387 return (!hasArgList() && isa<MDNode>(getRawLocation())) ||
389 any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
390}
391
392std::optional<DbgVariableFragmentInfo> DbgVariableRecord::getFragment() const {
393 return getExpression()->getFragmentInfo();
394}
395
396std::optional<uint64_t> DbgVariableRecord::getFragmentSizeInBits() const {
397 if (auto Fragment = getExpression()->getFragmentInfo())
398 return Fragment->SizeInBits;
399 return getVariable()->getSizeInBits();
400}
401
403 switch (RecordKind) {
404 case ValueKind:
405 return cast<DbgVariableRecord>(this)->clone();
406 case LabelKind:
407 return cast<DbgLabelRecord>(this)->clone();
408 };
409 llvm_unreachable("unsupported DbgRecord kind");
410}
411
413 return new DbgVariableRecord(*this);
414}
415
416DbgLabelRecord *DbgLabelRecord::clone() const {
417 return new DbgLabelRecord(getLabel(), getDebugLoc());
418}
419
422 Instruction *InsertBefore) const {
423 [[maybe_unused]] DICompileUnit *Unit =
424 getDebugLoc()->getScope()->getSubprogram()->getUnit();
425 assert(M && Unit &&
426 "Cannot clone from BasicBlock that is not part of a Module or "
427 "DICompileUnit!");
428 LLVMContext &Context = getDebugLoc()->getContext();
429 Function *IntrinsicFn;
430
431 // Work out what sort of intrinsic we're going to produce.
432 switch (getType()) {
434 IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_declare);
435 break;
437 IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_value);
438 break;
440 IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_assign);
441 break;
444 llvm_unreachable("Invalid LocationType");
445 break;
448 "#dbg_declare_value should never be converted to an intrinsic");
449 }
450
451 // Create the intrinsic from this DbgVariableRecord's information, optionally
452 // insert into the target location.
455 "DbgVariableRecord's RawLocation should be non-null.");
456 if (isDbgAssign()) {
457 Value *AssignArgs[] = {
465 IntrinsicFn->getFunctionType(), IntrinsicFn, AssignArgs));
466 } else {
467 Value *Args[] = {MetadataAsValue::get(Context, getRawLocation()),
471 CallInst::Create(IntrinsicFn->getFunctionType(), IntrinsicFn, Args));
472 }
473 DVI->setTailCall();
474 DVI->setDebugLoc(getDebugLoc());
475 if (InsertBefore)
476 DVI->insertBefore(InsertBefore->getIterator());
477
478 return DVI;
479}
480
483 Instruction *InsertBefore) const {
484 auto *LabelFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_label);
485 Value *Args[] = {
488 CallInst::Create(LabelFn->getFunctionType(), LabelFn, Args));
489 DbgLabel->setTailCall();
490 DbgLabel->setDebugLoc(getDebugLoc());
491 if (InsertBefore)
492 DbgLabel->insertBefore(InsertBefore->getIterator());
493 return DbgLabel;
494}
495
497 auto *MD = getRawAddress();
498 if (auto *V = dyn_cast_or_null<ValueAsMetadata>(MD))
499 return V->getValue();
500
501 // When the value goes to null, it gets replaced by an empty MDNode.
502 assert((!MD || !cast<MDNode>(MD)->getNumOperands()) &&
503 "Expected an empty MDNode");
504 return nullptr;
505}
506
510
514
519
521 Value *Addr = getAddress();
522 return !Addr || isa<UndefValue>(Addr);
523}
524
526 return Marker->MarkedInstr;
527}
528
530 return Marker->MarkedInstr->getParent();
531}
532
533BasicBlock *DbgRecord::getParent() { return Marker->MarkedInstr->getParent(); }
534
535BasicBlock *DbgRecord::getBlock() { return Marker->getParent(); }
536
537const BasicBlock *DbgRecord::getBlock() const { return Marker->getParent(); }
538
540
542 return getBlock()->getParent();
543}
544
546
548 return getFunction()->getParent();
549}
550
552
554 return getBlock()->getContext();
555}
556
558 assert(!getMarker() &&
559 "Cannot insert a DbgRecord that is already has a DbgMarker!");
560 assert(InsertBefore->getMarker() &&
561 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
562 "DbgMarker!");
563 InsertBefore->getMarker()->insertDbgRecord(this, InsertBefore);
564}
566 assert(!getMarker() &&
567 "Cannot insert a DbgRecord that is already has a DbgMarker!");
568 assert(InsertAfter->getMarker() &&
569 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
570 "DbgMarker!");
571 InsertAfter->getMarker()->insertDbgRecordAfter(this, InsertAfter);
572}
573
575 assert(!getMarker() &&
576 "Cannot insert a DbgRecord that is already has a DbgMarker!");
577 assert(InsertBefore->getMarker() &&
578 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
579 "DbgMarker!");
580 InsertBefore->getMarker()->insertDbgRecord(this, &*InsertBefore);
581}
583 assert(!getMarker() &&
584 "Cannot insert a DbgRecord that is already has a DbgMarker!");
585 assert(InsertAfter->getMarker() &&
586 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
587 "DbgMarker!");
588 InsertAfter->getMarker()->insertDbgRecordAfter(this, &*InsertAfter);
589}
590
592 assert(getMarker() &&
593 "Canot move a DbgRecord that does not currently have a DbgMarker!");
595 insertBefore(MoveBefore);
596}
598 assert(getMarker() &&
599 "Canot move a DbgRecord that does not currently have a DbgMarker!");
601 insertAfter(MoveAfter);
602}
603
605 assert(getMarker() &&
606 "Canot move a DbgRecord that does not currently have a DbgMarker!");
608 insertBefore(MoveBefore);
609}
611 assert(getMarker() &&
612 "Canot move a DbgRecord that does not currently have a DbgMarker!");
614 insertAfter(MoveAfter);
615}
616
617///////////////////////////////////////////////////////////////////////////////
618
619// An empty, global, DbgMarker for the purpose of describing empty ranges of
620// DbgRecords.
622
624 while (!StoredDbgRecords.empty()) {
625 auto It = StoredDbgRecords.begin();
626 DbgRecord *DR = &*It;
627 StoredDbgRecords.erase(It);
628 DR->deleteRecord();
629 }
630}
631
633 assert(DR->getMarker() == this);
634 StoredDbgRecords.erase(DR->getIterator());
635 DR->deleteRecord();
636}
637
639 return MarkedInstr->getParent();
640}
641
642BasicBlock *DbgMarker::getParent() { return MarkedInstr->getParent(); }
643
645 // Are there any DbgRecords in this DbgMarker? If not, nothing to preserve.
647 if (StoredDbgRecords.empty()) {
649 Owner->DebugMarker = nullptr;
650 return;
651 }
652
653 // The attached DbgRecords need to be preserved; attach them to the next
654 // instruction. If there isn't a next instruction, put them on the
655 // "trailing" list.
656 DbgMarker *NextMarker = Owner->getParent()->getNextMarker(Owner);
657 if (NextMarker) {
658 NextMarker->absorbDebugValues(*this, true);
660 } else {
661 // We can avoid a deallocation -- just store this marker onto the next
662 // instruction. Unless we're at the end of the block, in which case this
663 // marker becomes the trailing marker of a degenerate block.
664 BasicBlock::iterator NextIt = std::next(Owner->getIterator());
665 if (NextIt == getParent()->end()) {
667 MarkedInstr = nullptr;
668 } else {
669 NextIt->DebugMarker = this;
670 MarkedInstr = &*NextIt;
671 }
672 }
673 Owner->DebugMarker = nullptr;
674}
675
677 MarkedInstr->DebugMarker = nullptr;
678 MarkedInstr = nullptr;
679}
680
682 if (MarkedInstr)
685 delete this;
686}
687
695
698 Marker = nullptr;
699}
700
705
706void DbgMarker::insertDbgRecord(DbgRecord *New, bool InsertAtHead) {
707 auto It = InsertAtHead ? StoredDbgRecords.begin() : StoredDbgRecords.end();
708 StoredDbgRecords.insert(It, *New);
709 New->setMarker(this);
710}
712 assert(InsertBefore->getMarker() == this &&
713 "DbgRecord 'InsertBefore' must be contained in this DbgMarker!");
714 StoredDbgRecords.insert(InsertBefore->getIterator(), *New);
715 New->setMarker(this);
716}
718 assert(InsertAfter->getMarker() == this &&
719 "DbgRecord 'InsertAfter' must be contained in this DbgMarker!");
720 StoredDbgRecords.insert(++(InsertAfter->getIterator()), *New);
721 New->setMarker(this);
722}
723
724void DbgMarker::absorbDebugValues(DbgMarker &Src, bool InsertAtHead) {
725 auto It = InsertAtHead ? StoredDbgRecords.begin() : StoredDbgRecords.end();
726 for (DbgRecord &DVR : Src.StoredDbgRecords)
727 DVR.setMarker(this);
728
729 StoredDbgRecords.splice(It, Src.StoredDbgRecords);
730}
731
734 bool InsertAtHead) {
735 for (DbgRecord &DR : Range)
736 DR.setMarker(this);
737
738 auto InsertPos =
739 (InsertAtHead) ? StoredDbgRecords.begin() : StoredDbgRecords.end();
740
741 StoredDbgRecords.splice(InsertPos, Src.StoredDbgRecords, Range.begin(),
742 Range.end());
743}
744
746 DbgMarker *From, std::optional<simple_ilist<DbgRecord>::iterator> from_here,
747 bool InsertAtHead) {
748 DbgRecord *First = nullptr;
749 // Work out what range of DbgRecords to clone: normally all the contents of
750 // the "From" marker, optionally we can start from the from_here position down
751 // to end().
752 auto Range =
753 make_range(From->StoredDbgRecords.begin(), From->StoredDbgRecords.end());
754 if (from_here.has_value())
755 Range = make_range(*from_here, From->StoredDbgRecords.end());
756
757 // Clone each DbgVariableRecord and insert into StoreDbgVariableRecords;
758 // optionally place them at the start or the end of the list.
759 auto Pos = (InsertAtHead) ? StoredDbgRecords.begin() : StoredDbgRecords.end();
760 for (DbgRecord &DR : Range) {
761 DbgRecord *New = DR.clone();
762 New->setMarker(this);
763 StoredDbgRecords.insert(Pos, *New);
764 if (!First)
765 First = New;
766 }
767
768 if (!First)
769 return {StoredDbgRecords.end(), StoredDbgRecords.end()};
770
771 if (InsertAtHead)
772 // If InsertAtHead is set, we cloned a range onto the front of of the
773 // StoredDbgRecords collection, return that range.
774 return {StoredDbgRecords.begin(), Pos};
775 else
776 // We inserted a block at the end, return that range.
777 return {First->getIterator(), StoredDbgRecords.end()};
778}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_EXPORT_TEMPLATE
Definition Compiler.h:215
static ManagedStatic< DebugCounterOwner > Owner
static ValueAsMetadata * getAsMetadata(Value *V)
#define T
MachineInstr unsigned OpIdx
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
LLVM Basic Block Representation.
Definition BasicBlock.h:62
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.
Definition BasicBlock.h:213
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
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)
DWARF expression.
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
static LLVM_ABI DbgLabelRecord * createUnresolvedDbgLabelRecord(MDNode *Label)
For use during parsing; creates a DbgLabelRecord from as-of-yet unresolved MDNodes.
LLVM_ABI DbgLabelRecord * clone() const
This class is used to track label information.
Definition DwarfDebug.h:290
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.
DbgMarker()=default
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.
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,...
DbgRecordParamRef< DIExpression > Expression
static LLVM_ABI DbgVariableRecord * createUnresolvedDbgVariableRecord(LocationType Type, Metadata *Val, MDNode *Variable, MDNode *Expression, MDNode *AssignID, Metadata *Address, MDNode *AddressExpression)
Used to create DbgVariableRecords during parsing, where some metadata references may still be unresol...
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 * createDVRDeclareValue(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
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
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
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.
A debug info location.
Definition DebugLoc.h:124
Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...
Definition Metadata.h:221
std::array< Metadata *, 3 > DebugValues
Definition Metadata.h:227
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Definition Metadata.h:282
Class representing an expression and its matching format.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition Function.h:211
Module * getParent()
Get the module that this global value is contained inside of...
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.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1080
LLVMContext & getContext() const
Definition Metadata.h:1244
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:110
Root of the metadata hierarchy.
Definition Metadata.h:64
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
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.
Definition Type.h:46
Value wrapper in the Metadata hierarchy.
Definition Metadata.h:459
static LLVM_ABI ValueAsMetadata * get(Value *V)
Definition Metadata.cpp:509
LLVM Value Representation.
Definition Value.h:75
const ParentTy * getParent() const
Definition ilist_node.h:34
self_iterator getIterator()
Definition ilist_node.h:123
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
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 * > OverloadTys={})
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.
Definition STLExtras.h:1764
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1745
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...
Definition Casting.h:547
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Definition ModRef.h:74
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1946