LLVM 19.0.0git
DebugProgramInstruction.cpp
Go to the documentation of this file.
1//======-- DebugProgramInstruction.cpp - Implement DPValues/DPMarkers --======//
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
11#include "llvm/IR/DIBuilder.h"
13
14namespace llvm {
15
17 : DbgRecord(ValueKind, DVI->getDebugLoc()),
18 DebugValueUser({DVI->getRawLocation(), nullptr, nullptr}),
19 Variable(DVI->getVariable()), Expression(DVI->getExpression()),
20 AddressExpression(nullptr) {
21 switch (DVI->getIntrinsicID()) {
22 case Intrinsic::dbg_value:
24 break;
25 case Intrinsic::dbg_declare:
27 break;
28 case Intrinsic::dbg_assign: {
31 static_cast<const DbgAssignIntrinsic *>(DVI);
32 resetDebugValue(1, Assign->getRawAddress());
33 AddressExpression = Assign->getAddressExpression();
34 setAssignId(Assign->getAssignID());
35 break;
36 }
37 default:
39 "Trying to create a DPValue with an invalid intrinsic type!");
40 }
41}
42
44 : DbgRecord(ValueKind, DPV.getDebugLoc()), DebugValueUser(DPV.DebugValues),
45 Type(DPV.getType()), Variable(DPV.getVariable()),
46 Expression(DPV.getExpression()),
47 AddressExpression(DPV.AddressExpression) {}
48
50 const DILocation *DI, LocationType Type)
51 : DbgRecord(ValueKind, DI), DebugValueUser({Location, nullptr, nullptr}),
52 Type(Type), Variable(DV), Expression(Expr) {}
53
56 Metadata *Address, DIExpression *AddressExpression,
57 const DILocation *DI)
58 : DbgRecord(ValueKind, DI), DebugValueUser({Value, Address, AssignID}),
59 Type(LocationType::Assign), Variable(Variable), Expression(Expression),
60 AddressExpression(AddressExpression) {}
61
63 switch (RecordKind) {
64 case ValueKind:
65 delete cast<DPValue>(this);
66 return;
67 case LabelKind:
68 delete cast<DPLabel>(this);
69 return;
70 }
71 llvm_unreachable("unsupported DbgRecord kind");
72}
73
74void DbgRecord::print(raw_ostream &O, bool IsForDebug) const {
75 switch (RecordKind) {
76 case ValueKind:
77 cast<DPValue>(this)->print(O, IsForDebug);
78 return;
79 case LabelKind:
80 cast<DPLabel>(this)->print(O, IsForDebug);
81 return;
82 };
83 llvm_unreachable("unsupported DbgRecord kind");
84}
85
87 bool IsForDebug) const {
88 switch (RecordKind) {
89 case ValueKind:
90 cast<DPValue>(this)->print(O, MST, IsForDebug);
91 return;
92 case LabelKind:
93 cast<DPLabel>(this)->print(O, MST, IsForDebug);
94 return;
95 };
96 llvm_unreachable("unsupported DbgRecord kind");
97}
98
100 if (RecordKind != R.RecordKind)
101 return false;
102 switch (RecordKind) {
103 case ValueKind:
104 return cast<DPValue>(this)->isIdenticalToWhenDefined(*cast<DPValue>(&R));
105 case LabelKind:
106 return cast<DPLabel>(this)->getLabel() == cast<DPLabel>(R).getLabel();
107 };
108 llvm_unreachable("unsupported DbgRecord kind");
109}
110
112 return getDebugLoc() == R.getDebugLoc() && isIdenticalToWhenDefined(R);
113}
114
117 switch (RecordKind) {
118 case ValueKind:
119 return cast<DPValue>(this)->createDebugIntrinsic(M, InsertBefore);
120 case LabelKind:
121 return cast<DPLabel>(this)->createDebugIntrinsic(M, InsertBefore);
122 };
123 llvm_unreachable("unsupported DbgRecord kind");
124}
125
127 DIExpression *Expr, const DILocation *DI) {
128 return new DPValue(ValueAsMetadata::get(Location), DV, Expr, DI,
130}
131
133 DIExpression *Expr, const DILocation *DI,
134 DPValue &InsertBefore) {
135 auto *NewDPValue = createDPValue(Location, DV, Expr, DI);
136 NewDPValue->insertBefore(&InsertBefore);
137 return NewDPValue;
138}
139
141 DIExpression *Expr, const DILocation *DI) {
142 return new DPValue(ValueAsMetadata::get(Address), DV, Expr, DI,
144}
145
147 DIExpression *Expr, const DILocation *DI,
148 DPValue &InsertBefore) {
149 auto *NewDPVDeclare = createDPVDeclare(Address, DV, Expr, DI);
150 NewDPVDeclare->insertBefore(&InsertBefore);
151 return NewDPVDeclare;
152}
153
156 DIAssignID *AssignID, Value *Address,
157 DIExpression *AddressExpression,
158 const DILocation *DI) {
159 return new DPValue(ValueAsMetadata::get(Val), Variable, Expression, AssignID,
161}
162
164 DILocalVariable *Variable,
166 Value *Address,
167 DIExpression *AddressExpression,
168 const DILocation *DI) {
169 auto *Link = LinkedInstr->getMetadata(LLVMContext::MD_DIAssignID);
170 assert(Link && "Linked instruction must have DIAssign metadata attached");
171 auto *NewDPVAssign = DPValue::createDPVAssign(Val, Variable, Expression,
172 cast<DIAssignID>(Link), Address,
174 LinkedInstr->getParent()->insertDPValueAfter(NewDPVAssign, LinkedInstr);
175 return NewDPVAssign;
176}
177
179
181 auto *MD = getRawLocation();
182 // If a Value has been deleted, the "location" for this DPValue will be
183 // replaced by nullptr. Return an empty range.
184 if (!MD)
185 return {location_op_iterator(static_cast<ValueAsMetadata *>(nullptr)),
186 location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))};
187
188 // If operand is ValueAsMetadata, return a range over just that operand.
189 if (auto *VAM = dyn_cast<ValueAsMetadata>(MD))
190 return {location_op_iterator(VAM), location_op_iterator(VAM + 1)};
191
192 // If operand is DIArgList, return a range over its args.
193 if (auto *AL = dyn_cast<DIArgList>(MD))
194 return {location_op_iterator(AL->args_begin()),
195 location_op_iterator(AL->args_end())};
196
197 // Operand is an empty metadata tuple, so return empty iterator.
198 assert(cast<MDNode>(MD)->getNumOperands() == 0);
199 return {location_op_iterator(static_cast<ValueAsMetadata *>(nullptr)),
200 location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))};
201}
202
204 if (hasArgList())
205 return cast<DIArgList>(getRawLocation())->getArgs().size();
206 return 1;
207}
208
209Value *DPValue::getVariableLocationOp(unsigned OpIdx) const {
210 auto *MD = getRawLocation();
211 if (!MD)
212 return nullptr;
213
214 if (auto *AL = dyn_cast<DIArgList>(MD))
215 return AL->getArgs()[OpIdx]->getValue();
216 if (isa<MDNode>(MD))
217 return nullptr;
218 assert(isa<ValueAsMetadata>(MD) &&
219 "Attempted to get location operand from DPValue with none.");
220 auto *V = cast<ValueAsMetadata>(MD);
221 assert(OpIdx == 0 && "Operand Index must be 0 for a debug intrinsic with a "
222 "single location operand.");
223 return V->getValue();
224}
225
227 return isa<MetadataAsValue>(V) ? dyn_cast<ValueAsMetadata>(
228 cast<MetadataAsValue>(V)->getMetadata())
230}
231
233 bool AllowEmpty) {
234 assert(NewValue && "Values must be non-null");
235
236 bool DbgAssignAddrReplaced = isDbgAssign() && OldValue == getAddress();
237 if (DbgAssignAddrReplaced)
238 setAddress(NewValue);
239
240 auto Locations = location_ops();
241 auto OldIt = find(Locations, OldValue);
242 if (OldIt == Locations.end()) {
243 if (AllowEmpty || DbgAssignAddrReplaced)
244 return;
245 llvm_unreachable("OldValue must be a current location");
246 }
247
248 if (!hasArgList()) {
249 // Set our location to be the MAV wrapping the new Value.
250 setRawLocation(isa<MetadataAsValue>(NewValue)
251 ? cast<MetadataAsValue>(NewValue)->getMetadata()
252 : ValueAsMetadata::get(NewValue));
253 return;
254 }
255
256 // We must be referring to a DIArgList, produce a new operands vector with the
257 // old value replaced, generate a new DIArgList and set it as our location.
259 ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
260 for (auto *VMD : Locations)
261 MDs.push_back(VMD == *OldIt ? NewOperand : getAsMetadata(VMD));
263}
264
265void DPValue::replaceVariableLocationOp(unsigned OpIdx, Value *NewValue) {
266 assert(OpIdx < getNumVariableLocationOps() && "Invalid Operand Index");
267
268 if (!hasArgList()) {
269 setRawLocation(isa<MetadataAsValue>(NewValue)
270 ? cast<MetadataAsValue>(NewValue)->getMetadata()
271 : ValueAsMetadata::get(NewValue));
272 return;
273 }
274
276 ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
277 for (unsigned Idx = 0; Idx < getNumVariableLocationOps(); ++Idx)
278 MDs.push_back(Idx == OpIdx ? NewOperand
280
282}
283
286 assert(NewExpr->hasAllLocationOps(getNumVariableLocationOps() +
287 NewValues.size()) &&
288 "NewExpr for debug variable intrinsic does not reference every "
289 "location operand.");
290 assert(!is_contained(NewValues, nullptr) && "New values must be non-null");
293 for (auto *VMD : location_ops())
294 MDs.push_back(getAsMetadata(VMD));
295 for (auto *VMD : NewValues)
296 MDs.push_back(getAsMetadata(VMD));
298}
299
301 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
302 // this set anymore.
303 SmallPtrSet<Value *, 4> RemovedValues;
304 for (Value *OldValue : location_ops()) {
305 if (!RemovedValues.insert(OldValue).second)
306 continue;
307 Value *Poison = PoisonValue::get(OldValue->getType());
308 replaceVariableLocationOp(OldValue, Poison);
309 }
310}
311
313 return (getNumVariableLocationOps() == 0 &&
314 !getExpression()->isComplex()) ||
315 any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
316}
317
319 return cast<DILocalVariable>(Variable.get());
320}
321
322std::optional<uint64_t> DPValue::getFragmentSizeInBits() const {
323 if (auto Fragment = getExpression()->getFragmentInfo())
324 return Fragment->SizeInBits;
325 return getVariable()->getSizeInBits();
326}
327
329 switch (RecordKind) {
330 case ValueKind:
331 return cast<DPValue>(this)->clone();
332 case LabelKind:
333 return cast<DPLabel>(this)->clone();
334 };
335 llvm_unreachable("unsupported DbgRecord kind");
336}
337
338DPValue *DPValue::clone() const { return new DPValue(*this); }
339
340DPLabel *DPLabel::clone() const { return new DPLabel(Label, getDebugLoc()); }
341
344 [[maybe_unused]] DICompileUnit *Unit =
345 getDebugLoc().get()->getScope()->getSubprogram()->getUnit();
346 assert(M && Unit &&
347 "Cannot clone from BasicBlock that is not part of a Module or "
348 "DICompileUnit!");
350 Function *IntrinsicFn;
351
352 // Work out what sort of intrinsic we're going to produce.
353 switch (getType()) {
355 IntrinsicFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_declare);
356 break;
358 IntrinsicFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_value);
359 break;
361 IntrinsicFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_assign);
362 break;
365 llvm_unreachable("Invalid LocationType");
366 }
367
368 // Create the intrinsic from this DPValue's information, optionally insert
369 // into the target location.
371 assert(getRawLocation() && "DPValue's RawLocation should be non-null.");
372 if (isDbgAssign()) {
373 Value *AssignArgs[] = {
380 DVI = cast<DbgVariableIntrinsic>(CallInst::Create(
381 IntrinsicFn->getFunctionType(), IntrinsicFn, AssignArgs));
382 } else {
386 DVI = cast<DbgVariableIntrinsic>(
387 CallInst::Create(IntrinsicFn->getFunctionType(), IntrinsicFn, Args));
388 }
389 DVI->setTailCall();
390 DVI->setDebugLoc(getDebugLoc());
391 if (InsertBefore)
392 DVI->insertBefore(InsertBefore);
393
394 return DVI;
395}
396
398 Instruction *InsertBefore) const {
399 auto *LabelFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_label);
400 Value *Args[] = {
402 DbgLabelInst *DbgLabel = cast<DbgLabelInst>(
403 CallInst::Create(LabelFn->getFunctionType(), LabelFn, Args));
404 DbgLabel->setTailCall();
405 DbgLabel->setDebugLoc(getDebugLoc());
406 if (InsertBefore)
407 DbgLabel->insertBefore(InsertBefore);
408 return DbgLabel;
409}
410
412 auto *MD = getRawAddress();
413 if (auto *V = dyn_cast<ValueAsMetadata>(MD))
414 return V->getValue();
415
416 // When the value goes to null, it gets replaced by an empty MDNode.
417 assert(!cast<MDNode>(MD)->getNumOperands() && "Expected an empty MDNode");
418 return nullptr;
419}
420
422 return cast<DIAssignID>(DebugValues[2]);
423}
424
426
430}
431
433 Value *Addr = getAddress();
434 return !Addr || isa<UndefValue>(Addr);
435}
436
438 return Marker->MarkedInstr;
439}
440
442 return Marker->MarkedInstr->getParent();
443}
444
446
448
449const BasicBlock *DbgRecord::getBlock() const { return Marker->getParent(); }
450
452
454 return getBlock()->getParent();
455}
456
458
460 return getFunction()->getParent();
461}
462
464
466 return getBlock()->getContext();
467}
468
470 assert(!getMarker() &&
471 "Cannot insert a DbgRecord that is already has a DPMarker!");
472 assert(InsertBefore->getMarker() &&
473 "Cannot insert a DbgRecord before a DbgRecord that does not have a "
474 "DPMarker!");
475 InsertBefore->getMarker()->insertDPValue(this, InsertBefore);
476}
478 assert(!getMarker() &&
479 "Cannot insert a DbgRecord that is already has a DPMarker!");
480 assert(InsertAfter->getMarker() &&
481 "Cannot insert a DbgRecord after a DbgRecord that does not have a "
482 "DPMarker!");
483 InsertAfter->getMarker()->insertDPValueAfter(this, InsertAfter);
484}
486 assert(getMarker() &&
487 "Canot move a DbgRecord that does not currently have a DPMarker!");
489 insertBefore(MoveBefore);
490}
492 assert(getMarker() &&
493 "Canot move a DbgRecord that does not currently have a DPMarker!");
495 insertAfter(MoveAfter);
496}
497
498///////////////////////////////////////////////////////////////////////////////
499
500// An empty, global, DPMarker for the purpose of describing empty ranges of
501// DPValues.
503
505 while (!StoredDPValues.empty()) {
506 auto It = StoredDPValues.begin();
507 DbgRecord *DR = &*It;
508 StoredDPValues.erase(It);
509 DR->deleteRecord();
510 }
511}
512
514 assert(DR->getMarker() == this);
515 StoredDPValues.erase(DR->getIterator());
516 DR->deleteRecord();
517}
518
520 return MarkedInstr->getParent();
521}
522
524
526 // Are there any DPValues in this DPMarker? If not, nothing to preserve.
527 Instruction *Owner = MarkedInstr;
528 if (StoredDPValues.empty()) {
530 Owner->DbgMarker = nullptr;
531 return;
532 }
533
534 // The attached DPValues need to be preserved; attach them to the next
535 // instruction. If there isn't a next instruction, put them on the
536 // "trailing" list.
537 DPMarker *NextMarker = Owner->getParent()->getNextMarker(Owner);
538 if (NextMarker) {
539 NextMarker->absorbDebugValues(*this, true);
541 } else {
542 // We can avoid a deallocation -- just store this marker onto the next
543 // instruction. Unless we're at the end of the block, in which case this
544 // marker becomes the trailing marker of a degenerate block.
545 BasicBlock::iterator NextIt = std::next(Owner->getIterator());
546 if (NextIt == getParent()->end()) {
548 MarkedInstr = nullptr;
549 } else {
550 NextIt->DbgMarker = this;
551 MarkedInstr = &*NextIt;
552 }
553 }
554 Owner->DbgMarker = nullptr;
555}
556
558 MarkedInstr->DbgMarker = nullptr;
559 MarkedInstr = nullptr;
560}
561
563 if (MarkedInstr)
566 delete this;
567}
568
570 return make_range(StoredDPValues.begin(), StoredDPValues.end());
571}
574 return make_range(StoredDPValues.begin(), StoredDPValues.end());
575}
576
579 Marker = nullptr;
580}
581
584 deleteRecord();
585}
586
587void DPMarker::insertDPValue(DbgRecord *New, bool InsertAtHead) {
588 auto It = InsertAtHead ? StoredDPValues.begin() : StoredDPValues.end();
589 StoredDPValues.insert(It, *New);
590 New->setMarker(this);
591}
592void DPMarker::insertDPValue(DbgRecord *New, DbgRecord *InsertBefore) {
593 assert(InsertBefore->getMarker() == this &&
594 "DPValue 'InsertBefore' must be contained in this DPMarker!");
595 StoredDPValues.insert(InsertBefore->getIterator(), *New);
596 New->setMarker(this);
597}
599 assert(InsertAfter->getMarker() == this &&
600 "DPValue 'InsertAfter' must be contained in this DPMarker!");
601 StoredDPValues.insert(++(InsertAfter->getIterator()), *New);
602 New->setMarker(this);
603}
604
605void DPMarker::absorbDebugValues(DPMarker &Src, bool InsertAtHead) {
606 auto It = InsertAtHead ? StoredDPValues.begin() : StoredDPValues.end();
607 for (DbgRecord &DPV : Src.StoredDPValues)
608 DPV.setMarker(this);
609
610 StoredDPValues.splice(It, Src.StoredDPValues);
611}
612
614 DPMarker &Src, bool InsertAtHead) {
615 for (DbgRecord &DR : Range)
616 DR.setMarker(this);
617
618 auto InsertPos =
619 (InsertAtHead) ? StoredDPValues.begin() : StoredDPValues.end();
620
621 StoredDPValues.splice(InsertPos, Src.StoredDPValues, Range.begin(),
622 Range.end());
623}
624
626 DPMarker *From, std::optional<simple_ilist<DbgRecord>::iterator> from_here,
627 bool InsertAtHead) {
628 DbgRecord *First = nullptr;
629 // Work out what range of DPValues to clone: normally all the contents of the
630 // "From" marker, optionally we can start from the from_here position down to
631 // end().
632 auto Range =
633 make_range(From->StoredDPValues.begin(), From->StoredDPValues.end());
634 if (from_here.has_value())
635 Range = make_range(*from_here, From->StoredDPValues.end());
636
637 // Clone each DPValue and insert into StoreDPValues; optionally place them at
638 // the start or the end of the list.
639 auto Pos = (InsertAtHead) ? StoredDPValues.begin() : StoredDPValues.end();
640 for (DbgRecord &DR : Range) {
641 DbgRecord *New = DR.clone();
642 New->setMarker(this);
643 StoredDPValues.insert(Pos, *New);
644 if (!First)
645 First = New;
646 }
647
648 if (!First)
649 return {StoredDPValues.end(), StoredDPValues.end()};
650
651 if (InsertAtHead)
652 // If InsertAtHead is set, we cloned a range onto the front of of the
653 // StoredDPValues collection, return that range.
654 return {StoredDPValues.begin(), Pos};
655 else
656 // We inserted a block at the end, return that range.
657 return {First->getIterator(), StoredDPValues.end()};
658}
659
660} // end namespace llvm
BlockVerifier::State From
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint64_t Addr
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.
LLVMContext & Context
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static SymbolRef::Type getType(const Symbol *Sym)
Definition: TapiFile.cpp:40
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:165
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
void insertDPValueAfter(DbgRecord *DPV, Instruction *I)
Insert a DPValue into a block at the position given by I.
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:205
void setTrailingDPValues(DPMarker *M)
Record that the collection of DPValues in M "trails" after the last instruction of this block.
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:164
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition: BasicBlock.cpp:150
DPMarker * getNextMarker(Instruction *I)
Return the DPMarker for the position that comes after I.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr, BasicBlock::iterator InsertBefore)
void setTailCall(bool IsTc=true)
static DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
Assignment ID.
DWARF expression.
Debug location.
std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
Records a position in IR for a source label (DILabel).
DbgLabelInst * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
DPLabel * clone() const
DILabel * getLabel() const
Per-instruction record of debug-info.
void dropOneDbgValue(DbgRecord *DR)
Erase a single DbgRecord from this marker.
const BasicBlock * getParent() const
void dropDbgValues()
Erase all DPValues in this DPMarker.
void insertDPValue(DbgRecord *New, bool InsertAtHead)
Insert a DPValue into this DPMarker, at the end of the list.
void insertDPValueAfter(DbgRecord *New, DbgRecord *InsertAfter)
Insert a DPValue after a DPValue contained within this marker.
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
void absorbDebugValues(DPMarker &Src, bool InsertAtHead)
Transfer any DPValues from Src into this DPMarker.
simple_ilist< DbgRecord > StoredDPValues
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
static DPMarker EmptyDPMarker
We generally act like all llvm Instructions have a range of DPValues attached to them,...
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgValueRange()
Produce a range over all the DPValues in this Marker.
iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(DPMarker *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere, bool InsertAtHead=false)
Clone all DPMarkers from From into this marker.
void removeMarker()
Handle the removal of a marker: the position of debug-info has gone away, but the stored debug record...
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....
Value * getAddress() const
DIExpression * AddressExpression
DIExpression * getExpression() const
void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
void setAssignId(DIAssignID *New)
void setVariable(DILocalVariable *NewVar)
void setAddress(Value *V)
static DPValue * createDPValue(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
static DPValue * createDPVAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
TrackingMDNodeRef Variable
static DPValue * createDPVDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
void setRawLocation(Metadata *NewLocation)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
static DPValue * createLinkedDPVAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
DIExpression * getAddressExpression() const
unsigned getNumVariableLocationOps() const
LocationType getType() const
void setExpression(DIExpression *NewExpr)
DPValue(const DbgVariableIntrinsic *DVI)
Create a new DPValue representing the intrinsic DVI, for example the assignment represented by a dbg....
std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
DPValue * clone() const
void setKillAddress()
Kill the address component.
bool isKillAddress() const
Check whether this kills the address component.
Value * getVariableLocationOp(unsigned OpIdx) const
Metadata * getRawAddress() const
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
DIAssignID * getAssignID() const
DILocalVariable * getVariable() const
DbgVariableIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DPValue back into a dbg.value intrinsic.
void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
This represents the llvm.dbg.assign instruction.
This is the common base class for debug info intrinsics.
This represents the llvm.dbg.label instruction.
This class is used to track label information.
Definition: DwarfDebug.h:289
Base class for non-instruction debug metadata records that have positions within IR.
void insertAfter(DbgRecord *InsertAfter)
void setMarker(DPMarker *M)
void print(raw_ostream &O, bool IsForDebug=false) const
bool isEquivalentTo(const DbgRecord &R) const
Same as isIdenticalToWhenDefined but checks DebugLoc too.
DebugLoc getDebugLoc() const
DbgInfoIntrinsic * createDebugIntrinsic(Module *M, Instruction *InsertBefore) const
Convert this DbgRecord back into an appropriate llvm.dbg.
Kind RecordKind
Subclass discriminator.
void deleteRecord()
Methods that dispatch to subclass implementations.
void insertBefore(DbgRecord *InsertBefore)
void moveBefore(DbgRecord *MoveBefore)
const Instruction * getInstruction() const
DPMarker * Marker
Marker that this DbgRecord is linked into.
void moveAfter(DbgRecord *MoveAfter)
bool isIdenticalToWhenDefined(const DbgRecord &R) const
DbgRecord * clone() const
const BasicBlock * getParent() const
This is the common base class for debug info intrinsics for variables.
Metadata * getRawLocation() const
DILocation * get() const
Get the underlying DILocation.
Definition: DebugLoc.cpp:20
Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...
Definition: Metadata.h:212
std::array< Metadata *, 3 > DebugValues
Definition: Metadata.h:218
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Definition: Metadata.h:273
Class representing an expression and its matching format.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:200
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:655
DPMarker * DbgMarker
Optional marker recording the position for debugging information that takes effect immediately before...
Definition: Instruction.h:63
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
const BasicBlock * getParent() const
Definition: Instruction.h:150
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:357
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:449
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
LLVMContext & getContext() const
Definition: Metadata.h:1231
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:103
Root of the metadata hierarchy.
Definition: Metadata.h:62
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:65
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1827
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:342
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:427
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1808
Value wrapper in the Metadata hierarchy.
Definition: Metadata.h:450
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:492
LLVM Value Representation.
Definition: Value.h:74
self_iterator getIterator()
Definition: ilist_node.h:109
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:52
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, false >::type iterator
Definition: simple_ilist.h:97
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:1447
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
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.
Definition: STLExtras.h:1738
static ValueAsMetadata * getAsMetadata(Value *V)
@ 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.
Definition: STLExtras.h:1888