LLVM: lib/IR/DebugProgramInstruction.cpp Source File

LLVM 22.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
9#include "llvm/IR/DebugProgramInstruction.h"
10#include "llvm/IR/DIBuilder.h"
11#include "llvm/IR/DebugInfoMetadata.h"
12#include "llvm/IR/IntrinsicInst.h"
13#include "llvm/Support/Compiler.h"
14
15namespace llvm {
16
17template <typename T>
19 : Ref(const_cast<T *>(Param)) {}
20template <typename T>
22 : Ref(const_cast<MDNode *>(Param)) {}
23
24 template <typename T> T *DbgRecordParamRef<T>::get() const {
25 return cast<T>(Ref);
26}
27
28 template class LLVM_EXPORT_TEMPLATE DbgRecordParamRef<DIExpression>;
29 template class LLVM_EXPORT_TEMPLATE DbgRecordParamRef<DILabel>;
30 template class LLVM_EXPORT_TEMPLATE DbgRecordParamRef<DILocalVariable>;
31
34 DebugValueUser({DVI->getRawLocation(), nullptr, nullptr}),
35 Variable(DVI->getVariable()), Expression(DVI->getExpression()),
36 AddressExpression() {
37 switch (DVI->getIntrinsicID()) {
38 case Intrinsic::dbg_value:
39 Type = LocationType::Value;
40 break;
41 case Intrinsic::dbg_declare:
42 Type = LocationType::Declare;
43 break;
44 case Intrinsic::dbg_assign: {
45 Type = LocationType::Assign;
46 const DbgAssignIntrinsic *Assign =
47 static_cast<const DbgAssignIntrinsic *>(DVI);
48 resetDebugValue(1, Assign->getRawAddress());
49 AddressExpression = Assign->getAddressExpression();
50 setAssignId(Assign->getAssignID());
51 break;
52 }
53 default:
55 "Trying to create a DbgVariableRecord with an invalid intrinsic type!");
56 }
57}
58
64
66 DIExpression *Expr, const DILocation *DI,
68 : DbgRecord(ValueKind, DI), DebugValueUser({Location, nullptr, nullptr}),
69 Type(Type), Variable(DV), Expression(Expr) {}
70
73 DIAssignID *AssignID, Metadata *Address,
75 const DILocation *DI)
76 : DbgRecord(ValueKind, DI), DebugValueUser({Value, Address, AssignID}),
77 Type(LocationType::Assign), Variable(Variable), Expression(Expression),
78 AddressExpression(AddressExpression) {}
79
81 switch (RecordKind) {
82 case ValueKind:
83 delete cast<DbgVariableRecord>(this);
84 return;
85 case LabelKind:
86 delete cast<DbgLabelRecord>(this);
87 return;
88 }
89 llvm_unreachable("unsupported DbgRecord kind");
90}
91
92 void DbgRecord::print(raw_ostream &O, bool IsForDebug) const {
93 switch (RecordKind) {
94 case ValueKind:
95 cast<DbgVariableRecord>(this)->print(O, IsForDebug);
96 return;
97 case LabelKind:
98 cast<DbgLabelRecord>(this)->print(O, IsForDebug);
99 return;
100 };
101 llvm_unreachable("unsupported DbgRecord kind");
102}
103
105 bool IsForDebug) const {
106 switch (RecordKind) {
107 case ValueKind:
108 cast<DbgVariableRecord>(this)->print(O, MST, IsForDebug);
109 return;
110 case LabelKind:
111 cast<DbgLabelRecord>(this)->print(O, MST, IsForDebug);
112 return;
113 };
114 llvm_unreachable("unsupported DbgRecord kind");
115}
116
118 if (RecordKind != R.RecordKind)
119 return false;
120 switch (RecordKind) {
121 case ValueKind:
122 return cast<DbgVariableRecord>(this)->isIdenticalToWhenDefined(
124 case LabelKind:
125 return cast<DbgLabelRecord>(this)->getLabel() ==
126 cast<DbgLabelRecord>(R).getLabel();
127 };
128 llvm_unreachable("unsupported DbgRecord kind");
129}
130
132 return getDebugLoc() == R.getDebugLoc() && isIdenticalToWhenDefined(R);
133}
134
137 switch (RecordKind) {
138 case ValueKind:
139 return cast<DbgVariableRecord>(this)->createDebugIntrinsic(M, InsertBefore);
140 case LabelKind:
141 return cast<DbgLabelRecord>(this)->createDebugIntrinsic(M, InsertBefore);
142 };
143 llvm_unreachable("unsupported DbgRecord kind");
144}
145
146DbgLabelRecord::DbgLabelRecord(MDNode *Label, MDNode *DL)
147 : DbgRecord(LabelKind, DebugLoc(DL)), Label(Label) {
148 assert(Label && "Unexpected nullptr");
149 assert((isa<DILabel>(Label) || Label->isTemporary()) &&
150 "Label type must be or resolve to a DILabel");
151}
152 DbgLabelRecord::DbgLabelRecord(DILabel *Label, DebugLoc DL)
153 : DbgRecord(LabelKind, DL), Label(Label) {
154 assert(Label && "Unexpected nullptr");
155}
156
158 MDNode *DL) {
159 return new DbgLabelRecord(Label, DL);
160}
161
163 Metadata *Val, MDNode *Variable,
164 MDNode *Expression, MDNode *AssignID,
166 MDNode *AddressExpression, MDNode *DI)
167 : DbgRecord(ValueKind, DebugLoc(DI)),
168 DebugValueUser({Val, Address, AssignID}), Type(Type), Variable(Variable),
169 Expression(Expression), AddressExpression(AddressExpression) {}
170
178
181 DIExpression *Expr,
182 const DILocation *DI) {
183 return new DbgVariableRecord(ValueAsMetadata::get(Location), DV, Expr, DI,
185}
186
188 Value *Location, DILocalVariable *DV, DIExpression *Expr,
189 const DILocation *DI, DbgVariableRecord &InsertBefore) {
190 auto *NewDbgVariableRecord = createDbgVariableRecord(Location, DV, Expr, DI);
191 NewDbgVariableRecord->insertBefore(&InsertBefore);
192 return NewDbgVariableRecord;
193}
194
202
205 DIExpression *Expr, const DILocation *DI,
206 DbgVariableRecord &InsertBefore) {
207 auto *NewDVRDeclare = createDVRDeclare(Address, DV, Expr, DI);
208 NewDVRDeclare->insertBefore(&InsertBefore);
209 return NewDVRDeclare;
210}
211
220
222 Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable,
224 const DILocation *DI) {
225 auto *Link = LinkedInstr->getMetadata(LLVMContext::MD_DIAssignID);
226 assert(Link && "Linked instruction must have DIAssign metadata attached");
227 auto *NewDVRAssign = DbgVariableRecord::createDVRAssign(
230 LinkedInstr->getParent()->insertDbgRecordAfter(NewDVRAssign, LinkedInstr);
231 return NewDVRAssign;
232}
233
236 auto *MD = getRawLocation();
237 // If a Value has been deleted, the "location" for this DbgVariableRecord will
238 // be replaced by nullptr. Return an empty range.
239 if (!MD)
240 return {location_op_iterator(static_cast<ValueAsMetadata *>(nullptr)),
241 location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))};
242
243 // If operand is ValueAsMetadata, return a range over just that operand.
244 if (auto *VAM = dyn_cast<ValueAsMetadata>(MD))
245 return {location_op_iterator(VAM), location_op_iterator(VAM + 1)};
246
247 // If operand is DIArgList, return a range over its args.
248 if (auto *AL = dyn_cast<DIArgList>(MD))
249 return {location_op_iterator(AL->args_begin()),
250 location_op_iterator(AL->args_end())};
251
252 // Operand is an empty metadata tuple, so return empty iterator.
253 assert(cast<MDNode>(MD)->getNumOperands() == 0);
254 return {location_op_iterator(static_cast<ValueAsMetadata *>(nullptr)),
255 location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))};
256}
257
259 if (hasArgList())
260 return cast<DIArgList>(getRawLocation())->getArgs().size();
261 return 1;
262}
263
265 auto *MD = getRawLocation();
266 if (!MD)
267 return nullptr;
268
269 if (auto *AL = dyn_cast<DIArgList>(MD))
270 return AL->getArgs()[OpIdx]->getValue();
271 if (isa<MDNode>(MD))
272 return nullptr;
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();
279}
280
286
288 Value *NewValue,
289 bool AllowEmpty) {
290 assert(NewValue && "Values must be non-null");
291
292 bool DbgAssignAddrReplaced = isDbgAssign() && OldValue == getAddress();
293 if (DbgAssignAddrReplaced)
294 setAddress(NewValue);
295
296 auto Locations = location_ops();
297 auto OldIt = find(Locations, OldValue);
298 if (OldIt == Locations.end()) {
299 if (AllowEmpty || DbgAssignAddrReplaced)
300 return;
301 llvm_unreachable("OldValue must be a current location");
302 }
303
304 if (!hasArgList()) {
305 // Set our location to be the MAV wrapping the new Value.
307 ? cast<MetadataAsValue>(NewValue)->getMetadata()
308 : ValueAsMetadata::get(NewValue));
309 return;
310 }
311
312 // We must be referring to a DIArgList, produce a new operands vector with the
313 // old value replaced, generate a new DIArgList and set it as our location.
315 ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
316 for (auto *VMD : Locations)
317 MDs.push_back(VMD == *OldIt ? NewOperand : getAsMetadata(VMD));
319}
320
322 Value *NewValue) {
323 assert(OpIdx < getNumVariableLocationOps() && "Invalid Operand Index");
324
325 if (!hasArgList()) {
327 ? cast<MetadataAsValue>(NewValue)->getMetadata()
328 : ValueAsMetadata::get(NewValue));
329 return;
330 }
331
333 ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
334 for (unsigned Idx = 0; Idx < getNumVariableLocationOps(); ++Idx)
335 MDs.push_back(Idx == OpIdx ? NewOperand
337
339}
340
343 assert(NewExpr->hasAllLocationOps(getNumVariableLocationOps() +
344 NewValues.size()) &&
345 "NewExpr for debug variable intrinsic does not reference every "
346 "location operand.");
347 assert(!is_contained(NewValues, nullptr) && "New values must be non-null");
350 for (auto *VMD : location_ops())
351 MDs.push_back(getAsMetadata(VMD));
352 for (auto *VMD : NewValues)
353 MDs.push_back(getAsMetadata(VMD));
355}
356
358 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
359 // this set anymore.
360 SmallPtrSet<Value *, 4> RemovedValues;
361 for (Value *OldValue : location_ops()) {
362 if (!RemovedValues.insert(OldValue).second)
363 continue;
364 Value *Poison = PoisonValue::get(OldValue->getType());
366 }
367}
368
370 return (!hasArgList() && isa<MDNode>(getRawLocation())) ||
372 any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
373}
374
375 std::optional<DbgVariableFragmentInfo> DbgVariableRecord::getFragment() const {
376 return getExpression()->getFragmentInfo();
377}
378
379 std::optional<uint64_t> DbgVariableRecord::getFragmentSizeInBits() const {
380 if (auto Fragment = getExpression()->getFragmentInfo())
381 return Fragment->SizeInBits;
382 return getVariable()->getSizeInBits();
383}
384
386 switch (RecordKind) {
387 case ValueKind:
388 return cast<DbgVariableRecord>(this)->clone();
389 case LabelKind:
390 return cast<DbgLabelRecord>(this)->clone();
391 };
392 llvm_unreachable("unsupported DbgRecord kind");
393}
394
396 return new DbgVariableRecord(*this);
397}
398
399 DbgLabelRecord *DbgLabelRecord::clone() const {
400 return new DbgLabelRecord(getLabel(), getDebugLoc());
401}
402
405 Instruction *InsertBefore) const {
406 [[maybe_unused]] DICompileUnit *Unit =
407 getDebugLoc()->getScope()->getSubprogram()->getUnit();
408 assert(M && Unit &&
409 "Cannot clone from BasicBlock that is not part of a Module or "
410 "DICompileUnit!");
411 LLVMContext &Context = getDebugLoc()->getContext();
412 Function *IntrinsicFn;
413
414 // Work out what sort of intrinsic we're going to produce.
415 switch (getType()) {
417 IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_declare);
418 break;
420 IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_value);
421 break;
423 IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_assign);
424 break;
427 llvm_unreachable("Invalid LocationType");
428 }
429
430 // Create the intrinsic from this DbgVariableRecord's information, optionally
431 // insert into the target location.
434 "DbgVariableRecord's RawLocation should be non-null.");
435 if (isDbgAssign()) {
436 Value *AssignArgs[] = {
444 IntrinsicFn->getFunctionType(), IntrinsicFn, AssignArgs));
445 } else {
446 Value *Args[] = {MetadataAsValue::get(Context, getRawLocation()),
450 CallInst::Create(IntrinsicFn->getFunctionType(), IntrinsicFn, Args));
451 }
452 DVI->setTailCall();
453 DVI->setDebugLoc(getDebugLoc());
454 if (InsertBefore)
455 DVI->insertBefore(InsertBefore->getIterator());
456
457 return DVI;
458}
459
462 Instruction *InsertBefore) const {
463 auto *LabelFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_label);
464 Value *Args[] = {
467 CallInst::Create(LabelFn->getFunctionType(), LabelFn, Args));
468 DbgLabel->setTailCall();
469 DbgLabel->setDebugLoc(getDebugLoc());
470 if (InsertBefore)
471 DbgLabel->insertBefore(InsertBefore->getIterator());
472 return DbgLabel;
473}
474
476 auto *MD = getRawAddress();
477 if (auto *V = dyn_cast_or_null<ValueAsMetadata>(MD))
478 return V->getValue();
479
480 // When the value goes to null, it gets replaced by an empty MDNode.
481 assert((!MD || !cast<MDNode>(MD)->getNumOperands()) &&
482 "Expected an empty MDNode");
483 return nullptr;
484}
485
489
493
498
500 Value *Addr = getAddress();
501 return !Addr || isa<UndefValue>(Addr);
502}
503
505 return Marker->MarkedInstr;
506}
507
509 return Marker->MarkedInstr->getParent();
510}
511
512 BasicBlock *DbgRecord::getParent() { return Marker->MarkedInstr->getParent(); }
513
514 BasicBlock *DbgRecord::getBlock() { return Marker->getParent(); }
515
516 const BasicBlock *DbgRecord::getBlock() const { return Marker->getParent(); }
517
519
521 return getBlock()->getParent();
522}
523
525
527 return getFunction()->getParent();
528}
529
531
533 return getBlock()->getContext();
534}
535
536 void DbgRecord::insertBefore(DbgRecord *InsertBefore) {
537 assert(!getMarker() &&
538 "Cannot insert a DbgRecord that is already has a DbgMarker!");
539 assert(InsertBefore->getMarker() &&
540 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
541 "DbgMarker!");
542 InsertBefore->getMarker()->insertDbgRecord(this, InsertBefore);
543}
545 assert(!getMarker() &&
546 "Cannot insert a DbgRecord that is already has a DbgMarker!");
547 assert(InsertAfter->getMarker() &&
548 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
549 "DbgMarker!");
550 InsertAfter->getMarker()->insertDbgRecordAfter(this, InsertAfter);
551}
552
554 assert(!getMarker() &&
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 "
558 "DbgMarker!");
559 InsertBefore->getMarker()->insertDbgRecord(this, &*InsertBefore);
560}
562 assert(!getMarker() &&
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 "
566 "DbgMarker!");
567 InsertAfter->getMarker()->insertDbgRecordAfter(this, &*InsertAfter);
568}
569
571 assert(getMarker() &&
572 "Canot move a DbgRecord that does not currently have a DbgMarker!");
574 insertBefore(MoveBefore);
575}
577 assert(getMarker() &&
578 "Canot move a DbgRecord that does not currently have a DbgMarker!");
580 insertAfter(MoveAfter);
581}
582
584 assert(getMarker() &&
585 "Canot move a DbgRecord that does not currently have a DbgMarker!");
587 insertBefore(MoveBefore);
588}
590 assert(getMarker() &&
591 "Canot move a DbgRecord that does not currently have a DbgMarker!");
593 insertAfter(MoveAfter);
594}
595
596///////////////////////////////////////////////////////////////////////////////
597
598// An empty, global, DbgMarker for the purpose of describing empty ranges of
599// DbgRecords.
601
603 while (!StoredDbgRecords.empty()) {
604 auto It = StoredDbgRecords.begin();
605 DbgRecord *DR = &*It;
606 StoredDbgRecords.erase(It);
607 DR->deleteRecord();
608 }
609}
610
612 assert(DR->getMarker() == this);
613 StoredDbgRecords.erase(DR->getIterator());
614 DR->deleteRecord();
615}
616
618 return MarkedInstr->getParent();
619}
620
621 BasicBlock *DbgMarker::getParent() { return MarkedInstr->getParent(); }
622
624 // Are there any DbgRecords in this DbgMarker? If not, nothing to preserve.
625 Instruction *Owner = MarkedInstr;
626 if (StoredDbgRecords.empty()) {
628 Owner->DebugMarker = nullptr;
629 return;
630 }
631
632 // The attached DbgRecords need to be preserved; attach them to the next
633 // instruction. If there isn't a next instruction, put them on the
634 // "trailing" list.
635 DbgMarker *NextMarker = Owner->getParent()->getNextMarker(Owner);
636 if (NextMarker) {
637 NextMarker->absorbDebugValues(*this, true);
639 } else {
640 // We can avoid a deallocation -- just store this marker onto the next
641 // instruction. Unless we're at the end of the block, in which case this
642 // marker becomes the trailing marker of a degenerate block.
643 BasicBlock::iterator NextIt = std::next(Owner->getIterator());
644 if (NextIt == getParent()->end()) {
646 MarkedInstr = nullptr;
647 } else {
648 NextIt->DebugMarker = this;
649 MarkedInstr = &*NextIt;
650 }
651 }
652 Owner->DebugMarker = nullptr;
653}
654
656 MarkedInstr->DebugMarker = nullptr;
657 MarkedInstr = nullptr;
658}
659
661 if (MarkedInstr)
664 delete this;
665}
666
674
677 Marker = nullptr;
678}
679
684
685 void DbgMarker::insertDbgRecord(DbgRecord *New, bool InsertAtHead) {
686 auto It = InsertAtHead ? StoredDbgRecords.begin() : StoredDbgRecords.end();
687 StoredDbgRecords.insert(It, *New);
688 New->setMarker(this);
689}
691 assert(InsertBefore->getMarker() == this &&
692 "DbgRecord 'InsertBefore' must be contained in this DbgMarker!");
693 StoredDbgRecords.insert(InsertBefore->getIterator(), *New);
694 New->setMarker(this);
695}
697 assert(InsertAfter->getMarker() == this &&
698 "DbgRecord 'InsertAfter' must be contained in this DbgMarker!");
699 StoredDbgRecords.insert(++(InsertAfter->getIterator()), *New);
700 New->setMarker(this);
701}
702
703 void DbgMarker::absorbDebugValues(DbgMarker &Src, bool InsertAtHead) {
704 auto It = InsertAtHead ? StoredDbgRecords.begin() : StoredDbgRecords.end();
705 for (DbgRecord &DVR : Src.StoredDbgRecords)
706 DVR.setMarker(this);
707
708 StoredDbgRecords.splice(It, Src.StoredDbgRecords);
709}
710
713 bool InsertAtHead) {
714 for (DbgRecord &DR : Range)
715 DR.setMarker(this);
716
717 auto InsertPos =
718 (InsertAtHead) ? StoredDbgRecords.begin() : StoredDbgRecords.end();
719
720 StoredDbgRecords.splice(InsertPos, Src.StoredDbgRecords, Range.begin(),
721 Range.end());
722}
723
725 DbgMarker *From, std::optional<simple_ilist<DbgRecord>::iterator> from_here,
726 bool InsertAtHead) {
727 DbgRecord *First = nullptr;
728 // Work out what range of DbgRecords to clone: normally all the contents of
729 // the "From" marker, optionally we can start from the from_here position down
730 // to end().
731 auto Range =
732 make_range(From->StoredDbgRecords.begin(), From->StoredDbgRecords.end());
733 if (from_here.has_value())
734 Range = make_range(*from_here, From->StoredDbgRecords.end());
735
736 // Clone each DbgVariableRecord and insert into StoreDbgVariableRecords;
737 // optionally place them at the start or the end of the list.
738 auto Pos = (InsertAtHead) ? StoredDbgRecords.begin() : StoredDbgRecords.end();
739 for (DbgRecord &DR : Range) {
740 DbgRecord *New = DR.clone();
741 New->setMarker(this);
742 StoredDbgRecords.insert(Pos, *New);
743 if (!First)
744 First = New;
745 }
746
747 if (!First)
748 return {StoredDbgRecords.end(), StoredDbgRecords.end()};
749
750 if (InsertAtHead)
751 // If InsertAtHead is set, we cloned a range onto the front of of the
752 // StoredDbgRecords collection, return that range.
753 return {StoredDbgRecords.begin(), Pos};
754 else
755 // We inserted a block at the end, return that range.
756 return {First->getIterator(), StoredDbgRecords.end()};
757}
758
759} // end namespace llvm
@ Poison
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_EXPORT_TEMPLATE
Definition Compiler.h:215
T
#define T
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),...
Definition ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition ArrayRef.h:143
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.
Definition BasicBlock.cpp:131
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)
Assignment ID.
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.
Debug location.
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 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.
LLVM_ABI DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
This class is used to track label information.
Definition DwarfDebug.h:289
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.
DbgMarker()=default
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.
DbgRecord(Kind RecordKind, DebugLoc DL)
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
DbgRecordParamRef< DIExpression > Expression
LLVM_ABI bool isKillAddress() const
Check whether this kills the address component.
LocationType Type
Classification of the debug-info record that this DbgVariableRecord represents.
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
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)
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.
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:220
std::array< Metadata *, 3 > DebugValues
Definition Metadata.h:226
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Definition Metadata.h:281
Class representing an expression and its matching format.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition Function.h:209
Module * getParent()
Get the module that this global value is contained inside of...
Definition GlobalValue.h:663
DbgMarker * DebugMarker
Optional marker recording the position for debugging information that takes effect immediately before...
Definition Instruction.h:85
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.
Definition Instruction.h:428
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition Instruction.h:510
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1078
LLVMContext & getContext() const
Definition Metadata.h:1242
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:104
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:67
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition Constants.cpp:1888
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition SmallPtrSet.h:389
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition SmallPtrSet.h:527
void push_back(const T &Elt)
Definition SmallVector.h:417
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1203
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
Value wrapper in the Metadata hierarchy.
Definition Metadata.h:458
static LLVM_ABI ValueAsMetadata * get(Value *V)
Definition Metadata.cpp:503
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
Definition simple_ilist.h:95
#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.
Definition Intrinsics.cpp:723
This is an optimization pass for GlobalISel generic memory operations.
Definition AddressRanges.h:18
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:1751
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:1732
static ValueAsMetadata * getAsMetadata(Value *V)
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:71
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:1897

Generated on for LLVM by doxygen 1.14.0

AltStyle によって変換されたページ (->オリジナル) /