LLVM 22.0.0git
DebugInfoMetadata.h
Go to the documentation of this file.
1//===- llvm/IR/DebugInfoMetadata.h - Debug info metadata --------*- C++ -*-===//
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// Declarations for metadata specific to debug info.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_IR_DEBUGINFOMETADATA_H
14#define LLVM_IR_DEBUGINFOMETADATA_H
15
16#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/STLExtras.h"
21#include "llvm/ADT/StringRef.h"
23#include "llvm/IR/Constants.h"
25#include "llvm/IR/Metadata.h"
26#include "llvm/IR/PseudoProbe.h"
31#include <cassert>
32#include <climits>
33#include <cstddef>
34#include <cstdint>
35#include <iterator>
36#include <optional>
37#include <vector>
38
39// Helper macros for defining get() overrides.
40#define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__
41#define DEFINE_MDNODE_GET_UNPACK(ARGS) DEFINE_MDNODE_GET_UNPACK_IMPL ARGS
42#define DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS) \
43 static CLASS *getDistinct(LLVMContext &Context, \
44 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
45 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct); \
46 } \
47 static Temp##CLASS getTemporary(LLVMContext &Context, \
48 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
49 return Temp##CLASS( \
50 getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary)); \
51 }
52#define DEFINE_MDNODE_GET(CLASS, FORMAL, ARGS) \
53 static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
54 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued); \
55 } \
56 static CLASS *getIfExists(LLVMContext &Context, \
57 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
58 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued, \
59 /* ShouldCreate */ false); \
60 } \
61 DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)
62
63namespace llvm {
64
65namespace dwarf {
66enum Tag : uint16_t;
67}
68
69/// Wrapper structure that holds a language name and its version.
70///
71/// Some debug-info formats, particularly DWARF, distniguish between
72/// language codes that include the version name and codes that don't.
73/// DISourceLanguageName may hold either of these.
74///
76 /// Language version. The version scheme is language
77 /// dependent.
78 uint32_t Version = 0;
79
80 /// Language name.
81 /// If \ref HasVersion is \c true, then this name
82 /// is version independent (i.e., doesn't include the language
83 /// version in its name).
84 uint16_t Name;
85
86 /// If \c true, then \ref Version is interpretable and \ref Name
87 /// is a version independent name.
88 bool HasVersion;
89
90public:
91 bool hasVersionedName() const { return HasVersion; }
92
93 /// Returns a versioned or unversioned language name.
94 uint16_t getName() const { return Name; }
95
96 /// Transitional API for cases where we do not yet support
97 /// versioned source language names. Use \ref getName instead.
98 ///
99 /// FIXME: remove once all callers of this API account for versioned
100 /// names.
103 return Name;
104 }
105
106 /// Returns language version. Only valid for versioned language names.
109 return Version;
110 }
111
113 : Version(Version), Name(Lang), HasVersion(true) {};
115 : Version(0), Name(Lang), HasVersion(false) {};
116};
117
118class DbgVariableRecord;
119
121
123 const MDTuple *N = nullptr;
124
125public:
126 DITypeRefArray() = default;
127 DITypeRefArray(const MDTuple *N) : N(N) {}
128
129 explicit operator bool() const { return get(); }
130 explicit operator MDTuple *() const { return get(); }
131
132 MDTuple *get() const { return const_cast<MDTuple *>(N); }
133 MDTuple *operator->() const { return get(); }
134 MDTuple &operator*() const { return *get(); }
135
136 // FIXME: Fix callers and remove condition on N.
137 unsigned size() const { return N ? N->getNumOperands() : 0u; }
138 DIType *operator[](unsigned I) const {
139 return cast_or_null<DIType>(N->getOperand(I));
140 }
141
142 class iterator {
143 MDNode::op_iterator I = nullptr;
144
145 public:
146 using iterator_category = std::input_iterator_tag;
148 using difference_type = std::ptrdiff_t;
149 using pointer = void;
150 using reference = DIType *;
151
152 iterator() = default;
153 explicit iterator(MDNode::op_iterator I) : I(I) {}
154
155 DIType *operator*() const { return cast_or_null<DIType>(*I); }
156
158 ++I;
159 return *this;
160 }
161
163 iterator Temp(*this);
164 ++I;
165 return Temp;
166 }
167
168 bool operator==(const iterator &X) const { return I == X.I; }
169 bool operator!=(const iterator &X) const { return I != X.I; }
170 };
171
172 // FIXME: Fix callers and remove condition on N.
173 iterator begin() const { return N ? iterator(N->op_begin()) : iterator(); }
174 iterator end() const { return N ? iterator(N->op_end()) : iterator(); }
175};
176
177/// Tagged DWARF-like metadata node.
178///
179/// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,
180/// defined in llvm/BinaryFormat/Dwarf.h). Called \a DINode because it's
181/// potentially used for non-DWARF output.
182///
183/// Uses the SubclassData16 Metadata slot.
184class DINode : public MDNode {
185 friend class LLVMContextImpl;
186 friend class MDNode;
187
188protected:
189 DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
191 : MDNode(C, ID, Storage, Ops1, Ops2) {
192 assert(Tag < 1u << 16);
194 }
195 ~DINode() = default;
196
197 template <class Ty> Ty *getOperandAs(unsigned I) const {
199 }
200
201 StringRef getStringOperand(unsigned I) const {
202 if (auto *S = getOperandAs<MDString>(I))
203 return S->getString();
204 return StringRef();
205 }
206
208 if (S.empty())
209 return nullptr;
210 return MDString::get(Context, S);
211 }
212
213 /// Allow subclasses to mutate the tag.
214 void setTag(unsigned Tag) { SubclassData16 = Tag; }
215
216public:
217 LLVM_ABI dwarf::Tag getTag() const;
218
219 /// Debug info flags.
220 ///
221 /// The three accessibility flags are mutually exclusive and rolled together
222 /// in the first two bits.
224#define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = ID,
225#define DI_FLAG_LARGEST_NEEDED
226#include "llvm/IR/DebugInfoFlags.def"
227 FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic,
228 FlagPtrToMemberRep = FlagSingleInheritance | FlagMultipleInheritance |
229 FlagVirtualInheritance,
230 LLVM_MARK_AS_BITMASK_ENUM(FlagLargest)
231 };
232
233 LLVM_ABI static DIFlags getFlag(StringRef Flag);
234 LLVM_ABI static StringRef getFlagString(DIFlags Flag);
235
236 /// Split up a flags bitfield.
237 ///
238 /// Split \c Flags into \c SplitFlags, a vector of its components. Returns
239 /// any remaining (unrecognized) bits.
240 LLVM_ABI static DIFlags splitFlags(DIFlags Flags,
241 SmallVectorImpl<DIFlags> &SplitFlags);
242
243 static bool classof(const Metadata *MD) {
244 switch (MD->getMetadataID()) {
245 default:
246 return false;
247 case GenericDINodeKind:
248 case DISubrangeKind:
249 case DIEnumeratorKind:
250 case DIBasicTypeKind:
251 case DIFixedPointTypeKind:
252 case DIStringTypeKind:
253 case DISubrangeTypeKind:
254 case DIDerivedTypeKind:
255 case DICompositeTypeKind:
256 case DISubroutineTypeKind:
257 case DIFileKind:
258 case DICompileUnitKind:
259 case DISubprogramKind:
260 case DILexicalBlockKind:
261 case DILexicalBlockFileKind:
262 case DINamespaceKind:
263 case DICommonBlockKind:
264 case DITemplateTypeParameterKind:
265 case DITemplateValueParameterKind:
266 case DIGlobalVariableKind:
267 case DILocalVariableKind:
268 case DILabelKind:
269 case DIObjCPropertyKind:
270 case DIImportedEntityKind:
271 case DIModuleKind:
272 case DIGenericSubrangeKind:
273 case DIAssignIDKind:
274 return true;
275 }
276 }
277};
278
279/// Generic tagged DWARF-like metadata node.
280///
281/// An un-specialized DWARF-like metadata node. The first operand is a
282/// (possibly empty) null-separated \a MDString header that contains arbitrary
283/// fields. The remaining operands are \a dwarf_operands(), and are pointers
284/// to other metadata.
285///
286/// Uses the SubclassData32 Metadata slot.
287class GenericDINode : public DINode {
288 friend class LLVMContextImpl;
289 friend class MDNode;
290
291 GenericDINode(LLVMContext &C, StorageType Storage, unsigned Hash,
292 unsigned Tag, ArrayRef<Metadata *> Ops1,
294 : DINode(C, GenericDINodeKind, Storage, Tag, Ops1, Ops2) {
295 setHash(Hash);
296 }
298
299 void setHash(unsigned Hash) { SubclassData32 = Hash; }
300 void recalculateHash();
301
302 static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
304 StorageType Storage, bool ShouldCreate = true) {
305 return getImpl(Context, Tag, getCanonicalMDString(Context, Header),
306 DwarfOps, Storage, ShouldCreate);
307 }
308
309 LLVM_ABI static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
310 MDString *Header,
313 bool ShouldCreate = true);
314
315 TempGenericDINode cloneImpl() const {
318 }
319
320public:
321 unsigned getHash() const { return SubclassData32; }
322
323 DEFINE_MDNODE_GET(GenericDINode,
324 (unsigned Tag, StringRef Header,
326 (Tag, Header, DwarfOps))
327 DEFINE_MDNODE_GET(GenericDINode,
328 (unsigned Tag, MDString *Header,
331
332 /// Return a (temporary) clone of this.
333 TempGenericDINode clone() const { return cloneImpl(); }
334
335 LLVM_ABI dwarf::Tag getTag() const;
336 StringRef getHeader() const { return getStringOperand(0); }
338
339 op_iterator dwarf_op_begin() const { return op_begin() + 1; }
340 op_iterator dwarf_op_end() const { return op_end(); }
343 }
344
345 unsigned getNumDwarfOperands() const { return getNumOperands() - 1; }
346 const MDOperand &getDwarfOperand(unsigned I) const {
347 return getOperand(I + 1);
348 }
349 void replaceDwarfOperandWith(unsigned I, Metadata *New) {
350 replaceOperandWith(I + 1, New);
351 }
352
353 static bool classof(const Metadata *MD) {
354 return MD->getMetadataID() == GenericDINodeKind;
355 }
356};
357
358/// Assignment ID.
359/// Used to link stores (as an attachment) and dbg.assigns (as an operand).
360/// DIAssignID metadata is never uniqued as we compare instances using
361/// referential equality (the instance/address is the ID).
362class DIAssignID : public MDNode {
363 friend class LLVMContextImpl;
364 friend class MDNode;
365
367 : MDNode(C, DIAssignIDKind, Storage, {}) {}
368
369 ~DIAssignID() { dropAllReferences(); }
370
371 LLVM_ABI static DIAssignID *getImpl(LLVMContext &Context, StorageType Storage,
372 bool ShouldCreate = true);
373
374 TempDIAssignID cloneImpl() const { return getTemporary(getContext()); }
375
376public:
377 // This node has no operands to replace.
378 void replaceOperandWith(unsigned I, Metadata *New) = delete;
379
381 return Context.getReplaceableUses()->getAllDbgVariableRecordUsers();
382 }
383
384 static DIAssignID *getDistinct(LLVMContext &Context) {
385 return getImpl(Context, Distinct);
386 }
387 static TempDIAssignID getTemporary(LLVMContext &Context) {
388 return TempDIAssignID(getImpl(Context, Temporary));
389 }
390 // NOTE: Do not define get(LLVMContext&) - see class comment.
391
392 static bool classof(const Metadata *MD) {
393 return MD->getMetadataID() == DIAssignIDKind;
394 }
395};
396
397/// Array subrange.
398class DISubrange : public DINode {
399 friend class LLVMContextImpl;
400 friend class MDNode;
401
403
404 ~DISubrange() = default;
405
406 LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, int64_t Count,
408 bool ShouldCreate = true);
409
410 LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
412 bool ShouldCreate = true);
413
414 LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
416 Metadata *UpperBound, Metadata *Stride,
418 bool ShouldCreate = true);
419
420 TempDISubrange cloneImpl() const {
421 return getTemporary(getContext(), getRawCountNode(), getRawLowerBound(),
422 getRawUpperBound(), getRawStride());
423 }
424
425public:
426 DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0),
427 (Count, LowerBound))
428
429 DEFINE_MDNODE_GET(DISubrange, (Metadata * CountNode, int64_t LowerBound = 0),
431
432 DEFINE_MDNODE_GET(DISubrange,
434 Metadata *UpperBound, Metadata *Stride),
435 (CountNode, LowerBound, UpperBound, Stride))
436
437 TempDISubrange clone() const { return cloneImpl(); }
438
439 Metadata *getRawCountNode() const { return getOperand(0).get(); }
440
441 Metadata *getRawLowerBound() const { return getOperand(1).get(); }
442
443 Metadata *getRawUpperBound() const { return getOperand(2).get(); }
444
445 Metadata *getRawStride() const { return getOperand(3).get(); }
446
447 typedef PointerUnion<ConstantInt *, DIVariable *, DIExpression *> BoundType;
448
449 LLVM_ABI BoundType getCount() const;
450
451 LLVM_ABI BoundType getLowerBound() const;
452
453 LLVM_ABI BoundType getUpperBound() const;
454
455 LLVM_ABI BoundType getStride() const;
456
457 static bool classof(const Metadata *MD) {
458 return MD->getMetadataID() == DISubrangeKind;
459 }
460};
461
462class DIGenericSubrange : public DINode {
463 friend class LLVMContextImpl;
464 friend class MDNode;
465
466 DIGenericSubrange(LLVMContext &C, StorageType Storage,
468
469 ~DIGenericSubrange() = default;
470
471 LLVM_ABI static DIGenericSubrange *
472 getImpl(LLVMContext &Context, Metadata *CountNode, Metadata *LowerBound,
473 Metadata *UpperBound, Metadata *Stride, StorageType Storage,
474 bool ShouldCreate = true);
475
476 TempDIGenericSubrange cloneImpl() const {
479 }
480
481public:
482 DEFINE_MDNODE_GET(DIGenericSubrange,
483 (Metadata * CountNode, Metadata *LowerBound,
484 Metadata *UpperBound, Metadata *Stride),
485 (CountNode, LowerBound, UpperBound, Stride))
486
487 TempDIGenericSubrange clone() const { return cloneImpl(); }
488
489 Metadata *getRawCountNode() const { return getOperand(0).get(); }
490 Metadata *getRawLowerBound() const { return getOperand(1).get(); }
491 Metadata *getRawUpperBound() const { return getOperand(2).get(); }
492 Metadata *getRawStride() const { return getOperand(3).get(); }
493
495
500
501 static bool classof(const Metadata *MD) {
502 return MD->getMetadataID() == DIGenericSubrangeKind;
503 }
504};
505
506/// Enumeration value.
507///
508/// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
509/// longer creates a type cycle.
510class DIEnumerator : public DINode {
511 friend class LLVMContextImpl;
512 friend class MDNode;
513
514 APInt Value;
515 LLVM_ABI DIEnumerator(LLVMContext &C, StorageType Storage, const APInt &Value,
517 DIEnumerator(LLVMContext &C, StorageType Storage, int64_t Value,
519 : DIEnumerator(C, Storage, APInt(64, Value, !IsUnsigned), IsUnsigned,
520 Ops) {}
521 ~DIEnumerator() = default;
522
523 static DIEnumerator *getImpl(LLVMContext &Context, const APInt &Value,
525 StorageType Storage, bool ShouldCreate = true) {
526 return getImpl(Context, Value, IsUnsigned,
527 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
528 }
529 LLVM_ABI static DIEnumerator *getImpl(LLVMContext &Context,
530 const APInt &Value, bool IsUnsigned,
531 MDString *Name, StorageType Storage,
532 bool ShouldCreate = true);
533
534 TempDIEnumerator cloneImpl() const {
536 }
537
538public:
539 DEFINE_MDNODE_GET(DIEnumerator,
540 (int64_t Value, bool IsUnsigned, StringRef Name),
541 (APInt(64, Value, !IsUnsigned), IsUnsigned, Name))
542 DEFINE_MDNODE_GET(DIEnumerator,
543 (int64_t Value, bool IsUnsigned, MDString *Name),
544 (APInt(64, Value, !IsUnsigned), IsUnsigned, Name))
545 DEFINE_MDNODE_GET(DIEnumerator,
546 (APInt Value, bool IsUnsigned, StringRef Name),
547 (Value, IsUnsigned, Name))
548 DEFINE_MDNODE_GET(DIEnumerator,
549 (APInt Value, bool IsUnsigned, MDString *Name),
550 (Value, IsUnsigned, Name))
551
552 TempDIEnumerator clone() const { return cloneImpl(); }
553
554 const APInt &getValue() const { return Value; }
555 bool isUnsigned() const { return SubclassData32; }
556 StringRef getName() const { return getStringOperand(0); }
557
559
560 static bool classof(const Metadata *MD) {
561 return MD->getMetadataID() == DIEnumeratorKind;
562 }
563};
564
565/// Base class for scope-like contexts.
566///
567/// Base class for lexical scopes and types (which are also declaration
568/// contexts).
569///
570/// TODO: Separate the concepts of declaration contexts and lexical scopes.
571class DIScope : public DINode {
572protected:
576 ~DIScope() = default;
577
578public:
580
581 inline StringRef getFilename() const;
582 inline StringRef getDirectory() const;
583 inline std::optional<StringRef> getSource() const;
584
585 LLVM_ABI StringRef getName() const;
586 LLVM_ABI DIScope *getScope() const;
587
588 /// Return the raw underlying file.
589 ///
590 /// A \a DIFile is a \a DIScope, but it doesn't point at a separate file (it
591 /// \em is the file). If \c this is an \a DIFile, we need to return \c this.
592 /// Otherwise, return the first operand, which is where all other subclasses
593 /// store their file pointer.
595 return isa<DIFile>(this) ? const_cast<DIScope *>(this)
596 : static_cast<Metadata *>(getOperand(0));
597 }
598
599 static bool classof(const Metadata *MD) {
600 switch (MD->getMetadataID()) {
601 default:
602 return false;
603 case DIBasicTypeKind:
604 case DIFixedPointTypeKind:
605 case DIStringTypeKind:
606 case DISubrangeTypeKind:
607 case DIDerivedTypeKind:
608 case DICompositeTypeKind:
609 case DISubroutineTypeKind:
610 case DIFileKind:
611 case DICompileUnitKind:
612 case DISubprogramKind:
613 case DILexicalBlockKind:
614 case DILexicalBlockFileKind:
615 case DINamespaceKind:
616 case DICommonBlockKind:
617 case DIModuleKind:
618 return true;
619 }
620 }
621};
622
623/// File.
624///
625/// TODO: Merge with directory/file node (including users).
626/// TODO: Canonicalize paths on creation.
627class DIFile : public DIScope {
628 friend class LLVMContextImpl;
629 friend class MDNode;
630
631public:
632 /// Which algorithm (e.g. MD5) a checksum was generated with.
633 ///
634 /// The encoding is explicit because it is used directly in Bitcode. The
635 /// value 0 is reserved to indicate the absence of a checksum in Bitcode.
637 // The first variant was originally CSK_None, encoded as 0. The new
638 // internal representation removes the need for this by wrapping the
639 // ChecksumInfo in an Optional, but to preserve Bitcode compatibility the 0
640 // encoding is reserved.
644 CSK_Last = CSK_SHA256 // Should be last enumeration.
645 };
646
647 /// A single checksum, represented by a \a Kind and a \a Value (a string).
648 template <typename T> struct ChecksumInfo {
649 /// The kind of checksum which \a Value encodes.
651 /// The string value of the checksum.
653
655 ~ChecksumInfo() = default;
656 bool operator==(const ChecksumInfo<T> &X) const {
657 return Kind == X.Kind && Value == X.Value;
658 }
659 bool operator!=(const ChecksumInfo<T> &X) const { return !(*this == X); }
660 StringRef getKindAsString() const { return getChecksumKindAsString(Kind); }
661 };
662
663private:
664 std::optional<ChecksumInfo<MDString *>> Checksum;
665 /// An optional source. A nullptr means none.
667
669 std::optional<ChecksumInfo<MDString *>> CS, MDString *Src,
671 ~DIFile() = default;
672
673 static DIFile *getImpl(LLVMContext &Context, StringRef Filename,
675 std::optional<ChecksumInfo<StringRef>> CS,
676 std::optional<StringRef> Source, StorageType Storage,
677 bool ShouldCreate = true) {
678 std::optional<ChecksumInfo<MDString *>> MDChecksum;
679 if (CS)
680 MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value));
681 return getImpl(Context, getCanonicalMDString(Context, Filename),
682 getCanonicalMDString(Context, Directory), MDChecksum,
683 Source ? MDString::get(Context, *Source) : nullptr, Storage,
684 ShouldCreate);
685 }
686 LLVM_ABI static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
687 MDString *Directory,
688 std::optional<ChecksumInfo<MDString *>> CS,
689 MDString *Source, StorageType Storage,
690 bool ShouldCreate = true);
691
692 TempDIFile cloneImpl() const {
694 getChecksum(), getSource());
695 }
696
697public:
700 std::optional<ChecksumInfo<StringRef>> CS = std::nullopt,
701 std::optional<StringRef> Source = std::nullopt),
702 (Filename, Directory, CS, Source))
703 DEFINE_MDNODE_GET(DIFile,
705 std::optional<ChecksumInfo<MDString *>> CS = std::nullopt,
706 MDString *Source = nullptr),
707 (Filename, Directory, CS, Source))
708
709 TempDIFile clone() const { return cloneImpl(); }
710
711 StringRef getFilename() const { return getStringOperand(0); }
712 StringRef getDirectory() const { return getStringOperand(1); }
713 std::optional<ChecksumInfo<StringRef>> getChecksum() const {
714 std::optional<ChecksumInfo<StringRef>> StringRefChecksum;
715 if (Checksum)
716 StringRefChecksum.emplace(Checksum->Kind, Checksum->Value->getString());
717 return StringRefChecksum;
718 }
719 std::optional<StringRef> getSource() const {
720 return Source ? std::optional<StringRef>(Source->getString())
721 : std::nullopt;
722 }
723
724 MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
725 MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
726 std::optional<ChecksumInfo<MDString *>> getRawChecksum() const {
727 return Checksum;
728 }
729 MDString *getRawSource() const { return Source; }
730
731 LLVM_ABI static StringRef getChecksumKindAsString(ChecksumKind CSKind);
732 LLVM_ABI static std::optional<ChecksumKind>
733 getChecksumKind(StringRef CSKindStr);
734
735 static bool classof(const Metadata *MD) {
736 return MD->getMetadataID() == DIFileKind;
737 }
738};
739
741 if (auto *F = getFile())
742 return F->getFilename();
743 return "";
744}
745
747 if (auto *F = getFile())
748 return F->getDirectory();
749 return "";
750}
751
752std::optional<StringRef> DIScope::getSource() const {
753 if (auto *F = getFile())
754 return F->getSource();
755 return std::nullopt;
756}
757
758/// Base class for types.
759///
760/// TODO: Remove the hardcoded name and context, since many types don't use
761/// them.
762/// TODO: Split up flags.
763///
764/// Uses the SubclassData32 Metadata slot.
765class DIType : public DIScope {
766 unsigned Line;
767 DIFlags Flags;
768 uint32_t NumExtraInhabitants;
769
770protected:
771 static constexpr unsigned N_OPERANDS = 5;
772
773 DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
774 unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants,
776 : DIScope(C, ID, Storage, Tag, Ops) {
777 init(Line, AlignInBits, NumExtraInhabitants, Flags);
778 }
779 ~DIType() = default;
780
781 void init(unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants,
782 DIFlags Flags) {
783 this->Line = Line;
784 this->Flags = Flags;
785 this->SubclassData32 = AlignInBits;
786 this->NumExtraInhabitants = NumExtraInhabitants;
787 }
788
789 /// Change fields in place.
790 void mutate(unsigned Tag, unsigned Line, uint32_t AlignInBits,
791 uint32_t NumExtraInhabitants, DIFlags Flags) {
792 assert(isDistinct() && "Only distinct nodes can mutate");
793 setTag(Tag);
794 init(Line, AlignInBits, NumExtraInhabitants, Flags);
795 }
796
797public:
798 TempDIType clone() const {
799 return TempDIType(cast<DIType>(MDNode::clone().release()));
800 }
801
802 unsigned getLine() const { return Line; }
804 uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
805 uint32_t getNumExtraInhabitants() const { return NumExtraInhabitants; }
806 DIFlags getFlags() const { return Flags; }
807
809 StringRef getName() const { return getStringOperand(2); }
810
811 Metadata *getRawScope() const { return getOperand(1); }
813
814 Metadata *getRawSizeInBits() const { return getOperand(3); }
817 if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(MD->getValue()))
818 return CI->getZExtValue();
819 }
820 return 0;
821 }
822
823 Metadata *getRawOffsetInBits() const { return getOperand(4); }
826 if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(MD->getValue()))
827 return CI->getZExtValue();
828 }
829 return 0;
830 }
831
832 /// Returns a new temporary DIType with updated Flags
833 TempDIType cloneWithFlags(DIFlags NewFlags) const {
834 auto NewTy = clone();
835 NewTy->Flags = NewFlags;
836 return NewTy;
837 }
838
839 bool isPrivate() const {
840 return (getFlags() & FlagAccessibility) == FlagPrivate;
841 }
842 bool isProtected() const {
843 return (getFlags() & FlagAccessibility) == FlagProtected;
844 }
845 bool isPublic() const {
846 return (getFlags() & FlagAccessibility) == FlagPublic;
847 }
848 bool isForwardDecl() const { return getFlags() & FlagFwdDecl; }
849 bool isAppleBlockExtension() const { return getFlags() & FlagAppleBlock; }
850 bool isVirtual() const { return getFlags() & FlagVirtual; }
851 bool isArtificial() const { return getFlags() & FlagArtificial; }
852 bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
853 bool isObjcClassComplete() const {
854 return getFlags() & FlagObjcClassComplete;
855 }
856 bool isVector() const { return getFlags() & FlagVector; }
857 bool isBitField() const { return getFlags() & FlagBitField; }
858 bool isStaticMember() const { return getFlags() & FlagStaticMember; }
859 bool isLValueReference() const { return getFlags() & FlagLValueReference; }
860 bool isRValueReference() const { return getFlags() & FlagRValueReference; }
861 bool isTypePassByValue() const { return getFlags() & FlagTypePassByValue; }
863 return getFlags() & FlagTypePassByReference;
864 }
865 bool isBigEndian() const { return getFlags() & FlagBigEndian; }
866 bool isLittleEndian() const { return getFlags() & FlagLittleEndian; }
867 bool getExportSymbols() const { return getFlags() & FlagExportSymbols; }
868
869 static bool classof(const Metadata *MD) {
870 switch (MD->getMetadataID()) {
871 default:
872 return false;
873 case DIBasicTypeKind:
874 case DIFixedPointTypeKind:
875 case DIStringTypeKind:
876 case DISubrangeTypeKind:
877 case DIDerivedTypeKind:
878 case DICompositeTypeKind:
879 case DISubroutineTypeKind:
880 return true;
881 }
882 }
883};
884
885/// Basic type, like 'int' or 'float'.
886///
887/// TODO: Split out DW_TAG_unspecified_type.
888/// TODO: Drop unused accessors.
889class DIBasicType : public DIType {
890 friend class LLVMContextImpl;
891 friend class MDNode;
892
893 unsigned Encoding;
894 /// Describes the number of bits used by the value of the object. Non-zero
895 /// when the value of an object does not fully occupy the storage size
896 /// specified by SizeInBits.
897 uint32_t DataSizeInBits;
898
899protected:
901 uint32_t AlignInBits, unsigned Encoding,
902 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
904 : DIType(C, DIBasicTypeKind, Storage, Tag, 0, AlignInBits,
906 Encoding(Encoding), DataSizeInBits(DataSizeInBits) {}
908 uint32_t AlignInBits, unsigned Encoding,
909 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
912 Ops),
913 Encoding(Encoding), DataSizeInBits(DataSizeInBits) {}
914 ~DIBasicType() = default;
915
916 static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
918 uint32_t AlignInBits, unsigned Encoding,
920 uint32_t DataSizeInBits, DIFlags Flags,
921 StorageType Storage, bool ShouldCreate = true) {
922 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
924 DataSizeInBits, Flags, Storage, ShouldCreate);
925 }
926 static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
928 uint32_t AlignInBits, unsigned Encoding,
930 uint32_t DataSizeInBits, DIFlags Flags,
931 StorageType Storage, bool ShouldCreate = true) {
932 auto *SizeInBitsNode = ConstantAsMetadata::get(
933 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
934 return getImpl(Context, Tag, Name, SizeInBitsNode, AlignInBits, Encoding,
935 NumExtraInhabitants, DataSizeInBits, Flags, Storage,
936 ShouldCreate);
937 }
938 LLVM_ABI static DIBasicType *
939 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
942 StorageType Storage, bool ShouldCreate = true);
943
944 TempDIBasicType cloneImpl() const {
948 getFlags());
949 }
950
951public:
953 (Tag, Name, 0, 0, 0, 0, 0, FlagZero))
956 (Tag, Name, SizeInBits, 0, 0, 0, 0, FlagZero))
958 (unsigned Tag, MDString *Name, uint64_t SizeInBits),
959 (Tag, Name, SizeInBits, 0, 0, 0, 0, FlagZero))
962 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
963 (Tag, Name, SizeInBits, AlignInBits, Encoding, 0, 0, Flags))
965 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
966 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
967 (Tag, Name, SizeInBits, AlignInBits, Encoding, 0, 0, Flags))
970 uint32_t AlignInBits, unsigned Encoding,
976 uint32_t AlignInBits, unsigned Encoding,
977 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
978 DIFlags Flags),
979 (Tag, Name, SizeInBits, AlignInBits, Encoding,
980 NumExtraInhabitants, DataSizeInBits, Flags))
983 uint32_t AlignInBits, unsigned Encoding,
987 NumExtraInhabitants, DataSizeInBits, Flags))
989 (unsigned Tag, MDString *Name, Metadata *SizeInBits,
990 uint32_t AlignInBits, unsigned Encoding,
991 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
992 DIFlags Flags),
993 (Tag, Name, SizeInBits, AlignInBits, Encoding,
994 NumExtraInhabitants, DataSizeInBits, Flags))
995
996 TempDIBasicType clone() const { return cloneImpl(); }
997
998 unsigned getEncoding() const { return Encoding; }
999
1000 uint32_t getDataSizeInBits() const { return DataSizeInBits; }
1001
1002 enum class Signedness { Signed, Unsigned };
1003
1004 /// Return the signedness of this type, or std::nullopt if this type is
1005 /// neither signed nor unsigned.
1006 LLVM_ABI std::optional<Signedness> getSignedness() const;
1007
1008 static bool classof(const Metadata *MD) {
1009 return MD->getMetadataID() == DIBasicTypeKind ||
1010 MD->getMetadataID() == DIFixedPointTypeKind;
1011 }
1012};
1013
1014/// Fixed-point type.
1015class DIFixedPointType : public DIBasicType {
1016 friend class LLVMContextImpl;
1017 friend class MDNode;
1018
1019 // Actually FixedPointKind.
1020 unsigned Kind;
1021 // Used for binary and decimal.
1022 int Factor;
1023 // Used for rational.
1024 APInt Numerator;
1025 APInt Denominator;
1026
1027 DIFixedPointType(LLVMContext &C, StorageType Storage, unsigned Tag,
1029 unsigned Kind, int Factor, ArrayRef<Metadata *> Ops)
1030 : DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, AlignInBits,
1031 Encoding, 0, 0, Flags, Ops),
1032 Kind(Kind), Factor(Factor) {
1033 assert(Kind == FixedPointBinary || Kind == FixedPointDecimal);
1034 }
1036 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags,
1037 unsigned Kind, APInt Numerator, APInt Denominator,
1039 : DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, AlignInBits,
1040 Encoding, 0, 0, Flags, Ops),
1041 Kind(Kind), Factor(0), Numerator(Numerator), Denominator(Denominator) {
1042 assert(Kind == FixedPointRational);
1043 }
1044 DIFixedPointType(LLVMContext &C, StorageType Storage, unsigned Tag,
1045 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags,
1046 unsigned Kind, int Factor, APInt Numerator,
1048 : DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, AlignInBits,
1049 Encoding, 0, 0, Flags, Ops),
1050 Kind(Kind), Factor(Factor), Numerator(Numerator),
1052 ~DIFixedPointType() = default;
1053
1054 static DIFixedPointType *
1055 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name,
1056 uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1057 DIFlags Flags, unsigned Kind, int Factor, APInt Numerator,
1058 APInt Denominator, StorageType Storage, bool ShouldCreate = true) {
1059 auto *SizeInBitsNode = ConstantAsMetadata::get(
1060 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1061 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
1062 SizeInBitsNode, AlignInBits, Encoding, Flags, Kind, Factor,
1063 Numerator, Denominator, Storage, ShouldCreate);
1064 }
1065 static DIFixedPointType *
1066 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name,
1067 Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1068 DIFlags Flags, unsigned Kind, int Factor, APInt Numerator,
1069 APInt Denominator, StorageType Storage, bool ShouldCreate = true) {
1070 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
1071 SizeInBits, AlignInBits, Encoding, Flags, Kind, Factor,
1072 Numerator, Denominator, Storage, ShouldCreate);
1073 }
1074 static DIFixedPointType *
1075 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
1076 uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1077 DIFlags Flags, unsigned Kind, int Factor, APInt Numerator,
1078 APInt Denominator, StorageType Storage, bool ShouldCreate = true) {
1079 auto *SizeInBitsNode = ConstantAsMetadata::get(
1080 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1081 return getImpl(Context, Tag, Name, SizeInBitsNode, AlignInBits, Encoding,
1082 Flags, Kind, Factor, Numerator, Denominator, Storage,
1083 ShouldCreate);
1084 }
1085 LLVM_ABI static DIFixedPointType *
1086 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
1087 Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1088 DIFlags Flags, unsigned Kind, int Factor, APInt Numerator,
1089 APInt Denominator, StorageType Storage, bool ShouldCreate = true);
1090
1091 TempDIFixedPointType cloneImpl() const {
1094 getFlags(), Kind, Factor, Numerator, Denominator);
1095 }
1096
1097public:
1098 enum FixedPointKind : unsigned {
1099 /// Scale factor 2^Factor.
1101 /// Scale factor 10^Factor.
1103 /// Arbitrary rational scale factor.
1106 };
1107
1108 LLVM_ABI static std::optional<FixedPointKind>
1110 LLVM_ABI static const char *fixedPointKindString(FixedPointKind);
1111
1112 DEFINE_MDNODE_GET(DIFixedPointType,
1113 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
1115 unsigned Kind, int Factor, APInt Numerator,
1116 APInt Denominator),
1118 Factor, Numerator, Denominator))
1119 DEFINE_MDNODE_GET(DIFixedPointType,
1122 unsigned Kind, int Factor, APInt Numerator,
1123 APInt Denominator),
1125 Factor, Numerator, Denominator))
1126 DEFINE_MDNODE_GET(DIFixedPointType,
1127 (unsigned Tag, MDString *Name, Metadata *SizeInBits,
1129 unsigned Kind, int Factor, APInt Numerator,
1130 APInt Denominator),
1132 Factor, Numerator, Denominator))
1133
1134 TempDIFixedPointType clone() const { return cloneImpl(); }
1135
1136 bool isBinary() const { return Kind == FixedPointBinary; }
1137 bool isDecimal() const { return Kind == FixedPointDecimal; }
1138 bool isRational() const { return Kind == FixedPointRational; }
1139
1140 LLVM_ABI bool isSigned() const;
1141
1142 FixedPointKind getKind() const { return static_cast<FixedPointKind>(Kind); }
1143
1144 int getFactorRaw() const { return Factor; }
1145 int getFactor() const {
1146 assert(Kind == FixedPointBinary || Kind == FixedPointDecimal);
1147 return Factor;
1148 }
1149
1150 const APInt &getNumeratorRaw() const { return Numerator; }
1151 const APInt &getNumerator() const {
1152 assert(Kind == FixedPointRational);
1153 return Numerator;
1154 }
1155
1156 const APInt &getDenominatorRaw() const { return Denominator; }
1157 const APInt &getDenominator() const {
1158 assert(Kind == FixedPointRational);
1159 return Denominator;
1160 }
1161
1162 static bool classof(const Metadata *MD) {
1163 return MD->getMetadataID() == DIFixedPointTypeKind;
1164 }
1165};
1166
1167/// String type, Fortran CHARACTER(n)
1168class DIStringType : public DIType {
1169 friend class LLVMContextImpl;
1170 friend class MDNode;
1171
1172 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1173
1174 unsigned Encoding;
1175
1176 DIStringType(LLVMContext &C, StorageType Storage, unsigned Tag,
1177 uint32_t AlignInBits, unsigned Encoding,
1179 : DIType(C, DIStringTypeKind, Storage, Tag, 0, AlignInBits, 0, FlagZero,
1180 Ops),
1181 Encoding(Encoding) {}
1182 ~DIStringType() = default;
1183
1184 static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
1186 Metadata *StrLenExp, Metadata *StrLocationExp,
1188 unsigned Encoding, StorageType Storage,
1189 bool ShouldCreate = true) {
1190 auto *SizeInBitsNode = ConstantAsMetadata::get(
1191 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1192 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
1193 StringLength, StrLenExp, StrLocationExp, SizeInBitsNode,
1194 AlignInBits, Encoding, Storage, ShouldCreate);
1195 }
1196 static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
1197 MDString *Name, Metadata *StringLength,
1198 Metadata *StrLenExp, Metadata *StrLocationExp,
1200 unsigned Encoding, StorageType Storage,
1201 bool ShouldCreate = true) {
1202 auto *SizeInBitsNode = ConstantAsMetadata::get(
1203 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1204 return getImpl(Context, Tag, Name, StringLength, StrLenExp, StrLocationExp,
1205 SizeInBitsNode, AlignInBits, Encoding, Storage,
1206 ShouldCreate);
1207 }
1208 LLVM_ABI static DIStringType *
1209 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
1210 Metadata *StringLength, Metadata *StrLenExp, Metadata *StrLocationExp,
1211 Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1212 StorageType Storage, bool ShouldCreate = true);
1213
1214 TempDIStringType cloneImpl() const {
1219 }
1220
1221public:
1222 DEFINE_MDNODE_GET(DIStringType,
1223 (unsigned Tag, StringRef Name, uint64_t SizeInBits,
1225 (Tag, Name, nullptr, nullptr, nullptr, SizeInBits,
1226 AlignInBits, 0))
1227 DEFINE_MDNODE_GET(DIStringType,
1231 unsigned Encoding),
1234 DEFINE_MDNODE_GET(DIStringType,
1235 (unsigned Tag, StringRef Name, Metadata *StringLength,
1238 unsigned Encoding),
1241 DEFINE_MDNODE_GET(DIStringType,
1245 unsigned Encoding),
1248
1249 TempDIStringType clone() const { return cloneImpl(); }
1250
1251 static bool classof(const Metadata *MD) {
1252 return MD->getMetadataID() == DIStringTypeKind;
1253 }
1254
1258
1262
1266
1267 unsigned getEncoding() const { return Encoding; }
1268
1269 Metadata *getRawStringLength() const { return getOperand(MY_FIRST_OPERAND); }
1270
1272 return getOperand(MY_FIRST_OPERAND + 1);
1273 }
1274
1276 return getOperand(MY_FIRST_OPERAND + 2);
1277 }
1278};
1279
1280/// Derived types.
1281///
1282/// This includes qualified types, pointers, references, friends, typedefs, and
1283/// class members.
1284///
1285/// TODO: Split out members (inheritance, fields, methods, etc.).
1286class DIDerivedType : public DIType {
1287public:
1288 /// Pointer authentication (__ptrauth) metadata.
1290 // RawData layout:
1291 // - Bits 0..3: Key
1292 // - Bit 4: IsAddressDiscriminated
1293 // - Bits 5..20: ExtraDiscriminator
1294 // - Bit 21: IsaPointer
1295 // - Bit 22: AuthenticatesNullValues
1296 unsigned RawData;
1297
1298 PtrAuthData(unsigned FromRawData) : RawData(FromRawData) {}
1299 PtrAuthData(unsigned Key, bool IsDiscr, unsigned Discriminator,
1300 bool IsaPointer, bool AuthenticatesNullValues) {
1301 assert(Key < 16);
1302 assert(Discriminator <= 0xffff);
1303 RawData = (Key << 0) | (IsDiscr ? (1 << 4) : 0) | (Discriminator << 5) |
1304 (IsaPointer ? (1 << 21) : 0) |
1305 (AuthenticatesNullValues ? (1 << 22) : 0);
1306 }
1307
1308 unsigned key() { return (RawData >> 0) & 0b1111; }
1309 bool isAddressDiscriminated() { return (RawData >> 4) & 1; }
1310 unsigned extraDiscriminator() { return (RawData >> 5) & 0xffff; }
1311 bool isaPointer() { return (RawData >> 21) & 1; }
1312 bool authenticatesNullValues() { return (RawData >> 22) & 1; }
1313 };
1314
1315private:
1316 friend class LLVMContextImpl;
1317 friend class MDNode;
1318
1319 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1320
1321 /// The DWARF address space of the memory pointed to or referenced by a
1322 /// pointer or reference type respectively.
1323 std::optional<unsigned> DWARFAddressSpace;
1324
1325 DIDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
1326 unsigned Line, uint32_t AlignInBits,
1327 std::optional<unsigned> DWARFAddressSpace,
1328 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1330 : DIType(C, DIDerivedTypeKind, Storage, Tag, Line, AlignInBits, 0, Flags,
1331 Ops),
1332 DWARFAddressSpace(DWARFAddressSpace) {
1333 if (PtrAuthData)
1335 }
1336 ~DIDerivedType() = default;
1337 static DIDerivedType *
1338 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
1339 unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
1341 std::optional<unsigned> DWARFAddressSpace,
1342 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1344 bool ShouldCreate = true) {
1345 auto *SizeInBitsNode = ConstantAsMetadata::get(
1346 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1347 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1348 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1349 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1350 Line, Scope, BaseType, SizeInBitsNode, AlignInBits,
1351 OffsetInBitsNode, DWARFAddressSpace, PtrAuthData, Flags,
1352 ExtraData, Annotations.get(), Storage, ShouldCreate);
1353 }
1354 static DIDerivedType *
1355 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, DIFile *File,
1356 unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
1358 std::optional<unsigned> DWARFAddressSpace,
1359 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1361 bool ShouldCreate = true) {
1362 auto *SizeInBitsNode = ConstantAsMetadata::get(
1363 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1364 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1365 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1366 return getImpl(Context, Tag, Name, File, Line, Scope, BaseType,
1367 SizeInBitsNode, AlignInBits, OffsetInBitsNode,
1369 Annotations.get(), Storage, ShouldCreate);
1370 }
1371 static DIDerivedType *
1372 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
1375 std::optional<unsigned> DWARFAddressSpace,
1376 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1378 bool ShouldCreate = true) {
1379 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1381 DWARFAddressSpace, PtrAuthData, Flags, ExtraData,
1382 Annotations.get(), Storage, ShouldCreate);
1383 }
1384 LLVM_ABI static DIDerivedType *
1385 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
1386 unsigned Line, Metadata *Scope, Metadata *BaseType,
1388 std::optional<unsigned> DWARFAddressSpace,
1389 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1391 bool ShouldCreate = true);
1392
1393 TempDIDerivedType cloneImpl() const {
1394 return getTemporary(
1397 getRawOffsetInBits(), getDWARFAddressSpace(), getPtrAuthData(),
1399 }
1400
1401public:
1402 DEFINE_MDNODE_GET(DIDerivedType,
1403 (unsigned Tag, MDString *Name, Metadata *File,
1404 unsigned Line, Metadata *Scope, Metadata *BaseType,
1407 std::optional<unsigned> DWARFAddressSpace,
1408 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1409 Metadata *ExtraData = nullptr,
1410 Metadata *Annotations = nullptr),
1412 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1414 DEFINE_MDNODE_GET(DIDerivedType,
1415 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1418 std::optional<unsigned> DWARFAddressSpace,
1419 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1421 DINodeArray Annotations = nullptr),
1423 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1425 DEFINE_MDNODE_GET(DIDerivedType,
1426 (unsigned Tag, MDString *Name, DIFile *File, unsigned Line,
1429 std::optional<unsigned> DWARFAddressSpace,
1430 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1431 Metadata *ExtraData = nullptr,
1432 DINodeArray Annotations = nullptr),
1434 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1436 DEFINE_MDNODE_GET(DIDerivedType,
1437 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1440 std::optional<unsigned> DWARFAddressSpace,
1441 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1442 Metadata *ExtraData = nullptr,
1443 DINodeArray Annotations = nullptr),
1445 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1447
1448 TempDIDerivedType clone() const { return cloneImpl(); }
1449
1450 /// Get the base type this is derived from.
1451 DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
1452 Metadata *getRawBaseType() const { return getOperand(MY_FIRST_OPERAND); }
1453
1454 /// \returns The DWARF address space of the memory pointed to or referenced by
1455 /// a pointer or reference type respectively.
1456 std::optional<unsigned> getDWARFAddressSpace() const {
1457 return DWARFAddressSpace;
1458 }
1459
1460 LLVM_ABI std::optional<PtrAuthData> getPtrAuthData() const;
1461
1462 /// Get extra data associated with this derived type.
1463 ///
1464 /// Class type for pointer-to-members, objective-c property node for ivars,
1465 /// global constant wrapper for static members, virtual base pointer offset
1466 /// for inheritance, a tuple of template parameters for template aliases,
1467 /// discriminant for a variant, or storage offset for a bit field.
1468 ///
1469 /// TODO: Separate out types that need this extra operand: pointer-to-member
1470 /// types and member fields (static members and ivars).
1472 Metadata *getRawExtraData() const { return getOperand(MY_FIRST_OPERAND + 1); }
1473
1474 /// Get the template parameters from a template alias.
1475 DITemplateParameterArray getTemplateParams() const {
1477 }
1478
1479 /// Get annotations associated with this derived type.
1480 DINodeArray getAnnotations() const {
1482 }
1484 return getOperand(MY_FIRST_OPERAND + 2);
1485 }
1486
1487 /// Get casted version of extra data.
1488 /// @{
1489 LLVM_ABI DIType *getClassType() const;
1490
1494
1496
1498
1499 LLVM_ABI Constant *getConstant() const;
1500
1502 /// @}
1503
1504 static bool classof(const Metadata *MD) {
1505 return MD->getMetadataID() == DIDerivedTypeKind;
1506 }
1507};
1508
1511 return Lhs.RawData == Rhs.RawData;
1512}
1513
1516 return !(Lhs == Rhs);
1517}
1518
1519/// Subrange type. This is somewhat similar to DISubrange, but it
1520/// is also a DIType.
1521class DISubrangeType : public DIType {
1522public:
1524 DIDerivedType *>
1526
1527private:
1528 friend class LLVMContextImpl;
1529 friend class MDNode;
1530
1531 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1532
1533 DISubrangeType(LLVMContext &C, StorageType Storage, unsigned Line,
1535
1536 ~DISubrangeType() = default;
1537
1538 static DISubrangeType *
1539 getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
1543 StorageType Storage, bool ShouldCreate = true) {
1544 auto *SizeInBitsNode = ConstantAsMetadata::get(
1545 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1546 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
1547 Scope, SizeInBitsNode, AlignInBits, Flags, BaseType,
1548 LowerBound, UpperBound, Stride, Bias, Storage, ShouldCreate);
1549 }
1550
1551 LLVM_ABI static DISubrangeType *
1552 getImpl(LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
1554 DIFlags Flags, Metadata *BaseType, Metadata *LowerBound,
1556 StorageType Storage, bool ShouldCreate = true);
1557
1558 TempDISubrangeType cloneImpl() const {
1563 }
1564
1565 LLVM_ABI BoundType convertRawToBound(Metadata *IN) const;
1566
1567public:
1568 DEFINE_MDNODE_GET(DISubrangeType,
1569 (MDString * Name, Metadata *File, unsigned Line,
1576 DEFINE_MDNODE_GET(DISubrangeType,
1583
1584 TempDISubrangeType clone() const { return cloneImpl(); }
1585
1586 /// Get the base type this is derived from.
1588 Metadata *getRawBaseType() const { return getOperand(MY_FIRST_OPERAND); }
1589
1591 return getOperand(MY_FIRST_OPERAND + 1).get();
1592 }
1593
1595 return getOperand(MY_FIRST_OPERAND + 2).get();
1596 }
1597
1599 return getOperand(MY_FIRST_OPERAND + 3).get();
1600 }
1601
1603 return getOperand(MY_FIRST_OPERAND + 4).get();
1604 }
1605
1607 return convertRawToBound(getRawLowerBound());
1608 }
1609
1611 return convertRawToBound(getRawUpperBound());
1612 }
1613
1614 BoundType getStride() const { return convertRawToBound(getRawStride()); }
1615
1616 BoundType getBias() const { return convertRawToBound(getRawBias()); }
1617
1618 static bool classof(const Metadata *MD) {
1619 return MD->getMetadataID() == DISubrangeTypeKind;
1620 }
1621};
1622
1623/// Composite types.
1624///
1625/// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
1626/// TODO: Create a custom, unrelated node for DW_TAG_array_type.
1627class DICompositeType : public DIType {
1628 friend class LLVMContextImpl;
1629 friend class MDNode;
1630
1631 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1632
1633 unsigned RuntimeLang;
1634 std::optional<uint32_t> EnumKind;
1635
1636 DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
1637 unsigned Line, unsigned RuntimeLang, uint32_t AlignInBits,
1639 std::optional<uint32_t> EnumKind, DIFlags Flags,
1641 : DIType(C, DICompositeTypeKind, Storage, Tag, Line, AlignInBits,
1643 RuntimeLang(RuntimeLang), EnumKind(EnumKind) {}
1644 ~DICompositeType() = default;
1645
1646 /// Change fields in place.
1647 void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang,
1649 std::optional<uint32_t> EnumKind, DIFlags Flags) {
1650 assert(isDistinct() && "Only distinct nodes can mutate");
1651 assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate");
1652 this->RuntimeLang = RuntimeLang;
1653 this->EnumKind = EnumKind;
1655 }
1656
1657 static DICompositeType *
1658 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
1659 unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
1661 uint32_t NumExtraInhabitants, DIFlags Flags, DINodeArray Elements,
1662 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1663 DIType *VTableHolder, DITemplateParameterArray TemplateParams,
1664 StringRef Identifier, DIDerivedType *Discriminator,
1666 Metadata *Rank, DINodeArray Annotations, Metadata *BitStride,
1667 StorageType Storage, bool ShouldCreate = true) {
1668 auto *SizeInBitsNode = ConstantAsMetadata::get(
1669 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1670 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1671 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1672 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1673 Line, Scope, BaseType, SizeInBitsNode, AlignInBits,
1674 OffsetInBitsNode, Flags, Elements.get(), RuntimeLang,
1676 getCanonicalMDString(Context, Identifier), Discriminator,
1679 ShouldCreate);
1680 }
1681 static DICompositeType *
1682 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
1683 unsigned Line, Metadata *Scope, Metadata *BaseType,
1684 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
1685 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
1686 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1691 Metadata *BitStride, StorageType Storage, bool ShouldCreate = true) {
1692 auto *SizeInBitsNode = ConstantAsMetadata::get(
1693 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1694 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1695 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1696 return getImpl(Context, Tag, Name, File, Line, Scope, BaseType,
1697 SizeInBitsNode, AlignInBits, OffsetInBitsNode, Flags,
1698 Elements, RuntimeLang, EnumKind, VTableHolder,
1701 NumExtraInhabitants, BitStride, Storage, ShouldCreate);
1702 }
1703 static DICompositeType *
1704 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
1707 uint32_t NumExtraInhabitants, DIFlags Flags, DINodeArray Elements,
1708 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1709 DIType *VTableHolder, DITemplateParameterArray TemplateParams,
1710 StringRef Identifier, DIDerivedType *Discriminator,
1712 Metadata *Rank, DINodeArray Annotations, Metadata *BitStride,
1713 StorageType Storage, bool ShouldCreate = true) {
1714 return getImpl(
1715 Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
1717 RuntimeLang, EnumKind, VTableHolder, TemplateParams.get(),
1720 NumExtraInhabitants, BitStride, Storage, ShouldCreate);
1721 }
1722 LLVM_ABI static DICompositeType *
1723 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
1724 unsigned Line, Metadata *Scope, Metadata *BaseType,
1726 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
1727 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1732 Metadata *BitStride, StorageType Storage, bool ShouldCreate = true);
1733
1734 TempDICompositeType cloneImpl() const {
1735 return getTemporary(
1743 getRawBitStride());
1744 }
1745
1746public:
1748 DICompositeType,
1749 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1752 DINodeArray Elements, unsigned RuntimeLang,
1753 std::optional<uint32_t> EnumKind, DIType *VTableHolder,
1754 DITemplateParameterArray TemplateParams = nullptr,
1756 Metadata *DataLocation = nullptr, Metadata *Associated = nullptr,
1757 Metadata *Allocated = nullptr, Metadata *Rank = nullptr,
1758 DINodeArray Annotations = nullptr, DIType *Specification = nullptr,
1762 RuntimeLang, EnumKind, VTableHolder, TemplateParams, Identifier,
1764 BitStride))
1766 DICompositeType,
1767 (unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
1770 Metadata *Elements, unsigned RuntimeLang,
1771 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1774 Metadata *Associated = nullptr, Metadata *Allocated = nullptr,
1775 Metadata *Rank = nullptr, Metadata *Annotations = nullptr,
1777 Metadata *BitStride = nullptr),
1779 OffsetInBits, Flags, Elements, RuntimeLang, EnumKind, VTableHolder,
1782 BitStride))
1784 DICompositeType,
1785 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1788 DINodeArray Elements, unsigned RuntimeLang,
1789 std::optional<uint32_t> EnumKind, DIType *VTableHolder,
1790 DITemplateParameterArray TemplateParams = nullptr,
1792 Metadata *DataLocation = nullptr, Metadata *Associated = nullptr,
1793 Metadata *Allocated = nullptr, Metadata *Rank = nullptr,
1794 DINodeArray Annotations = nullptr, DIType *Specification = nullptr,
1798 RuntimeLang, EnumKind, VTableHolder, TemplateParams, Identifier,
1800 BitStride))
1802 DICompositeType,
1803 (unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
1806 Metadata *Elements, unsigned RuntimeLang,
1807 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1808 Metadata *TemplateParams = nullptr, MDString *Identifier = nullptr,
1809 Metadata *Discriminator = nullptr, Metadata *DataLocation = nullptr,
1810 Metadata *Associated = nullptr, Metadata *Allocated = nullptr,
1811 Metadata *Rank = nullptr, Metadata *Annotations = nullptr,
1813 Metadata *BitStride = nullptr),
1815 OffsetInBits, Flags, Elements, RuntimeLang, EnumKind, VTableHolder,
1818 BitStride))
1819
1820 TempDICompositeType clone() const { return cloneImpl(); }
1821
1822 /// Get a DICompositeType with the given ODR identifier.
1823 ///
1824 /// If \a LLVMContext::isODRUniquingDebugTypes(), gets the mapped
1825 /// DICompositeType for the given ODR \c Identifier. If none exists, creates
1826 /// a new node.
1827 ///
1828 /// Else, returns \c nullptr.
1829 LLVM_ABI static DICompositeType *
1830 getODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
1831 MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
1835 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1841 MDString &Identifier);
1842
1843 /// Build a DICompositeType with the given ODR identifier.
1844 ///
1845 /// Looks up the mapped DICompositeType for the given ODR \c Identifier. If
1846 /// it doesn't exist, creates a new one. If it does exist and \a
1847 /// isForwardDecl(), and the new arguments would be a definition, mutates the
1848 /// the type in place. In either case, returns the type.
1849 ///
1850 /// If not \a LLVMContext::isODRUniquingDebugTypes(), this function returns
1851 /// nullptr.
1852 LLVM_ABI static DICompositeType *
1853 buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
1854 MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
1858 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1863
1865 DINodeArray getElements() const {
1867 }
1871 DITemplateParameterArray getTemplateParams() const {
1873 }
1875 return getStringOperand(MY_FIRST_OPERAND + 4);
1876 }
1877 unsigned getRuntimeLang() const { return RuntimeLang; }
1878 std::optional<uint32_t> getEnumKind() const { return EnumKind; }
1879
1880 Metadata *getRawBaseType() const { return getOperand(MY_FIRST_OPERAND); }
1881 Metadata *getRawElements() const { return getOperand(MY_FIRST_OPERAND + 1); }
1883 return getOperand(MY_FIRST_OPERAND + 2);
1884 }
1886 return getOperand(MY_FIRST_OPERAND + 3);
1887 }
1889 return getOperandAs<MDString>(MY_FIRST_OPERAND + 4);
1890 }
1892 return getOperand(MY_FIRST_OPERAND + 5);
1893 }
1895 return getOperandAs<DIDerivedType>(MY_FIRST_OPERAND + 5);
1896 }
1898 return getOperand(MY_FIRST_OPERAND + 6);
1899 }
1907 return getOperand(MY_FIRST_OPERAND + 7);
1908 }
1915 Metadata *getRawAllocated() const { return getOperand(MY_FIRST_OPERAND + 8); }
1922 Metadata *getRawRank() const { return getOperand(MY_FIRST_OPERAND + 9); }
1925 return dyn_cast_or_null<ConstantInt>(MD->getValue());
1926 return nullptr;
1927 }
1931
1933 return getOperand(MY_FIRST_OPERAND + 10);
1934 }
1935 DINodeArray getAnnotations() const {
1937 }
1938
1940 return getOperand(MY_FIRST_OPERAND + 11);
1941 }
1945
1947 return getOperand(MY_FIRST_OPERAND + 12);
1948 }
1951 return dyn_cast_or_null<ConstantInt>(MD->getValue());
1952 return nullptr;
1953 }
1954
1955 /// Replace operands.
1956 ///
1957 /// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
1958 /// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
1959 /// of its movement if necessary.
1960 /// @{
1961 void replaceElements(DINodeArray Elements) {
1962#ifndef NDEBUG
1963 for (DINode *Op : getElements())
1964 assert(is_contained(Elements->operands(), Op) &&
1965 "Lost a member during member list replacement");
1966#endif
1967 replaceOperandWith(MY_FIRST_OPERAND + 1, Elements.get());
1968 }
1969
1971 replaceOperandWith(MY_FIRST_OPERAND + 2, VTableHolder);
1972 }
1973
1974 void replaceTemplateParams(DITemplateParameterArray TemplateParams) {
1975 replaceOperandWith(MY_FIRST_OPERAND + 3, TemplateParams.get());
1976 }
1977 /// @}
1978
1979 static bool classof(const Metadata *MD) {
1980 return MD->getMetadataID() == DICompositeTypeKind;
1981 }
1982};
1983
1984/// Type array for a subprogram.
1985///
1986/// TODO: Fold the array of types in directly as operands.
1987class DISubroutineType : public DIType {
1988 friend class LLVMContextImpl;
1989 friend class MDNode;
1990
1991 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1992
1993 /// The calling convention used with DW_AT_calling_convention. Actually of
1994 /// type dwarf::CallingConvention.
1995 uint8_t CC;
1996
1997 DISubroutineType(LLVMContext &C, StorageType Storage, DIFlags Flags,
1999 ~DISubroutineType() = default;
2000
2001 static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
2004 bool ShouldCreate = true) {
2005 return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate);
2006 }
2007 LLVM_ABI static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
2010 bool ShouldCreate = true);
2011
2012 TempDISubroutineType cloneImpl() const {
2014 }
2015
2016public:
2017 DEFINE_MDNODE_GET(DISubroutineType,
2019 (Flags, CC, TypeArray))
2020 DEFINE_MDNODE_GET(DISubroutineType,
2023
2024 TempDISubroutineType clone() const { return cloneImpl(); }
2025 // Returns a new temporary DISubroutineType with updated CC
2026 TempDISubroutineType cloneWithCC(uint8_t CC) const {
2027 auto NewTy = clone();
2028 NewTy->CC = CC;
2029 return NewTy;
2030 }
2031
2032 uint8_t getCC() const { return CC; }
2033
2037
2038 Metadata *getRawTypeArray() const { return getOperand(MY_FIRST_OPERAND); }
2039
2040 static bool classof(const Metadata *MD) {
2041 return MD->getMetadataID() == DISubroutineTypeKind;
2042 }
2043};
2044
2045/// Compile unit.
2046class DICompileUnit : public DIScope {
2047 friend class LLVMContextImpl;
2048 friend class MDNode;
2049
2050public:
2058
2066
2067 LLVM_ABI static std::optional<DebugEmissionKind>
2069 LLVM_ABI static const char *emissionKindString(DebugEmissionKind EK);
2070 LLVM_ABI static std::optional<DebugNameTableKind>
2072 LLVM_ABI static const char *nameTableKindString(DebugNameTableKind PK);
2073
2074private:
2076 unsigned RuntimeVersion;
2078 unsigned EmissionKind;
2079 unsigned NameTableKind;
2080 bool IsOptimized;
2081 bool SplitDebugInlining;
2083 bool RangesBaseAddress;
2084
2087 unsigned RuntimeVersion, unsigned EmissionKind, uint64_t DWOId,
2089 unsigned NameTableKind, bool RangesBaseAddress,
2091 ~DICompileUnit() = default;
2092
2093 static DICompileUnit *
2097 unsigned EmissionKind, DICompositeTypeArray EnumTypes,
2098 DIScopeArray RetainedTypes,
2099 DIGlobalVariableExpressionArray GlobalVariables,
2100 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
2103 StringRef SDK, StorageType Storage, bool ShouldCreate = true) {
2104 return getImpl(
2105 Context, SourceLanguage, File, getCanonicalMDString(Context, Producer),
2108 EnumTypes.get(), RetainedTypes.get(), GlobalVariables.get(),
2111 getCanonicalMDString(Context, SysRoot),
2112 getCanonicalMDString(Context, SDK), Storage, ShouldCreate);
2113 }
2114 LLVM_ABI static DICompileUnit *
2115 getImpl(LLVMContext &Context, DISourceLanguageName SourceLanguage,
2116 Metadata *File, MDString *Producer, bool IsOptimized, MDString *Flags,
2117 unsigned RuntimeVersion, MDString *SplitDebugFilename,
2121 bool DebugInfoForProfiling, unsigned NameTableKind,
2122 bool RangesBaseAddress, MDString *SysRoot, MDString *SDK,
2123 StorageType Storage, bool ShouldCreate = true);
2124
2125 TempDICompileUnit cloneImpl() const {
2126 return getTemporary(
2133 }
2134
2135public:
2136 static void get() = delete;
2137 static void getIfExists() = delete;
2138
2140 DICompileUnit,
2142 bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
2144 DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes,
2145 DIGlobalVariableExpressionArray GlobalVariables,
2146 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
2147 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
2148 DebugNameTableKind NameTableKind, bool RangesBaseAddress,
2150 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
2152 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
2153 DebugInfoForProfiling, (unsigned)NameTableKind, RangesBaseAddress,
2154 SysRoot, SDK))
2156 DICompileUnit,
2158 bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
2162 bool SplitDebugInlining, bool DebugInfoForProfiling,
2163 unsigned NameTableKind, bool RangesBaseAddress, MDString *SysRoot,
2165 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
2167 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
2168 DebugInfoForProfiling, NameTableKind, RangesBaseAddress, SysRoot, SDK))
2169
2170 TempDICompileUnit clone() const { return cloneImpl(); }
2171
2172 DISourceLanguageName getSourceLanguage() const { return SourceLanguage; }
2173 bool isOptimized() const { return IsOptimized; }
2174 unsigned getRuntimeVersion() const { return RuntimeVersion; }
2176 return (DebugEmissionKind)EmissionKind;
2177 }
2179 return EmissionKind == DebugDirectivesOnly;
2180 }
2181 bool getDebugInfoForProfiling() const { return DebugInfoForProfiling; }
2183 return (DebugNameTableKind)NameTableKind;
2184 }
2185 bool getRangesBaseAddress() const { return RangesBaseAddress; }
2187 StringRef getFlags() const { return getStringOperand(2); }
2189 DICompositeTypeArray getEnumTypes() const {
2191 }
2192 DIScopeArray getRetainedTypes() const {
2194 }
2195 DIGlobalVariableExpressionArray getGlobalVariables() const {
2197 }
2198 DIImportedEntityArray getImportedEntities() const {
2200 }
2201 DIMacroNodeArray getMacros() const {
2203 }
2204 uint64_t getDWOId() const { return DWOId; }
2205 void setDWOId(uint64_t DwoId) { DWOId = DwoId; }
2206 bool getSplitDebugInlining() const { return SplitDebugInlining; }
2207 void setSplitDebugInlining(bool SplitDebugInlining) {
2208 this->SplitDebugInlining = SplitDebugInlining;
2209 }
2211 StringRef getSDK() const { return getStringOperand(10); }
2212
2218 Metadata *getRawEnumTypes() const { return getOperand(4); }
2222 Metadata *getRawMacros() const { return getOperand(8); }
2225
2226 /// Replace arrays.
2227 ///
2228 /// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
2229 /// deleted on a uniquing collision. In practice, uniquing collisions on \a
2230 /// DICompileUnit should be fairly rare.
2231 /// @{
2232 void replaceEnumTypes(DICompositeTypeArray N) {
2233 replaceOperandWith(4, N.get());
2234 }
2235 void replaceRetainedTypes(DITypeArray N) { replaceOperandWith(5, N.get()); }
2236 void replaceGlobalVariables(DIGlobalVariableExpressionArray N) {
2237 replaceOperandWith(6, N.get());
2238 }
2239 void replaceImportedEntities(DIImportedEntityArray N) {
2240 replaceOperandWith(7, N.get());
2241 }
2242 void replaceMacros(DIMacroNodeArray N) { replaceOperandWith(8, N.get()); }
2243 /// @}
2244
2245 static bool classof(const Metadata *MD) {
2246 return MD->getMetadataID() == DICompileUnitKind;
2247 }
2248};
2249
2250/// A scope for locals.
2251///
2252/// A legal scope for lexical blocks, local variables, and debug info
2253/// locations. Subclasses are \a DISubprogram, \a DILexicalBlock, and \a
2254/// DILexicalBlockFile.
2255class DILocalScope : public DIScope {
2256protected:
2260 ~DILocalScope() = default;
2261
2262public:
2263 /// Get the subprogram for this scope.
2264 ///
2265 /// Return this if it's an \a DISubprogram; otherwise, look up the scope
2266 /// chain.
2268
2269 /// Traverses the scope chain rooted at RootScope until it hits a Subprogram,
2270 /// recreating the chain with "NewSP" instead.
2271 LLVM_ABI static DILocalScope *
2273 LLVMContext &Ctx,
2275
2276 /// Get the first non DILexicalBlockFile scope of this scope.
2277 ///
2278 /// Return this if it's not a \a DILexicalBlockFIle; otherwise, look up the
2279 /// scope chain.
2281
2282 static bool classof(const Metadata *MD) {
2283 return MD->getMetadataID() == DISubprogramKind ||
2284 MD->getMetadataID() == DILexicalBlockKind ||
2285 MD->getMetadataID() == DILexicalBlockFileKind;
2286 }
2287};
2288
2289/// Subprogram description. Uses SubclassData1.
2290class DISubprogram : public DILocalScope {
2291 friend class LLVMContextImpl;
2292 friend class MDNode;
2293
2294 unsigned Line;
2295 unsigned ScopeLine;
2296 unsigned VirtualIndex;
2297
2298 /// In the MS ABI, the implicit 'this' parameter is adjusted in the prologue
2299 /// of method overrides from secondary bases by this amount. It may be
2300 /// negative.
2301 int ThisAdjustment;
2302
2303public:
2304 /// Debug info subprogram flags.
2306#define HANDLE_DISP_FLAG(ID, NAME) SPFlag##NAME = ID,
2307#define DISP_FLAG_LARGEST_NEEDED
2308#include "llvm/IR/DebugInfoFlags.def"
2309 SPFlagNonvirtual = SPFlagZero,
2310 SPFlagVirtuality = SPFlagVirtual | SPFlagPureVirtual,
2311 LLVM_MARK_AS_BITMASK_ENUM(SPFlagLargest)
2312 };
2313
2314 LLVM_ABI static DISPFlags getFlag(StringRef Flag);
2315 LLVM_ABI static StringRef getFlagString(DISPFlags Flag);
2316
2317 /// Split up a flags bitfield for easier printing.
2318 ///
2319 /// Split \c Flags into \c SplitFlags, a vector of its components. Returns
2320 /// any remaining (unrecognized) bits.
2321 LLVM_ABI static DISPFlags splitFlags(DISPFlags Flags,
2322 SmallVectorImpl<DISPFlags> &SplitFlags);
2323
2324 // Helper for converting old bitfields to new flags word.
2325 LLVM_ABI static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition,
2326 bool IsOptimized,
2327 unsigned Virtuality = SPFlagNonvirtual,
2328 bool IsMainSubprogram = false);
2329
2330private:
2331 DIFlags Flags;
2332 DISPFlags SPFlags;
2333
2334 DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
2335 unsigned ScopeLine, unsigned VirtualIndex, int ThisAdjustment,
2336 DIFlags Flags, DISPFlags SPFlags, bool UsesKeyInstructions,
2338 ~DISubprogram() = default;
2339
2340 static DISubprogram *
2341 getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
2342 StringRef LinkageName, DIFile *File, unsigned Line,
2344 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
2345 DISPFlags SPFlags, DICompileUnit *Unit,
2346 DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
2347 DINodeArray RetainedNodes, DITypeArray ThrownTypes,
2350 bool ShouldCreate = true) {
2351 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
2352 getCanonicalMDString(Context, LinkageName), File, Line, Type,
2354 Flags, SPFlags, Unit, TemplateParams.get(), Declaration,
2355 RetainedNodes.get(), ThrownTypes.get(), Annotations.get(),
2357 UsesKeyInstructions, Storage, ShouldCreate);
2358 }
2359
2360 LLVM_ABI static DISubprogram *
2361 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
2362 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
2363 unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
2364 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
2367 MDString *TargetFuncName, bool UsesKeyInstructions,
2368 StorageType Storage, bool ShouldCreate = true);
2369
2370 TempDISubprogram cloneImpl() const {
2372 getFile(), getLine(), getType(), getScopeLine(),
2373 getContainingType(), getVirtualIndex(),
2374 getThisAdjustment(), getFlags(), getSPFlags(),
2375 getUnit(), getTemplateParams(), getDeclaration(),
2376 getRetainedNodes(), getThrownTypes(), getAnnotations(),
2377 getTargetFuncName(), getKeyInstructionsEnabled());
2378 }
2379
2380public:
2382 DISubprogram,
2384 unsigned Line, DISubroutineType *Type, unsigned ScopeLine,
2385 DIType *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
2386 DIFlags Flags, DISPFlags SPFlags, DICompileUnit *Unit,
2387 DITemplateParameterArray TemplateParams = nullptr,
2388 DISubprogram *Declaration = nullptr, DINodeArray RetainedNodes = nullptr,
2389 DITypeArray ThrownTypes = nullptr, DINodeArray Annotations = nullptr,
2390 StringRef TargetFuncName = "", bool UsesKeyInstructions = false),
2391 (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
2392 VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
2395
2397 DISubprogram,
2399 unsigned Line, Metadata *Type, unsigned ScopeLine,
2400 Metadata *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
2401 DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
2405 bool UsesKeyInstructions = false),
2406 (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
2407 VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
2410
2411 TempDISubprogram clone() const { return cloneImpl(); }
2412
2413 /// Returns a new temporary DISubprogram with updated Flags
2414 TempDISubprogram cloneWithFlags(DIFlags NewFlags) const {
2415 auto NewSP = clone();
2416 NewSP->Flags = NewFlags;
2417 return NewSP;
2418 }
2419
2420 bool getKeyInstructionsEnabled() const { return SubclassData1; }
2421
2422public:
2423 unsigned getLine() const { return Line; }
2424 unsigned getVirtuality() const { return getSPFlags() & SPFlagVirtuality; }
2425 unsigned getVirtualIndex() const { return VirtualIndex; }
2426 int getThisAdjustment() const { return ThisAdjustment; }
2427 unsigned getScopeLine() const { return ScopeLine; }
2428 void setScopeLine(unsigned L) {
2429 assert(isDistinct());
2430 ScopeLine = L;
2431 }
2432 DIFlags getFlags() const { return Flags; }
2433 DISPFlags getSPFlags() const { return SPFlags; }
2434 bool isLocalToUnit() const { return getSPFlags() & SPFlagLocalToUnit; }
2435 bool isDefinition() const { return getSPFlags() & SPFlagDefinition; }
2436 bool isOptimized() const { return getSPFlags() & SPFlagOptimized; }
2437 bool isMainSubprogram() const { return getSPFlags() & SPFlagMainSubprogram; }
2438
2439 bool isArtificial() const { return getFlags() & FlagArtificial; }
2440 bool isPrivate() const {
2441 return (getFlags() & FlagAccessibility) == FlagPrivate;
2442 }
2443 bool isProtected() const {
2444 return (getFlags() & FlagAccessibility) == FlagProtected;
2445 }
2446 bool isPublic() const {
2447 return (getFlags() & FlagAccessibility) == FlagPublic;
2448 }
2449 bool isExplicit() const { return getFlags() & FlagExplicit; }
2450 bool isPrototyped() const { return getFlags() & FlagPrototyped; }
2451 bool areAllCallsDescribed() const {
2452 return getFlags() & FlagAllCallsDescribed;
2453 }
2454 bool isPure() const { return getSPFlags() & SPFlagPure; }
2455 bool isElemental() const { return getSPFlags() & SPFlagElemental; }
2456 bool isRecursive() const { return getSPFlags() & SPFlagRecursive; }
2457 bool isObjCDirect() const { return getSPFlags() & SPFlagObjCDirect; }
2458
2459 /// Check if this is deleted member function.
2460 ///
2461 /// Return true if this subprogram is a C++11 special
2462 /// member function declared deleted.
2463 bool isDeleted() const { return getSPFlags() & SPFlagDeleted; }
2464
2465 /// Check if this is reference-qualified.
2466 ///
2467 /// Return true if this subprogram is a C++11 reference-qualified non-static
2468 /// member function (void foo() &).
2469 bool isLValueReference() const { return getFlags() & FlagLValueReference; }
2470
2471 /// Check if this is rvalue-reference-qualified.
2472 ///
2473 /// Return true if this subprogram is a C++11 rvalue-reference-qualified
2474 /// non-static member function (void foo() &&).
2475 bool isRValueReference() const { return getFlags() & FlagRValueReference; }
2476
2477 /// Check if this is marked as noreturn.
2478 ///
2479 /// Return true if this subprogram is C++11 noreturn or C11 _Noreturn
2480 bool isNoReturn() const { return getFlags() & FlagNoReturn; }
2481
2482 // Check if this routine is a compiler-generated thunk.
2483 //
2484 // Returns true if this subprogram is a thunk generated by the compiler.
2485 bool isThunk() const { return getFlags() & FlagThunk; }
2486
2487 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2488
2489 StringRef getName() const { return getStringOperand(2); }
2490 StringRef getLinkageName() const { return getStringOperand(3); }
2491 /// Only used by clients of CloneFunction, and only right after the cloning.
2492 void replaceLinkageName(MDString *LN) { replaceOperandWith(3, LN); }
2493
2494 DISubroutineType *getType() const {
2495 return cast_or_null<DISubroutineType>(getRawType());
2496 }
2497 DIType *getContainingType() const {
2498 return cast_or_null<DIType>(getRawContainingType());
2499 }
2500 void replaceType(DISubroutineType *Ty) {
2501 assert(isDistinct() && "Only distinct nodes can mutate");
2502 replaceOperandWith(4, Ty);
2503 }
2504
2505 DICompileUnit *getUnit() const {
2506 return cast_or_null<DICompileUnit>(getRawUnit());
2507 }
2508 void replaceUnit(DICompileUnit *CU) { replaceOperandWith(5, CU); }
2509 DITemplateParameterArray getTemplateParams() const {
2510 return cast_or_null<MDTuple>(getRawTemplateParams());
2511 }
2512 DISubprogram *getDeclaration() const {
2513 return cast_or_null<DISubprogram>(getRawDeclaration());
2514 }
2515 void replaceDeclaration(DISubprogram *Decl) { replaceOperandWith(6, Decl); }
2516 DINodeArray getRetainedNodes() const {
2517 return cast_or_null<MDTuple>(getRawRetainedNodes());
2518 }
2519 DITypeArray getThrownTypes() const {
2520 return cast_or_null<MDTuple>(getRawThrownTypes());
2521 }
2522 DINodeArray getAnnotations() const {
2523 return cast_or_null<MDTuple>(getRawAnnotations());
2524 }
2525 StringRef getTargetFuncName() const {
2526 return (getRawTargetFuncName()) ? getStringOperand(12) : StringRef();
2527 }
2528
2529 Metadata *getRawScope() const { return getOperand(1); }
2530 MDString *getRawName() const { return getOperandAs<MDString>(2); }
2531 MDString *getRawLinkageName() const { return getOperandAs<MDString>(3); }
2532 Metadata *getRawType() const { return getOperand(4); }
2533 Metadata *getRawUnit() const { return getOperand(5); }
2534 Metadata *getRawDeclaration() const { return getOperand(6); }
2535 Metadata *getRawRetainedNodes() const { return getOperand(7); }
2536 Metadata *getRawContainingType() const {
2537 return getNumOperands() > 8 ? getOperandAs<Metadata>(8) : nullptr;
2538 }
2539 Metadata *getRawTemplateParams() const {
2540 return getNumOperands() > 9 ? getOperandAs<Metadata>(9) : nullptr;
2541 }
2542 Metadata *getRawThrownTypes() const {
2543 return getNumOperands() > 10 ? getOperandAs<Metadata>(10) : nullptr;
2544 }
2545 Metadata *getRawAnnotations() const {
2546 return getNumOperands() > 11 ? getOperandAs<Metadata>(11) : nullptr;
2547 }
2548 MDString *getRawTargetFuncName() const {
2549 return getNumOperands() > 12 ? getOperandAs<MDString>(12) : nullptr;
2550 }
2551
2552 void replaceRawLinkageName(MDString *LinkageName) {
2554 }
2555 void replaceRetainedNodes(DINodeArray N) {
2556 replaceOperandWith(7, N.get());
2557 }
2558
2559 /// For the given retained node of DISubprogram, applies one of the
2560 /// given functions depending on the type of the node.
2561 template <typename T, typename FuncLVT, typename FuncLabelT,
2562 typename FuncImportedEntityT, typename FuncUnknownT>
2563 static T
2564 visitRetainedNode(const Metadata *N, FuncLVT &&FuncLV, FuncLabelT &&FuncLabel,
2565 FuncImportedEntityT &&FuncIE, FuncUnknownT &&FuncUnknown) {
2566 if (const auto *LV = dyn_cast<DILocalVariable>(N))
2567 return FuncLV(LV);
2568 if (const auto *L = dyn_cast<DILabel>(N))
2569 return FuncLabel(L);
2570 if (const auto *IE = dyn_cast<DIImportedEntity>(N))
2571 return FuncIE(IE);
2572 return FuncUnknown(N);
2573 }
2574
2575 /// Returns the scope of subprogram's retainedNodes.
2576 static const DILocalScope *getRetainedNodeScope(const MDNode *N);
2577 // For use in Verifier.
2578 static const DIScope *getRawRetainedNodeScope(const MDNode *N);
2579
2580 /// For each retained node, applies one of the given functions depending
2581 /// on the type of a node.
2582 template <typename FuncLVT, typename FuncLabelT, typename FuncImportedEntityT>
2583 void forEachRetainedNode(FuncLVT &&FuncLV, FuncLabelT &&FuncLabel,
2584 FuncImportedEntityT &&FuncIE) const {
2585 for (MDNode *N : getRetainedNodes())
2586 visitRetainedNode<void>(N, FuncLV, FuncLabel, FuncIE,
2587 [](const Metadata *N) {
2588 llvm_unreachable("Unexpected retained node!");
2589 });
2590 }
2591
2592 /// Check if this subprogram describes the given function.
2593 ///
2594 /// FIXME: Should this be looking through bitcasts?
2595 LLVM_ABI bool describes(const Function *F) const;
2596
2597 static bool classof(const Metadata *MD) {
2598 return MD->getMetadataID() == DISubprogramKind;
2599 }
2600};
2601
2602/// Debug location.
2603///
2604/// A debug location in source code, used for debug info and otherwise.
2605///
2606/// Uses the SubclassData1, SubclassData16 and SubclassData32
2607/// Metadata slots.
2608
2609class DILocation : public MDNode {
2610 friend class LLVMContextImpl;
2611 friend class MDNode;
2612 uint64_t AtomGroup : 61;
2613 uint64_t AtomRank : 3;
2614
2615 DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
2616 unsigned Column, uint64_t AtomGroup, uint8_t AtomRank,
2618 ~DILocation() { dropAllReferences(); }
2619
2620 LLVM_ABI static DILocation *
2621 getImpl(LLVMContext &Context, unsigned Line, unsigned Column, Metadata *Scope,
2623 uint8_t AtomRank, StorageType Storage, bool ShouldCreate = true);
2624 static DILocation *getImpl(LLVMContext &Context, unsigned Line,
2625 unsigned Column, DILocalScope *Scope,
2628 StorageType Storage, bool ShouldCreate = true) {
2629 return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
2630 static_cast<Metadata *>(InlinedAt), ImplicitCode, AtomGroup,
2631 AtomRank, Storage, ShouldCreate);
2632 }
2633
2634 TempDILocation cloneImpl() const {
2635 // Get the raw scope/inlinedAt since it is possible to invoke this on
2636 // a DILocation containing temporary metadata.
2637 return getTemporary(getContext(), getLine(), getColumn(), getRawScope(),
2638 getRawInlinedAt(), isImplicitCode(), getAtomGroup(),
2639 getAtomRank());
2640 }
2641
2642public:
2643 uint64_t getAtomGroup() const { return AtomGroup; }
2644 uint8_t getAtomRank() const { return AtomRank; }
2645
2646 const DILocation *getWithoutAtom() const {
2647 if (!getAtomGroup() && !getAtomRank())
2648 return this;
2649 return get(getContext(), getLine(), getColumn(), getScope(), getInlinedAt(),
2650 isImplicitCode());
2651 }
2652
2653 // Disallow replacing operands.
2654 void replaceOperandWith(unsigned I, Metadata *New) = delete;
2655
2657 (unsigned Line, unsigned Column, Metadata *Scope,
2658 Metadata *InlinedAt = nullptr, bool ImplicitCode = false,
2659 uint64_t AtomGroup = 0, uint8_t AtomRank = 0),
2660 (Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup,
2661 AtomRank))
2662 DEFINE_MDNODE_GET(DILocation,
2663 (unsigned Line, unsigned Column, DILocalScope *Scope,
2664 DILocation *InlinedAt = nullptr, bool ImplicitCode = false,
2665 uint64_t AtomGroup = 0, uint8_t AtomRank = 0),
2666 (Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup,
2667 AtomRank))
2668
2669 /// Return a (temporary) clone of this.
2670 TempDILocation clone() const { return cloneImpl(); }
2671
2672 unsigned getLine() const { return SubclassData32; }
2673 unsigned getColumn() const { return SubclassData16; }
2674 DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
2675
2676 /// Return the linkage name of Subprogram. If the linkage name is empty,
2677 /// return scope name (the demangled name).
2678 StringRef getSubprogramLinkageName() const {
2679 DISubprogram *SP = getScope()->getSubprogram();
2680 if (!SP)
2681 return "";
2682 auto Name = SP->getLinkageName();
2683 if (!Name.empty())
2684 return Name;
2685 return SP->getName();
2686 }
2687
2688 DILocation *getInlinedAt() const {
2690 }
2691
2692 /// Check if the location corresponds to an implicit code.
2693 /// When the ImplicitCode flag is true, it means that the Instruction
2694 /// with this DILocation has been added by the front-end but it hasn't been
2695 /// written explicitly by the user (e.g. cleanup stuff in C++ put on a closing
2696 /// bracket). It's useful for code coverage to not show a counter on "empty"
2697 /// lines.
2698 bool isImplicitCode() const { return SubclassData1; }
2699 void setImplicitCode(bool ImplicitCode) { SubclassData1 = ImplicitCode; }
2700
2701 DIFile *getFile() const { return getScope()->getFile(); }
2702 StringRef getFilename() const { return getScope()->getFilename(); }
2703 StringRef getDirectory() const { return getScope()->getDirectory(); }
2704 std::optional<StringRef> getSource() const { return getScope()->getSource(); }
2705
2706 /// Walk through \a getInlinedAt() and return the \a DILocation of the
2707 /// outermost call site in the inlining chain.
2708 const DILocation *getInlinedAtLocation() const {
2709 const DILocation *Current = this;
2710 while (const DILocation *Next = Current->getInlinedAt())
2711 Current = Next;
2712 return Current;
2713 }
2714
2715 // Return the \a DILocalScope of the outermost call site in the inlining
2716 // chain.
2717 DILocalScope *getInlinedAtScope() const {
2718 return getInlinedAtLocation()->getScope();
2719 }
2720
2721 /// Get the DWARF discriminator.
2722 ///
2723 /// DWARF discriminators distinguish identical file locations between
2724 /// instructions that are on different basic blocks.
2725 ///
2726 /// There are 3 components stored in discriminator, from lower bits:
2727 ///
2728 /// Base discriminator: assigned by AddDiscriminators pass to identify IRs
2729 /// that are defined by the same source line, but
2730 /// different basic blocks.
2731 /// Duplication factor: assigned by optimizations that will scale down
2732 /// the execution frequency of the original IR.
2733 /// Copy Identifier: assigned by optimizations that clones the IR.
2734 /// Each copy of the IR will be assigned an identifier.
2735 ///
2736 /// Encoding:
2737 ///
2738 /// The above 3 components are encoded into a 32bit unsigned integer in
2739 /// order. If the lowest bit is 1, the current component is empty, and the
2740 /// next component will start in the next bit. Otherwise, the current
2741 /// component is non-empty, and its content starts in the next bit. The
2742 /// value of each components is either 5 bit or 12 bit: if the 7th bit
2743 /// is 0, the bit 2~6 (5 bits) are used to represent the component; if the
2744 /// 7th bit is 1, the bit 2~6 (5 bits) and 8~14 (7 bits) are combined to
2745 /// represent the component. Thus, the number of bits used for a component
2746 /// is either 0 (if it and all the next components are empty); 1 - if it is
2747 /// empty; 7 - if its value is up to and including 0x1f (lsb and msb are both
2748 /// 0); or 14, if its value is up to and including 0x1ff. Note that the last
2749 /// component is also capped at 0x1ff, even in the case when both first
2750 /// components are 0, and we'd technically have 29 bits available.
2751 ///
2752 /// For precise control over the data being encoded in the discriminator,
2753 /// use encodeDiscriminator/decodeDiscriminator.
2754
2755 inline unsigned getDiscriminator() const;
2756
2757 // For the regular discriminator, it stands for all empty components if all
2758 // the lowest 3 bits are non-zero and all higher 29 bits are unused(zero by
2759 // default). Here we fully leverage the higher 29 bits for pseudo probe use.
2760 // This is the format:
2761 // [2:0] - 0x7
2762 // [31:3] - pseudo probe fields guaranteed to be non-zero as a whole
2763 // So if the lower 3 bits is non-zero and the others has at least one
2764 // non-zero bit, it guarantees to be a pseudo probe discriminator
2765 inline static bool isPseudoProbeDiscriminator(unsigned Discriminator) {
2766 return ((Discriminator & 0x7) == 0x7) && (Discriminator & 0xFFFFFFF8);
2767 }
2768
2769 /// Returns a new DILocation with updated \p Discriminator.
2770 inline const DILocation *cloneWithDiscriminator(unsigned Discriminator) const;
2771
2772 /// Returns a new DILocation with updated base discriminator \p BD. Only the
2773 /// base discriminator is set in the new DILocation, the other encoded values
2774 /// are elided.
2775 /// If the discriminator cannot be encoded, the function returns std::nullopt.
2776 inline std::optional<const DILocation *>
2777 cloneWithBaseDiscriminator(unsigned BD) const;
2778
2779 /// Returns the duplication factor stored in the discriminator, or 1 if no
2780 /// duplication factor (or 0) is encoded.
2781 inline unsigned getDuplicationFactor() const;
2782
2783 /// Returns the copy identifier stored in the discriminator.
2784 inline unsigned getCopyIdentifier() const;
2785
2786 /// Returns the base discriminator stored in the discriminator.
2787 inline unsigned getBaseDiscriminator() const;
2788
2789 /// Returns a new DILocation with duplication factor \p DF * current
2790 /// duplication factor encoded in the discriminator. The current duplication
2791 /// factor is as defined by getDuplicationFactor().
2792 /// Returns std::nullopt if encoding failed.
2793 inline std::optional<const DILocation *>
2795
2796 /// Attempts to merge \p LocA and \p LocB into a single location; see
2797 /// DebugLoc::getMergedLocation for more details.
2798 /// NB: When merging the locations of instructions, prefer to use
2799 /// DebugLoc::getMergedLocation(), as an instruction's DebugLoc may contain
2800 /// additional metadata that will not be preserved when merging the unwrapped
2801 /// DILocations.
2803 DILocation *LocB);
2804
2805 /// Try to combine the vector of locations passed as input in a single one.
2806 /// This function applies getMergedLocation() repeatedly left-to-right.
2807 /// NB: When merging the locations of instructions, prefer to use
2808 /// DebugLoc::getMergedLocations(), as an instruction's DebugLoc may contain
2809 /// additional metadata that will not be preserved when merging the unwrapped
2810 /// DILocations.
2811 ///
2812 /// \p Locs: The locations to be merged.
2814
2815 /// Return the masked discriminator value for an input discrimnator value D
2816 /// (i.e. zero out the (B+1)-th and above bits for D (B is 0-base).
2817 // Example: an input of (0x1FF, 7) returns 0xFF.
2818 static unsigned getMaskedDiscriminator(unsigned D, unsigned B) {
2819 return (D & getN1Bits(B));
2820 }
2821
2822 /// Return the bits used for base discriminators.
2823 static unsigned getBaseDiscriminatorBits() { return getBaseFSBitEnd(); }
2824
2825 /// Returns the base discriminator for a given encoded discriminator \p D.
2826 static unsigned
2828 bool IsFSDiscriminator = false) {
2829 // Extract the dwarf base discriminator if it's encoded in the pseudo probe
2830 // discriminator.
2832 auto DwarfBaseDiscriminator =
2834 if (DwarfBaseDiscriminator)
2835 return *DwarfBaseDiscriminator;
2836 // Return the probe id instead of zero for a pseudo probe discriminator.
2837 // This should help differenciate callsites with same line numbers to
2838 // achieve a decent AutoFDO profile under -fpseudo-probe-for-profiling,
2839 // where the original callsite dwarf discriminator is overwritten by
2840 // callsite probe information.
2842 }
2843
2844 if (IsFSDiscriminator)
2847 }
2848
2849 /// Raw encoding of the discriminator. APIs such as cloneWithDuplicationFactor
2850 /// have certain special case behavior (e.g. treating empty duplication factor
2851 /// as the value '1').
2852 /// This API, in conjunction with cloneWithDiscriminator, may be used to
2853 /// encode the raw values provided.
2854 ///
2855 /// \p BD: base discriminator
2856 /// \p DF: duplication factor
2857 /// \p CI: copy index
2858 ///
2859 /// The return is std::nullopt if the values cannot be encoded in 32 bits -
2860 /// for example, values for BD or DF larger than 12 bits. Otherwise, the
2861 /// return is the encoded value.
2862 LLVM_ABI static std::optional<unsigned>
2863 encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI);
2864
2865 /// Raw decoder for values in an encoded discriminator D.
2866 LLVM_ABI static void decodeDiscriminator(unsigned D, unsigned &BD,
2867 unsigned &DF, unsigned &CI);
2868
2869 /// Returns the duplication factor for a given encoded discriminator \p D, or
2870 /// 1 if no value or 0 is encoded.
2871 static unsigned getDuplicationFactorFromDiscriminator(unsigned D) {
2873 return 1;
2875 unsigned Ret = getUnsignedFromPrefixEncoding(D);
2876 if (Ret == 0)
2877 return 1;
2878 return Ret;
2879 }
2880
2881 /// Returns the copy identifier for a given encoded discriminator \p D.
2886
2887 Metadata *getRawScope() const { return getOperand(0); }
2889 if (getNumOperands() == 2)
2890 return getOperand(1);
2891 return nullptr;
2892 }
2893
2894 static bool classof(const Metadata *MD) {
2895 return MD->getMetadataID() == DILocationKind;
2896 }
2897};
2898
2900protected:
2904
2905public:
2907
2908 Metadata *getRawScope() const { return getOperand(1); }
2909
2910 void replaceScope(DIScope *Scope) {
2911 assert(!isUniqued());
2912 setOperand(1, Scope);
2913 }
2914
2915 static bool classof(const Metadata *MD) {
2916 return MD->getMetadataID() == DILexicalBlockKind ||
2917 MD->getMetadataID() == DILexicalBlockFileKind;
2918 }
2919};
2920
2921/// Debug lexical block.
2922///
2923/// Uses the SubclassData32 Metadata slot.
2924class DILexicalBlock : public DILexicalBlockBase {
2925 friend class LLVMContextImpl;
2926 friend class MDNode;
2927
2928 uint16_t Column;
2929
2930 DILexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
2931 unsigned Column, ArrayRef<Metadata *> Ops)
2932 : DILexicalBlockBase(C, DILexicalBlockKind, Storage, Ops),
2933 Column(Column) {
2935 assert(Column < (1u << 16) && "Expected 16-bit column");
2936 }
2937 ~DILexicalBlock() = default;
2938
2939 static DILexicalBlock *getImpl(LLVMContext &Context, DILocalScope *Scope,
2940 DIFile *File, unsigned Line, unsigned Column,
2942 bool ShouldCreate = true) {
2943 return getImpl(Context, static_cast<Metadata *>(Scope),
2944 static_cast<Metadata *>(File), Line, Column, Storage,
2945 ShouldCreate);
2946 }
2947
2948 LLVM_ABI static DILexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
2949 Metadata *File, unsigned Line,
2950 unsigned Column, StorageType Storage,
2951 bool ShouldCreate = true);
2952
2953 TempDILexicalBlock cloneImpl() const {
2955 getColumn());
2956 }
2957
2958public:
2959 DEFINE_MDNODE_GET(DILexicalBlock,
2960 (DILocalScope * Scope, DIFile *File, unsigned Line,
2961 unsigned Column),
2962 (Scope, File, Line, Column))
2963 DEFINE_MDNODE_GET(DILexicalBlock,
2965 unsigned Column),
2966 (Scope, File, Line, Column))
2967
2968 TempDILexicalBlock clone() const { return cloneImpl(); }
2969
2970 unsigned getLine() const { return SubclassData32; }
2971 unsigned getColumn() const { return Column; }
2972
2973 static bool classof(const Metadata *MD) {
2974 return MD->getMetadataID() == DILexicalBlockKind;
2975 }
2976};
2977
2978class DILexicalBlockFile : public DILexicalBlockBase {
2979 friend class LLVMContextImpl;
2980 friend class MDNode;
2981
2982 DILexicalBlockFile(LLVMContext &C, StorageType Storage,
2984 : DILexicalBlockBase(C, DILexicalBlockFileKind, Storage, Ops) {
2986 }
2987 ~DILexicalBlockFile() = default;
2988
2989 static DILexicalBlockFile *getImpl(LLVMContext &Context, DILocalScope *Scope,
2990 DIFile *File, unsigned Discriminator,
2992 bool ShouldCreate = true) {
2993 return getImpl(Context, static_cast<Metadata *>(Scope),
2994 static_cast<Metadata *>(File), Discriminator, Storage,
2995 ShouldCreate);
2996 }
2997
2998 LLVM_ABI static DILexicalBlockFile *getImpl(LLVMContext &Context,
2999 Metadata *Scope, Metadata *File,
3000 unsigned Discriminator,
3002 bool ShouldCreate = true);
3003
3004 TempDILexicalBlockFile cloneImpl() const {
3005 return getTemporary(getContext(), getScope(), getFile(),
3007 }
3008
3009public:
3010 DEFINE_MDNODE_GET(DILexicalBlockFile,
3012 unsigned Discriminator),
3014 DEFINE_MDNODE_GET(DILexicalBlockFile,
3017
3018 TempDILexicalBlockFile clone() const { return cloneImpl(); }
3019 unsigned getDiscriminator() const { return SubclassData32; }
3020
3021 static bool classof(const Metadata *MD) {
3022 return MD->getMetadataID() == DILexicalBlockFileKind;
3023 }
3024};
3025
3026unsigned DILocation::getDiscriminator() const {
3027 if (auto *F = dyn_cast<DILexicalBlockFile>(getScope()))
3028 return F->getDiscriminator();
3029 return 0;
3030}
3031
3032const DILocation *
3033DILocation::cloneWithDiscriminator(unsigned Discriminator) const {
3034 DIScope *Scope = getScope();
3035 // Skip all parent DILexicalBlockFile that already have a discriminator
3036 // assigned. We do not want to have nested DILexicalBlockFiles that have
3037 // multiple discriminators because only the leaf DILexicalBlockFile's
3038 // dominator will be used.
3039 for (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope);
3040 LBF && LBF->getDiscriminator() != 0;
3042 Scope = LBF->getScope();
3043 DILexicalBlockFile *NewScope =
3044 DILexicalBlockFile::get(getContext(), Scope, getFile(), Discriminator);
3045 return DILocation::get(getContext(), getLine(), getColumn(), NewScope,
3046 getInlinedAt(), isImplicitCode(), getAtomGroup(),
3047 getAtomRank());
3048}
3049
3051 return getBaseDiscriminatorFromDiscriminator(getDiscriminator(),
3053}
3054
3056 return getDuplicationFactorFromDiscriminator(getDiscriminator());
3057}
3058
3060 return getCopyIdentifierFromDiscriminator(getDiscriminator());
3061}
3062
3063std::optional<const DILocation *>
3065 unsigned BD, DF, CI;
3066
3068 BD = getBaseDiscriminator();
3069 if (D == BD)
3070 return this;
3071 return cloneWithDiscriminator(D);
3072 }
3073
3074 decodeDiscriminator(getDiscriminator(), BD, DF, CI);
3075 if (D == BD)
3076 return this;
3077 if (std::optional<unsigned> Encoded = encodeDiscriminator(D, DF, CI))
3078 return cloneWithDiscriminator(*Encoded);
3079 return std::nullopt;
3080}
3081
3082std::optional<const DILocation *>
3084 assert(!EnableFSDiscriminator && "FSDiscriminator should not call this.");
3085 // Do no interfere with pseudo probes. Pseudo probe doesn't need duplication
3086 // factor support as samples collected on cloned probes will be aggregated.
3087 // Also pseudo probe at a callsite uses the dwarf discriminator to store
3088 // pseudo probe related information, such as the probe id.
3089 if (isPseudoProbeDiscriminator(getDiscriminator()))
3090 return this;
3091
3093 if (DF <= 1)
3094 return this;
3095
3096 unsigned BD = getBaseDiscriminator();
3097 unsigned CI = getCopyIdentifier();
3098 if (std::optional<unsigned> D = encodeDiscriminator(BD, DF, CI))
3099 return cloneWithDiscriminator(*D);
3100 return std::nullopt;
3101}
3102
3103/// Debug lexical block.
3104///
3105/// Uses the SubclassData1 Metadata slot.
3106class DINamespace : public DIScope {
3107 friend class LLVMContextImpl;
3108 friend class MDNode;
3109
3110 DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols,
3112 ~DINamespace() = default;
3113
3114 static DINamespace *getImpl(LLVMContext &Context, DIScope *Scope,
3116 StorageType Storage, bool ShouldCreate = true) {
3117 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
3118 ExportSymbols, Storage, ShouldCreate);
3119 }
3120 LLVM_ABI static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope,
3123 bool ShouldCreate = true);
3124
3125 TempDINamespace cloneImpl() const {
3126 return getTemporary(getContext(), getScope(), getName(),
3128 }
3129
3130public:
3134 DEFINE_MDNODE_GET(DINamespace,
3137
3138 TempDINamespace clone() const { return cloneImpl(); }
3139
3140 bool getExportSymbols() const { return SubclassData1; }
3142 StringRef getName() const { return getStringOperand(2); }
3143
3144 Metadata *getRawScope() const { return getOperand(1); }
3146
3147 static bool classof(const Metadata *MD) {
3148 return MD->getMetadataID() == DINamespaceKind;
3149 }
3150};
3151
3152/// Represents a module in the programming language, for example, a Clang
3153/// module, or a Fortran module.
3154///
3155/// Uses the SubclassData1 and SubclassData32 Metadata slots.
3156class DIModule : public DIScope {
3157 friend class LLVMContextImpl;
3158 friend class MDNode;
3159
3160 DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo,
3161 bool IsDecl, ArrayRef<Metadata *> Ops);
3162 ~DIModule() = default;
3163
3164 static DIModule *getImpl(LLVMContext &Context, DIFile *File, DIScope *Scope,
3167 unsigned LineNo, bool IsDecl, StorageType Storage,
3168 bool ShouldCreate = true) {
3169 return getImpl(Context, File, Scope, getCanonicalMDString(Context, Name),
3172 getCanonicalMDString(Context, APINotesFile), LineNo, IsDecl,
3173 Storage, ShouldCreate);
3174 }
3175 LLVM_ABI static DIModule *
3176 getImpl(LLVMContext &Context, Metadata *File, Metadata *Scope, MDString *Name,
3178 MDString *APINotesFile, unsigned LineNo, bool IsDecl,
3179 StorageType Storage, bool ShouldCreate = true);
3180
3181 TempDIModule cloneImpl() const {
3183 getConfigurationMacros(), getIncludePath(),
3184 getAPINotesFile(), getLineNo(), getIsDecl());
3185 }
3186
3187public:
3191 StringRef APINotesFile, unsigned LineNo,
3192 bool IsDecl = false),
3194 APINotesFile, LineNo, IsDecl))
3195 DEFINE_MDNODE_GET(DIModule,
3199 bool IsDecl = false),
3201 APINotesFile, LineNo, IsDecl))
3202
3203 TempDIModule clone() const { return cloneImpl(); }
3204
3205 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
3206 StringRef getName() const { return getStringOperand(2); }
3207 StringRef getConfigurationMacros() const { return getStringOperand(3); }
3208 StringRef getIncludePath() const { return getStringOperand(4); }
3209 StringRef getAPINotesFile() const { return getStringOperand(5); }
3210 unsigned getLineNo() const { return SubclassData32; }
3211 bool getIsDecl() const { return SubclassData1; }
3212
3213 Metadata *getRawScope() const { return getOperand(1); }
3214 MDString *getRawName() const { return getOperandAs<MDString>(2); }
3215 MDString *getRawConfigurationMacros() const {
3216 return getOperandAs<MDString>(3);
3217 }
3218 MDString *getRawIncludePath() const { return getOperandAs<MDString>(4); }
3219 MDString *getRawAPINotesFile() const { return getOperandAs<MDString>(5); }
3220
3221 static bool classof(const Metadata *MD) {
3222 return MD->getMetadataID() == DIModuleKind;
3223 }
3224};
3225
3226/// Base class for template parameters.
3227///
3228/// Uses the SubclassData1 Metadata slot.
3230protected:
3232 unsigned Tag, bool IsDefault, ArrayRef<Metadata *> Ops)
3233 : DINode(Context, ID, Storage, Tag, Ops) {
3234 SubclassData1 = IsDefault;
3235 }
3237
3238public:
3239 StringRef getName() const { return getStringOperand(0); }
3241
3243 Metadata *getRawType() const { return getOperand(1); }
3244 bool isDefault() const { return SubclassData1; }
3245
3246 static bool classof(const Metadata *MD) {
3247 return MD->getMetadataID() == DITemplateTypeParameterKind ||
3248 MD->getMetadataID() == DITemplateValueParameterKind;
3249 }
3250};
3251
3252class DITemplateTypeParameter : public DITemplateParameter {
3253 friend class LLVMContextImpl;
3254 friend class MDNode;
3255
3256 DITemplateTypeParameter(LLVMContext &Context, StorageType Storage,
3258 ~DITemplateTypeParameter() = default;
3259
3260 static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
3261 DIType *Type, bool IsDefault,
3263 bool ShouldCreate = true) {
3264 return getImpl(Context, getCanonicalMDString(Context, Name), Type,
3265 IsDefault, Storage, ShouldCreate);
3266 }
3268 getImpl(LLVMContext &Context, MDString *Name, Metadata *Type, bool IsDefault,
3269 StorageType Storage, bool ShouldCreate = true);
3270
3271 TempDITemplateTypeParameter cloneImpl() const {
3272 return getTemporary(getContext(), getName(), getType(), isDefault());
3273 }
3274
3275public:
3276 DEFINE_MDNODE_GET(DITemplateTypeParameter,
3278 (Name, Type, IsDefault))
3279 DEFINE_MDNODE_GET(DITemplateTypeParameter,
3282
3283 TempDITemplateTypeParameter clone() const { return cloneImpl(); }
3284
3285 static bool classof(const Metadata *MD) {
3286 return MD->getMetadataID() == DITemplateTypeParameterKind;
3287 }
3288};
3289
3290class DITemplateValueParameter : public DITemplateParameter {
3291 friend class LLVMContextImpl;
3292 friend class MDNode;
3293
3294 DITemplateValueParameter(LLVMContext &Context, StorageType Storage,
3295 unsigned Tag, bool IsDefault,
3297 : DITemplateParameter(Context, DITemplateValueParameterKind, Storage, Tag,
3298 IsDefault, Ops) {}
3299 ~DITemplateValueParameter() = default;
3300
3301 static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
3303 bool IsDefault, Metadata *Value,
3305 bool ShouldCreate = true) {
3306 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
3307 IsDefault, Value, Storage, ShouldCreate);
3308 }
3309 LLVM_ABI static DITemplateValueParameter *
3310 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
3311 bool IsDefault, Metadata *Value, StorageType Storage,
3312 bool ShouldCreate = true);
3313
3314 TempDITemplateValueParameter cloneImpl() const {
3315 return getTemporary(getContext(), getTag(), getName(), getType(),
3316 isDefault(), getValue());
3317 }
3318
3319public:
3320 DEFINE_MDNODE_GET(DITemplateValueParameter,
3321 (unsigned Tag, StringRef Name, DIType *Type, bool IsDefault,
3322 Metadata *Value),
3323 (Tag, Name, Type, IsDefault, Value))
3324 DEFINE_MDNODE_GET(DITemplateValueParameter,
3328
3329 TempDITemplateValueParameter clone() const { return cloneImpl(); }
3330
3331 Metadata *getValue() const { return getOperand(2); }
3332
3333 static bool classof(const Metadata *MD) {
3334 return MD->getMetadataID() == DITemplateValueParameterKind;
3335 }
3336};
3337
3338/// Base class for variables.
3339///
3340/// Uses the SubclassData32 Metadata slot.
3341class DIVariable : public DINode {
3342 unsigned Line;
3343
3344protected:
3346 signed Line, ArrayRef<Metadata *> Ops,
3347 uint32_t AlignInBits = 0);
3348 ~DIVariable() = default;
3349
3350public:
3351 unsigned getLine() const { return Line; }
3353 StringRef getName() const { return getStringOperand(1); }
3357 uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
3358 /// Determines the size of the variable's type.
3359 LLVM_ABI std::optional<uint64_t> getSizeInBits() const;
3360
3361 /// Return the signedness of this variable's type, or std::nullopt if this
3362 /// type is neither signed nor unsigned.
3363 std::optional<DIBasicType::Signedness> getSignedness() const {
3364 if (auto *BT = dyn_cast<DIBasicType>(getType()))
3365 return BT->getSignedness();
3366 return std::nullopt;
3367 }
3368
3370 if (auto *F = getFile())
3371 return F->getFilename();
3372 return "";
3373 }
3374
3376 if (auto *F = getFile())
3377 return F->getDirectory();
3378 return "";
3379 }
3380
3381 std::optional<StringRef> getSource() const {
3382 if (auto *F = getFile())
3383 return F->getSource();
3384 return std::nullopt;
3385 }
3386
3387 Metadata *getRawScope() const { return getOperand(0); }
3389 Metadata *getRawFile() const { return getOperand(2); }
3390 Metadata *getRawType() const { return getOperand(3); }
3391
3392 static bool classof(const Metadata *MD) {
3393 return MD->getMetadataID() == DILocalVariableKind ||
3394 MD->getMetadataID() == DIGlobalVariableKind;
3395 }
3396};
3397
3398/// DWARF expression.
3399///
3400/// This is (almost) a DWARF expression that modifies the location of a
3401/// variable, or the location of a single piece of a variable, or (when using
3402/// DW_OP_stack_value) is the constant variable value.
3403///
3404/// TODO: Co-allocate the expression elements.
3405/// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
3406/// storage types.
3407class DIExpression : public MDNode {
3408 friend class LLVMContextImpl;
3409 friend class MDNode;
3410
3411 std::vector<uint64_t> Elements;
3412
3413 DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
3414 : MDNode(C, DIExpressionKind, Storage, {}),
3415 Elements(Elements.begin(), Elements.end()) {}
3416 ~DIExpression() = default;
3417
3418 LLVM_ABI static DIExpression *getImpl(LLVMContext &Context,
3419 ArrayRef<uint64_t> Elements,
3421 bool ShouldCreate = true);
3422
3423 TempDIExpression cloneImpl() const {
3424 return getTemporary(getContext(), getElements());
3425 }
3426
3427public:
3428 DEFINE_MDNODE_GET(DIExpression, (ArrayRef<uint64_t> Elements), (Elements))
3429
3430 TempDIExpression clone() const { return cloneImpl(); }
3431
3432 ArrayRef<uint64_t> getElements() const { return Elements; }
3433
3434 unsigned getNumElements() const { return Elements.size(); }
3435
3436 uint64_t getElement(unsigned I) const {
3437 assert(I < Elements.size() && "Index out of range");
3438 return Elements[I];
3439 }
3440
3442 /// Determine whether this represents a constant value, if so
3443 // return it's sign information.
3444 LLVM_ABI std::optional<SignedOrUnsignedConstant> isConstant() const;
3445
3446 /// Return the number of unique location operands referred to (via
3447 /// DW_OP_LLVM_arg) in this expression; this is not necessarily the number of
3448 /// instances of DW_OP_LLVM_arg within the expression.
3449 /// For example, for the expression:
3450 /// (DW_OP_LLVM_arg 0, DW_OP_LLVM_arg 1, DW_OP_plus,
3451 /// DW_OP_LLVM_arg 0, DW_OP_mul)
3452 /// This function would return 2, as there are two unique location operands
3453 /// (0 and 1).
3455
3457
3460
3461 /// A lightweight wrapper around an expression operand.
3462 ///
3463 /// TODO: Store arguments directly and change \a DIExpression to store a
3464 /// range of these.
3466 const uint64_t *Op = nullptr;
3467
3468 public:
3469 ExprOperand() = default;
3470 explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
3471
3472 const uint64_t *get() const { return Op; }
3473
3474 /// Get the operand code.
3475 uint64_t getOp() const { return *Op; }
3476
3477 /// Get an argument to the operand.
3478 ///
3479 /// Never returns the operand itself.
3480 uint64_t getArg(unsigned I) const { return Op[I + 1]; }
3481
3482 unsigned getNumArgs() const { return getSize() - 1; }
3483
3484 /// Return the size of the operand.
3485 ///
3486 /// Return the number of elements in the operand (1 + args).
3487 LLVM_ABI unsigned getSize() const;
3488
3489 /// Append the elements of this operand to \p V.
3491 V.append(get(), get() + getSize());
3492 }
3493 };
3494
3495 /// An iterator for expression operands.
3497 ExprOperand Op;
3498
3499 public:
3500 using iterator_category = std::input_iterator_tag;
3502 using difference_type = std::ptrdiff_t;
3505
3506 expr_op_iterator() = default;
3508
3509 element_iterator getBase() const { return Op.get(); }
3510 const ExprOperand &operator*() const { return Op; }
3511 const ExprOperand *operator->() const { return &Op; }
3512
3514 increment();
3515 return *this;
3516 }
3518 expr_op_iterator T(*this);
3519 increment();
3520 return T;
3521 }
3522
3523 /// Get the next iterator.
3524 ///
3525 /// \a std::next() doesn't work because this is technically an
3526 /// input_iterator, but it's a perfectly valid operation. This is an
3527 /// accessor to provide the same functionality.
3528 expr_op_iterator getNext() const { return ++expr_op_iterator(*this); }
3529
3530 bool operator==(const expr_op_iterator &X) const {
3531 return getBase() == X.getBase();
3532 }
3533 bool operator!=(const expr_op_iterator &X) const {
3534 return getBase() != X.getBase();
3535 }
3536
3537 private:
3538 void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
3539 };
3540
3541 /// Visit the elements via ExprOperand wrappers.
3542 ///
3543 /// These range iterators visit elements through \a ExprOperand wrappers.
3544 /// This is not guaranteed to be a valid range unless \a isValid() gives \c
3545 /// true.
3546 ///
3547 /// \pre \a isValid() gives \c true.
3548 /// @{
3558 /// @}
3559
3560 LLVM_ABI bool isValid() const;
3561
3562 static bool classof(const Metadata *MD) {
3563 return MD->getMetadataID() == DIExpressionKind;
3564 }
3565
3566 /// Return whether the first element a DW_OP_deref.
3567 LLVM_ABI bool startsWithDeref() const;
3568
3569 /// Return whether there is exactly one operator and it is a DW_OP_deref;
3570 LLVM_ABI bool isDeref() const;
3571
3573
3574 /// Return the number of bits that have an active value, i.e. those that
3575 /// aren't known to be zero/sign (depending on the type of Var) and which
3576 /// are within the size of this fragment (if it is one). If we can't deduce
3577 /// anything from the expression this will return the size of Var.
3578 LLVM_ABI std::optional<uint64_t> getActiveBits(DIVariable *Var);
3579
3580 /// Retrieve the details of this fragment expression.
3581 LLVM_ABI static std::optional<FragmentInfo>
3583
3584 /// Retrieve the details of this fragment expression.
3585 std::optional<FragmentInfo> getFragmentInfo() const {
3587 }
3588
3589 /// Return whether this is a piece of an aggregate variable.
3590 bool isFragment() const { return getFragmentInfo().has_value(); }
3591
3592 /// Return whether this is an implicit location description.
3593 LLVM_ABI bool isImplicit() const;
3594
3595 /// Return whether the location is computed on the expression stack, meaning
3596 /// it cannot be a simple register location.
3597 LLVM_ABI bool isComplex() const;
3598
3599 /// Return whether the evaluated expression makes use of a single location at
3600 /// the start of the expression, i.e. if it contains only a single
3601 /// DW_OP_LLVM_arg op as its first operand, or if it contains none.
3603
3604 /// Returns a reference to the elements contained in this expression, skipping
3605 /// past the leading `DW_OP_LLVM_arg, 0` if one is present.
3606 /// Similar to `convertToNonVariadicExpression`, but faster and cheaper - it
3607 /// does not check whether the expression is a single-location expression, and
3608 /// it returns elements rather than creating a new DIExpression.
3609 LLVM_ABI std::optional<ArrayRef<uint64_t>>
3611
3612 /// Removes all elements from \p Expr that do not apply to an undef debug
3613 /// value, which includes every operator that computes the value/location on
3614 /// the DWARF stack, including any DW_OP_LLVM_arg elements (making the result
3615 /// of this function always a single-location expression) while leaving
3616 /// everything that defines what the computed value applies to, i.e. the
3617 /// fragment information.
3618 LLVM_ABI static const DIExpression *
3620
3621 /// If \p Expr is a non-variadic expression (i.e. one that does not contain
3622 /// DW_OP_LLVM_arg), returns \p Expr converted to variadic form by adding a
3623 /// leading [DW_OP_LLVM_arg, 0] to the expression; otherwise returns \p Expr.
3624 LLVM_ABI static const DIExpression *
3626
3627 /// If \p Expr is a valid single-location expression, i.e. it refers to only a
3628 /// single debug operand at the start of the expression, then return that
3629 /// expression in a non-variadic form by removing DW_OP_LLVM_arg from the
3630 /// expression if it is present; otherwise returns std::nullopt.
3631 /// See also `getSingleLocationExpressionElements` above, which skips
3632 /// checking `isSingleLocationExpression` and returns a list of elements
3633 /// rather than a DIExpression.
3634 LLVM_ABI static std::optional<const DIExpression *>
3636
3637 /// Inserts the elements of \p Expr into \p Ops modified to a canonical form,
3638 /// which uses DW_OP_LLVM_arg (i.e. is a variadic expression) and folds the
3639 /// implied derefence from the \p IsIndirect flag into the expression. This
3640 /// allows us to check equivalence between expressions with differing
3641 /// directness or variadicness.
3643 const DIExpression *Expr,
3644 bool IsIndirect);
3645
3646 /// Determines whether two debug values should produce equivalent DWARF
3647 /// expressions, using their DIExpressions and directness, ignoring the
3648 /// differences between otherwise identical expressions in variadic and
3649 /// non-variadic form and not considering the debug operands.
3650 /// \p FirstExpr is the DIExpression for the first debug value.
3651 /// \p FirstIndirect should be true if the first debug value is indirect; in
3652 /// IR this should be true for dbg.declare intrinsics and false for
3653 /// dbg.values, and in MIR this should be true only for DBG_VALUE instructions
3654 /// whose second operand is an immediate value.
3655 /// \p SecondExpr and \p SecondIndirect have the same meaning as the prior
3656 /// arguments, but apply to the second debug value.
3657 LLVM_ABI static bool isEqualExpression(const DIExpression *FirstExpr,
3658 bool FirstIndirect,
3659 const DIExpression *SecondExpr,
3660 bool SecondIndirect);
3661
3662 /// Append \p Ops with operations to apply the \p Offset.
3664 int64_t Offset);
3665
3666 /// If this is a constant offset, extract it. If there is no expression,
3667 /// return true with an offset of zero.
3668 LLVM_ABI bool extractIfOffset(int64_t &Offset) const;
3669
3670 /// Assuming that the expression operates on an address, extract a constant
3671 /// offset and the successive ops. Return false if the expression contains
3672 /// any incompatible ops (including non-zero DW_OP_LLVM_args - only a single
3673 /// address operand to the expression is permitted).
3674 ///
3675 /// We don't try very hard to interpret the expression because we assume that
3676 /// foldConstantMath has canonicalized the expression.
3677 LLVM_ABI bool
3678 extractLeadingOffset(int64_t &OffsetInBytes,
3679 SmallVectorImpl<uint64_t> &RemainingOps) const;
3680
3681 /// Returns true iff this DIExpression contains at least one instance of
3682 /// `DW_OP_LLVM_arg, n` for all n in [0, N).
3683 LLVM_ABI bool hasAllLocationOps(unsigned N) const;
3684
3685 /// Checks if the last 4 elements of the expression are DW_OP_constu <DWARF
3686 /// Address Space> DW_OP_swap DW_OP_xderef and extracts the <DWARF Address
3687 /// Space>.
3688 LLVM_ABI static const DIExpression *
3689 extractAddressClass(const DIExpression *Expr, unsigned &AddrClass);
3690
3691 /// Used for DIExpression::prepend.
3694 DerefBefore = 1 << 0,
3695 DerefAfter = 1 << 1,
3696 StackValue = 1 << 2,
3697 EntryValue = 1 << 3
3698 };
3699
3700 /// Prepend \p DIExpr with a deref and offset operation and optionally turn it
3701 /// into a stack value or/and an entry value.
3702 LLVM_ABI static DIExpression *prepend(const DIExpression *Expr, uint8_t Flags,
3703 int64_t Offset = 0);
3704
3705 /// Prepend \p DIExpr with the given opcodes and optionally turn it into a
3706 /// stack value.
3709 bool StackValue = false,
3710 bool EntryValue = false);
3711
3712 /// Append the opcodes \p Ops to \p DIExpr. Unlike \ref appendToStack, the
3713 /// returned expression is a stack value only if \p DIExpr is a stack value.
3714 /// If \p DIExpr describes a fragment, the returned expression will describe
3715 /// the same fragment.
3716 LLVM_ABI static DIExpression *append(const DIExpression *Expr,
3718
3719 /// Convert \p DIExpr into a stack value if it isn't one already by appending
3720 /// DW_OP_deref if needed, and appending \p Ops to the resulting expression.
3721 /// If \p DIExpr describes a fragment, the returned expression will describe
3722 /// the same fragment.
3723 LLVM_ABI static DIExpression *appendToStack(const DIExpression *Expr,
3725
3726 /// Create a copy of \p Expr by appending the given list of \p Ops to each
3727 /// instance of the operand `DW_OP_LLVM_arg, \p ArgNo`. This is used to
3728 /// modify a specific location used by \p Expr, such as when salvaging that
3729 /// location.
3732 unsigned ArgNo,
3733 bool StackValue = false);
3734
3735 /// Create a copy of \p Expr with each instance of
3736 /// `DW_OP_LLVM_arg, \p OldArg` replaced with `DW_OP_LLVM_arg, \p NewArg`,
3737 /// and each instance of `DW_OP_LLVM_arg, Arg` with `DW_OP_LLVM_arg, Arg - 1`
3738 /// for all Arg > \p OldArg.
3739 /// This is used when replacing one of the operands of a debug value list
3740 /// with another operand in the same list and deleting the old operand.
3741 LLVM_ABI static DIExpression *replaceArg(const DIExpression *Expr,
3742 uint64_t OldArg, uint64_t NewArg);
3743
3744 /// Create a DIExpression to describe one part of an aggregate variable that
3745 /// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation
3746 /// will be appended to the elements of \c Expr. If \c Expr already contains
3747 /// a \c DW_OP_LLVM_fragment \c OffsetInBits is interpreted as an offset
3748 /// into the existing fragment.
3749 ///
3750 /// \param OffsetInBits Offset of the piece in bits.
3751 /// \param SizeInBits Size of the piece in bits.
3752 /// \return Creating a fragment expression may fail if \c Expr
3753 /// contains arithmetic operations that would be
3754 /// truncated.
3755 LLVM_ABI static std::optional<DIExpression *>
3756 createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits,
3757 unsigned SizeInBits);
3758
3759 /// Determine the relative position of the fragments passed in.
3760 /// Returns -1 if this is entirely before Other, 0 if this and Other overlap,
3761 /// 1 if this is entirely after Other.
3762 static int fragmentCmp(const FragmentInfo &A, const FragmentInfo &B) {
3763 uint64_t l1 = A.OffsetInBits;
3764 uint64_t l2 = B.OffsetInBits;
3765 uint64_t r1 = l1 + A.SizeInBits;
3766 uint64_t r2 = l2 + B.SizeInBits;
3767 if (r1 <= l2)
3768 return -1;
3769 else if (r2 <= l1)
3770 return 1;
3771 else
3772 return 0;
3773 }
3774
3775 /// Computes a fragment, bit-extract operation if needed, and new constant
3776 /// offset to describe a part of a variable covered by some memory.
3777 ///
3778 /// The memory region starts at:
3779 /// \p SliceStart + \p SliceOffsetInBits
3780 /// And is size:
3781 /// \p SliceSizeInBits
3782 ///
3783 /// The location of the existing variable fragment \p VarFrag is:
3784 /// \p DbgPtr + \p DbgPtrOffsetInBits + \p DbgExtractOffsetInBits.
3785 ///
3786 /// It is intended that these arguments are derived from a debug record:
3787 /// - \p DbgPtr is the (single) DIExpression operand.
3788 /// - \p DbgPtrOffsetInBits is the constant offset applied to \p DbgPtr.
3789 /// - \p DbgExtractOffsetInBits is the offset from a
3790 /// DW_OP_LLVM_bit_extract_[sz]ext operation.
3791 ///
3792 /// Results and return value:
3793 /// - Return false if the result can't be calculated for any reason.
3794 /// - \p Result is set to nullopt if the intersect equals \p VarFarg.
3795 /// - \p Result contains a zero-sized fragment if there's no intersect.
3796 /// - \p OffsetFromLocationInBits is set to the difference between the first
3797 /// bit of the variable location and the first bit of the slice. The
3798 /// magnitude of a negative value therefore indicates the number of bits
3799 /// into the variable fragment that the memory region begins.
3800 ///
3801 /// We don't pass in a debug record directly to get the constituent parts
3802 /// and offsets because different debug records store the information in
3803 /// different places (dbg_assign has two DIExpressions - one contains the
3804 /// fragment info for the entire intrinsic).
3806 const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits,
3807 uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits,
3808 int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag,
3809 std::optional<DIExpression::FragmentInfo> &Result,
3810 int64_t &OffsetFromLocationInBits);
3811
3812 using ExtOps = std::array<uint64_t, 6>;
3813
3814 /// Returns the ops for a zero- or sign-extension in a DIExpression.
3815 LLVM_ABI static ExtOps getExtOps(unsigned FromSize, unsigned ToSize,
3816 bool Signed);
3817
3818 /// Append a zero- or sign-extension to \p Expr. Converts the expression to a
3819 /// stack value if it isn't one already.
3820 LLVM_ABI static DIExpression *appendExt(const DIExpression *Expr,
3821 unsigned FromSize, unsigned ToSize,
3822 bool Signed);
3823
3824 /// Check if fragments overlap between a pair of FragmentInfos.
3825 static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B) {
3826 return fragmentCmp(A, B) == 0;
3827 }
3828
3829 /// Determine the relative position of the fragments described by this
3830 /// DIExpression and \p Other. Calls static fragmentCmp implementation.
3831 int fragmentCmp(const DIExpression *Other) const {
3832 auto Fragment1 = *getFragmentInfo();
3833 auto Fragment2 = *Other->getFragmentInfo();
3834 return fragmentCmp(Fragment1, Fragment2);
3835 }
3836
3837 /// Check if fragments overlap between this DIExpression and \p Other.
3838 bool fragmentsOverlap(const DIExpression *Other) const {
3839 if (!isFragment() || !Other->isFragment())
3840 return true;
3841 return fragmentCmp(Other) == 0;
3842 }
3843
3844 /// Check if the expression consists of exactly one entry value operand.
3845 /// (This is the only configuration of entry values that is supported.)
3846 LLVM_ABI bool isEntryValue() const;
3847
3848 /// Try to shorten an expression with an initial constant operand.
3849 /// Returns a new expression and constant on success, or the original
3850 /// expression and constant on failure.
3851 LLVM_ABI std::pair<DIExpression *, const ConstantInt *>
3852 constantFold(const ConstantInt *CI);
3853
3854 /// Try to shorten an expression with constant math operations that can be
3855 /// evaluated at compile time. Returns a new expression on success, or the old
3856 /// expression if there is nothing to be reduced.
3858};
3859
3862 return std::tie(A.SizeInBits, A.OffsetInBits) ==
3863 std::tie(B.SizeInBits, B.OffsetInBits);
3864}
3865
3868 return std::tie(A.SizeInBits, A.OffsetInBits) <
3869 std::tie(B.SizeInBits, B.OffsetInBits);
3870}
3871
3872template <> struct DenseMapInfo<DIExpression::FragmentInfo> {
3874 static const uint64_t MaxVal = std::numeric_limits<uint64_t>::max();
3875
3876 static inline FragInfo getEmptyKey() { return {MaxVal, MaxVal}; }
3877
3878 static inline FragInfo getTombstoneKey() { return {MaxVal - 1, MaxVal - 1}; }
3879
3880 static unsigned getHashValue(const FragInfo &Frag) {
3881 return (Frag.SizeInBits & 0xffff) << 16 | (Frag.OffsetInBits & 0xffff);
3882 }
3883
3884 static bool isEqual(const FragInfo &A, const FragInfo &B) { return A == B; }
3885};
3886
3887/// Holds a DIExpression and keeps track of how many operands have been consumed
3888/// so far.
3891
3892public:
3894 if (!Expr) {
3895 assert(Start == End);
3896 return;
3897 }
3898 Start = Expr->expr_op_begin();
3899 End = Expr->expr_op_end();
3900 }
3901
3903 : Start(Expr.begin()), End(Expr.end()) {}
3904
3906
3907 /// Consume one operation.
3908 std::optional<DIExpression::ExprOperand> take() {
3909 if (Start == End)
3910 return std::nullopt;
3911 return *(Start++);
3912 }
3913
3914 /// Consume N operations.
3915 void consume(unsigned N) { std::advance(Start, N); }
3916
3917 /// Return the current operation.
3918 std::optional<DIExpression::ExprOperand> peek() const {
3919 if (Start == End)
3920 return std::nullopt;
3921 return *(Start);
3922 }
3923
3924 /// Return the next operation.
3925 std::optional<DIExpression::ExprOperand> peekNext() const {
3926 if (Start == End)
3927 return std::nullopt;
3928
3929 auto Next = Start.getNext();
3930 if (Next == End)
3931 return std::nullopt;
3932
3933 return *Next;
3934 }
3935
3936 std::optional<DIExpression::ExprOperand> peekNextN(unsigned N) const {
3937 if (Start == End)
3938 return std::nullopt;
3940 for (unsigned I = 0; I < N; I++) {
3941 Nth = Nth.getNext();
3942 if (Nth == End)
3943 return std::nullopt;
3944 }
3945 return *Nth;
3946 }
3947
3949 this->Start = DIExpression::expr_op_iterator(Expr.begin());
3950 this->End = DIExpression::expr_op_iterator(Expr.end());
3951 }
3952
3953 /// Determine whether there are any operations left in this expression.
3954 operator bool() const { return Start != End; }
3955
3956 DIExpression::expr_op_iterator begin() const { return Start; }
3957 DIExpression::expr_op_iterator end() const { return End; }
3958
3959 /// Retrieve the fragment information, if any.
3960 std::optional<DIExpression::FragmentInfo> getFragmentInfo() const {
3961 return DIExpression::getFragmentInfo(Start, End);
3962 }
3963};
3964
3965/// Global variables.
3966///
3967/// TODO: Remove DisplayName. It's always equal to Name.
3968class DIGlobalVariable : public DIVariable {
3969 friend class LLVMContextImpl;
3970 friend class MDNode;
3971
3972 bool IsLocalToUnit;
3973 bool IsDefinition;
3974
3975 DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
3976 bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
3978 : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
3979 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
3980 ~DIGlobalVariable() = default;
3981
3982 static DIGlobalVariable *
3983 getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
3984 StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type,
3985 bool IsLocalToUnit, bool IsDefinition,
3988 bool ShouldCreate = true) {
3989 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
3990 getCanonicalMDString(Context, LinkageName), File, Line, Type,
3993 Annotations.get(), Storage, ShouldCreate);
3994 }
3995 LLVM_ABI static DIGlobalVariable *
3996 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
3997 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
3998 bool IsLocalToUnit, bool IsDefinition,
4001 bool ShouldCreate = true);
4002
4003 TempDIGlobalVariable cloneImpl() const {
4008 getAnnotations());
4009 }
4010
4011public:
4013 DIGlobalVariable,
4015 unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition,
4017 uint32_t AlignInBits, DINodeArray Annotations),
4018 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
4021 DIGlobalVariable,
4023 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
4026 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
4028
4029 TempDIGlobalVariable clone() const { return cloneImpl(); }
4030
4031 bool isLocalToUnit() const { return IsLocalToUnit; }
4032 bool isDefinition() const { return IsDefinition; }
4038 DINodeArray getAnnotations() const {
4040 }
4041
4046 Metadata *getRawAnnotations() const { return getOperand(8); }
4047
4048 static bool classof(const Metadata *MD) {
4049 return MD->getMetadataID() == DIGlobalVariableKind;
4050 }
4051};
4052
4053/// Debug common block.
4054///
4055/// Uses the SubclassData32 Metadata slot.
4056class DICommonBlock : public DIScope {
4057 friend class LLVMContextImpl;
4058 friend class MDNode;
4059
4060 DICommonBlock(LLVMContext &Context, StorageType Storage, unsigned LineNo,
4062
4063 static DICommonBlock *getImpl(LLVMContext &Context, DIScope *Scope,
4065 DIFile *File, unsigned LineNo,
4066 StorageType Storage, bool ShouldCreate = true) {
4067 return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name),
4068 File, LineNo, Storage, ShouldCreate);
4069 }
4070 LLVM_ABI static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope,
4072 Metadata *File, unsigned LineNo,
4074 bool ShouldCreate = true);
4075
4076 TempDICommonBlock cloneImpl() const {
4078 getFile(), getLineNo());
4079 }
4080
4081public:
4082 DEFINE_MDNODE_GET(DICommonBlock,
4084 DIFile *File, unsigned LineNo),
4085 (Scope, Decl, Name, File, LineNo))
4086 DEFINE_MDNODE_GET(DICommonBlock,
4088 Metadata *File, unsigned LineNo),
4090
4091 TempDICommonBlock clone() const { return cloneImpl(); }
4092
4097 StringRef getName() const { return getStringOperand(2); }
4099 unsigned getLineNo() const { return SubclassData32; }
4100
4101 Metadata *getRawScope() const { return getOperand(0); }
4102 Metadata *getRawDecl() const { return getOperand(1); }
4104 Metadata *getRawFile() const { return getOperand(3); }
4105
4106 static bool classof(const Metadata *MD) {
4107 return MD->getMetadataID() == DICommonBlockKind;
4108 }
4109};
4110
4111/// Local variable.
4112///
4113/// TODO: Split up flags.
4114class DILocalVariable : public DIVariable {
4115 friend class LLVMContextImpl;
4116 friend class MDNode;
4117
4118 unsigned Arg : 16;
4119 DIFlags Flags;
4120
4121 DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
4122 unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
4124 : DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
4125 Arg(Arg), Flags(Flags) {
4126 assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range");
4127 }
4128 ~DILocalVariable() = default;
4129
4130 static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
4131 StringRef Name, DIFile *File, unsigned Line,
4132 DIType *Type, unsigned Arg, DIFlags Flags,
4133 uint32_t AlignInBits, DINodeArray Annotations,
4135 bool ShouldCreate = true) {
4136 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
4137 Line, Type, Arg, Flags, AlignInBits, Annotations.get(),
4138 Storage, ShouldCreate);
4139 }
4140 LLVM_ABI static DILocalVariable *
4141 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File,
4142 unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags,
4144 bool ShouldCreate = true);
4145
4146 TempDILocalVariable cloneImpl() const {
4148 getLine(), getType(), getArg(), getFlags(),
4150 }
4151
4152public:
4153 DEFINE_MDNODE_GET(DILocalVariable,
4155 unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags,
4156 uint32_t AlignInBits, DINodeArray Annotations),
4157 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
4158 Annotations))
4159 DEFINE_MDNODE_GET(DILocalVariable,
4161 unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags,
4163 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
4164 Annotations))
4165
4166 TempDILocalVariable clone() const { return cloneImpl(); }
4167
4168 /// Get the local scope for this variable.
4169 ///
4170 /// Variables must be defined in a local scope.
4174
4175 bool isParameter() const { return Arg; }
4176 unsigned getArg() const { return Arg; }
4177 DIFlags getFlags() const { return Flags; }
4178
4179 DINodeArray getAnnotations() const {
4181 }
4182 Metadata *getRawAnnotations() const { return getOperand(4); }
4183
4184 bool isArtificial() const { return getFlags() & FlagArtificial; }
4185 bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
4186
4187 /// Check that a location is valid for this variable.
4188 ///
4189 /// Check that \c DL exists, is in the same subprogram, and has the same
4190 /// inlined-at location as \c this. (Otherwise, it's not a valid attachment
4191 /// to a \a DbgInfoIntrinsic.)
4193 return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
4194 }
4195
4196 static bool classof(const Metadata *MD) {
4197 return MD->getMetadataID() == DILocalVariableKind;
4198 }
4199};
4200
4201/// Label.
4202///
4203/// Uses the SubclassData32 Metadata slot.
4204class DILabel : public DINode {
4205 friend class LLVMContextImpl;
4206 friend class MDNode;
4207
4208 unsigned Column;
4209 std::optional<unsigned> CoroSuspendIdx;
4210 bool IsArtificial;
4211
4212 DILabel(LLVMContext &C, StorageType Storage, unsigned Line, unsigned Column,
4213 bool IsArtificial, std::optional<unsigned> CoroSuspendIdx,
4215 ~DILabel() = default;
4216
4217 static DILabel *getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
4218 DIFile *File, unsigned Line, unsigned Column,
4219 bool IsArtificial,
4220 std::optional<unsigned> CoroSuspendIdx,
4221 StorageType Storage, bool ShouldCreate = true) {
4222 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
4223 Line, Column, IsArtificial, CoroSuspendIdx, Storage,
4224 ShouldCreate);
4225 }
4226 LLVM_ABI static DILabel *
4227 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File,
4228 unsigned Line, unsigned Column, bool IsArtificial,
4229 std::optional<unsigned> CoroSuspendIdx, StorageType Storage,
4230 bool ShouldCreate = true);
4231
4232 TempDILabel cloneImpl() const {
4236 }
4237
4238public:
4241 unsigned Line, unsigned Column, bool IsArtificial,
4242 std::optional<unsigned> CoroSuspendIdx),
4243 (Scope, Name, File, Line, Column, IsArtificial,
4244 CoroSuspendIdx))
4245 DEFINE_MDNODE_GET(DILabel,
4247 unsigned Line, unsigned Column, bool IsArtificial,
4248 std::optional<unsigned> CoroSuspendIdx),
4249 (Scope, Name, File, Line, Column, IsArtificial,
4250 CoroSuspendIdx))
4251
4252 TempDILabel clone() const { return cloneImpl(); }
4253
4254 /// Get the local scope for this label.
4255 ///
4256 /// Labels must be defined in a local scope.
4260 unsigned getLine() const { return SubclassData32; }
4261 unsigned getColumn() const { return Column; }
4262 StringRef getName() const { return getStringOperand(1); }
4264 bool isArtificial() const { return IsArtificial; }
4265 std::optional<unsigned> getCoroSuspendIdx() const { return CoroSuspendIdx; }
4266
4267 Metadata *getRawScope() const { return getOperand(0); }
4269 Metadata *getRawFile() const { return getOperand(2); }
4270
4271 /// Check that a location is valid for this label.
4272 ///
4273 /// Check that \c DL exists, is in the same subprogram, and has the same
4274 /// inlined-at location as \c this. (Otherwise, it's not a valid attachment
4275 /// to a \a DbgInfoIntrinsic.)
4277 return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
4278 }
4279
4280 static bool classof(const Metadata *MD) {
4281 return MD->getMetadataID() == DILabelKind;
4282 }
4283};
4284
4285class DIObjCProperty : public DINode {
4286 friend class LLVMContextImpl;
4287 friend class MDNode;
4288
4289 unsigned Line;
4290 unsigned Attributes;
4291
4292 DIObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
4293 unsigned Attributes, ArrayRef<Metadata *> Ops);
4294 ~DIObjCProperty() = default;
4295
4296 static DIObjCProperty *
4297 getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
4298 StringRef GetterName, StringRef SetterName, unsigned Attributes,
4299 DIType *Type, StorageType Storage, bool ShouldCreate = true) {
4300 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
4302 getCanonicalMDString(Context, SetterName), Attributes, Type,
4303 Storage, ShouldCreate);
4304 }
4305 LLVM_ABI static DIObjCProperty *
4306 getImpl(LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
4307 MDString *GetterName, MDString *SetterName, unsigned Attributes,
4308 Metadata *Type, StorageType Storage, bool ShouldCreate = true);
4309
4310 TempDIObjCProperty cloneImpl() const {
4311 return getTemporary(getContext(), getName(), getFile(), getLine(),
4313 getType());
4314 }
4315
4316public:
4317 DEFINE_MDNODE_GET(DIObjCProperty,
4318 (StringRef Name, DIFile *File, unsigned Line,
4320 unsigned Attributes, DIType *Type),
4321 (Name, File, Line, GetterName, SetterName, Attributes,
4322 Type))
4323 DEFINE_MDNODE_GET(DIObjCProperty,
4324 (MDString * Name, Metadata *File, unsigned Line,
4326 unsigned Attributes, Metadata *Type),
4327 (Name, File, Line, GetterName, SetterName, Attributes,
4328 Type))
4329
4330 TempDIObjCProperty clone() const { return cloneImpl(); }
4331
4332 unsigned getLine() const { return Line; }
4333 unsigned getAttributes() const { return Attributes; }
4334 StringRef getName() const { return getStringOperand(0); }
4339
4341 if (auto *F = getFile())
4342 return F->getFilename();
4343 return "";
4344 }
4345
4347 if (auto *F = getFile())
4348 return F->getDirectory();
4349 return "";
4350 }
4351
4353 Metadata *getRawFile() const { return getOperand(1); }
4356 Metadata *getRawType() const { return getOperand(4); }
4357
4358 static bool classof(const Metadata *MD) {
4359 return MD->getMetadataID() == DIObjCPropertyKind;
4360 }
4361};
4362
4363/// An imported module (C++ using directive or similar).
4364///
4365/// Uses the SubclassData32 Metadata slot.
4366class DIImportedEntity : public DINode {
4367 friend class LLVMContextImpl;
4368 friend class MDNode;
4369
4370 DIImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
4371 unsigned Line, ArrayRef<Metadata *> Ops)
4372 : DINode(C, DIImportedEntityKind, Storage, Tag, Ops) {
4374 }
4375 ~DIImportedEntity() = default;
4376
4377 static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
4378 DIScope *Scope, DINode *Entity, DIFile *File,
4379 unsigned Line, StringRef Name,
4380 DINodeArray Elements, StorageType Storage,
4381 bool ShouldCreate = true) {
4382 return getImpl(Context, Tag, Scope, Entity, File, Line,
4383 getCanonicalMDString(Context, Name), Elements.get(), Storage,
4384 ShouldCreate);
4385 }
4386 LLVM_ABI static DIImportedEntity *
4387 getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, Metadata *Entity,
4388 Metadata *File, unsigned Line, MDString *Name, Metadata *Elements,
4389 StorageType Storage, bool ShouldCreate = true);
4390
4391 TempDIImportedEntity cloneImpl() const {
4392 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
4393 getFile(), getLine(), getName(), getElements());
4394 }
4395
4396public:
4397 DEFINE_MDNODE_GET(DIImportedEntity,
4398 (unsigned Tag, DIScope *Scope, DINode *Entity, DIFile *File,
4399 unsigned Line, StringRef Name = "",
4400 DINodeArray Elements = nullptr),
4401 (Tag, Scope, Entity, File, Line, Name, Elements))
4402 DEFINE_MDNODE_GET(DIImportedEntity,
4405 Metadata *Elements = nullptr),
4406 (Tag, Scope, Entity, File, Line, Name, Elements))
4407
4408 TempDIImportedEntity clone() const { return cloneImpl(); }
4409
4410 unsigned getLine() const { return SubclassData32; }
4411 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
4412 DINode *getEntity() const { return cast_or_null<DINode>(getRawEntity()); }
4413 StringRef getName() const { return getStringOperand(2); }
4414 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
4415 DINodeArray getElements() const {
4416 return cast_or_null<MDTuple>(getRawElements());
4417 }
4418
4419 Metadata *getRawScope() const { return getOperand(0); }
4420 Metadata *getRawEntity() const { return getOperand(1); }
4421 MDString *getRawName() const { return getOperandAs<MDString>(2); }
4422 Metadata *getRawFile() const { return getOperand(3); }
4423 Metadata *getRawElements() const { return getOperand(4); }
4424
4425 static bool classof(const Metadata *MD) {
4426 return MD->getMetadataID() == DIImportedEntityKind;
4427 }
4428};
4429
4430/// A pair of DIGlobalVariable and DIExpression.
4431class DIGlobalVariableExpression : public MDNode {
4432 friend class LLVMContextImpl;
4433 friend class MDNode;
4434
4435 DIGlobalVariableExpression(LLVMContext &C, StorageType Storage,
4437 : MDNode(C, DIGlobalVariableExpressionKind, Storage, Ops) {}
4438 ~DIGlobalVariableExpression() = default;
4439
4441 getImpl(LLVMContext &Context, Metadata *Variable, Metadata *Expression,
4442 StorageType Storage, bool ShouldCreate = true);
4443
4444 TempDIGlobalVariableExpression cloneImpl() const {
4446 }
4447
4448public:
4449 DEFINE_MDNODE_GET(DIGlobalVariableExpression,
4450 (Metadata * Variable, Metadata *Expression),
4451 (Variable, Expression))
4452
4453 TempDIGlobalVariableExpression clone() const { return cloneImpl(); }
4454
4455 Metadata *getRawVariable() const { return getOperand(0); }
4456
4460
4461 Metadata *getRawExpression() const { return getOperand(1); }
4462
4466
4467 static bool classof(const Metadata *MD) {
4468 return MD->getMetadataID() == DIGlobalVariableExpressionKind;
4469 }
4470};
4471
4472/// Macro Info DWARF-like metadata node.
4473///
4474/// A metadata node with a DWARF macro info (i.e., a constant named
4475/// \c DW_MACINFO_*, defined in llvm/BinaryFormat/Dwarf.h). Called \a
4476/// DIMacroNode
4477/// because it's potentially used for non-DWARF output.
4478///
4479/// Uses the SubclassData16 Metadata slot.
4480class DIMacroNode : public MDNode {
4481 friend class LLVMContextImpl;
4482 friend class MDNode;
4483
4484protected:
4485 DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType,
4487 : MDNode(C, ID, Storage, Ops1, Ops2) {
4488 assert(MIType < 1u << 16);
4489 SubclassData16 = MIType;
4490 }
4491 ~DIMacroNode() = default;
4492
4493 template <class Ty> Ty *getOperandAs(unsigned I) const {
4494 return cast_or_null<Ty>(getOperand(I));
4495 }
4496
4497 StringRef getStringOperand(unsigned I) const {
4498 if (auto *S = getOperandAs<MDString>(I))
4499 return S->getString();
4500 return StringRef();
4501 }
4502
4504 if (S.empty())
4505 return nullptr;
4506 return MDString::get(Context, S);
4507 }
4508
4509public:
4510 unsigned getMacinfoType() const { return SubclassData16; }
4511
4512 static bool classof(const Metadata *MD) {
4513 switch (MD->getMetadataID()) {
4514 default:
4515 return false;
4516 case DIMacroKind:
4517 case DIMacroFileKind:
4518 return true;
4519 }
4520 }
4521};
4522
4523/// Macro
4524///
4525/// Uses the SubclassData32 Metadata slot.
4526class DIMacro : public DIMacroNode {
4527 friend class LLVMContextImpl;
4528 friend class MDNode;
4529
4530 DIMacro(LLVMContext &C, StorageType Storage, unsigned MIType, unsigned Line,
4532 : DIMacroNode(C, DIMacroKind, Storage, MIType, Ops) {
4534 }
4535 ~DIMacro() = default;
4536
4537 static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
4539 bool ShouldCreate = true) {
4540 return getImpl(Context, MIType, Line, getCanonicalMDString(Context, Name),
4541 getCanonicalMDString(Context, Value), Storage, ShouldCreate);
4542 }
4543 LLVM_ABI static DIMacro *getImpl(LLVMContext &Context, unsigned MIType,
4544 unsigned Line, MDString *Name,
4545 MDString *Value, StorageType Storage,
4546 bool ShouldCreate = true);
4547
4548 TempDIMacro cloneImpl() const {
4550 getValue());
4551 }
4552
4553public:
4555 (unsigned MIType, unsigned Line, StringRef Name,
4556 StringRef Value = ""),
4557 (MIType, Line, Name, Value))
4558 DEFINE_MDNODE_GET(DIMacro,
4559 (unsigned MIType, unsigned Line, MDString *Name,
4562
4563 TempDIMacro clone() const { return cloneImpl(); }
4564
4565 unsigned getLine() const { return SubclassData32; }
4566
4567 StringRef getName() const { return getStringOperand(0); }
4568 StringRef getValue() const { return getStringOperand(1); }
4569
4572
4573 static bool classof(const Metadata *MD) {
4574 return MD->getMetadataID() == DIMacroKind;
4575 }
4576};
4577
4578/// Macro file
4579///
4580/// Uses the SubclassData32 Metadata slot.
4581class DIMacroFile : public DIMacroNode {
4582 friend class LLVMContextImpl;
4583 friend class MDNode;
4584
4585 DIMacroFile(LLVMContext &C, StorageType Storage, unsigned MIType,
4586 unsigned Line, ArrayRef<Metadata *> Ops)
4587 : DIMacroNode(C, DIMacroFileKind, Storage, MIType, Ops) {
4589 }
4590 ~DIMacroFile() = default;
4591
4592 static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
4593 unsigned Line, DIFile *File,
4594 DIMacroNodeArray Elements, StorageType Storage,
4595 bool ShouldCreate = true) {
4596 return getImpl(Context, MIType, Line, static_cast<Metadata *>(File),
4597 Elements.get(), Storage, ShouldCreate);
4598 }
4599
4600 LLVM_ABI static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
4601 unsigned Line, Metadata *File,
4603 bool ShouldCreate = true);
4604
4605 TempDIMacroFile cloneImpl() const {
4607 getElements());
4608 }
4609
4610public:
4612 (unsigned MIType, unsigned Line, DIFile *File,
4613 DIMacroNodeArray Elements),
4614 (MIType, Line, File, Elements))
4615 DEFINE_MDNODE_GET(DIMacroFile,
4616 (unsigned MIType, unsigned Line, Metadata *File,
4619
4620 TempDIMacroFile clone() const { return cloneImpl(); }
4621
4622 void replaceElements(DIMacroNodeArray Elements) {
4623#ifndef NDEBUG
4624 for (DIMacroNode *Op : getElements())
4625 assert(is_contained(Elements->operands(), Op) &&
4626 "Lost a macro node during macro node list replacement");
4627#endif
4628 replaceOperandWith(1, Elements.get());
4629 }
4630
4631 unsigned getLine() const { return SubclassData32; }
4633
4634 DIMacroNodeArray getElements() const {
4636 }
4637
4638 Metadata *getRawFile() const { return getOperand(0); }
4639 Metadata *getRawElements() const { return getOperand(1); }
4640
4641 static bool classof(const Metadata *MD) {
4642 return MD->getMetadataID() == DIMacroFileKind;
4643 }
4644};
4645
4646/// List of ValueAsMetadata, to be used as an argument to a dbg.value
4647/// intrinsic.
4648class DIArgList : public Metadata, ReplaceableMetadataImpl {
4650 friend class LLVMContextImpl;
4652
4654
4655 DIArgList(LLVMContext &Context, ArrayRef<ValueAsMetadata *> Args)
4656 : Metadata(DIArgListKind, Uniqued), ReplaceableMetadataImpl(Context),
4657 Args(Args) {
4658 track();
4659 }
4660 ~DIArgList() { untrack(); }
4661
4662 LLVM_ABI void track();
4663 LLVM_ABI void untrack();
4664 void dropAllReferences(bool Untrack);
4665
4666public:
4667 LLVM_ABI static DIArgList *get(LLVMContext &Context,
4669
4670 ArrayRef<ValueAsMetadata *> getArgs() const { return Args; }
4671
4672 iterator args_begin() { return Args.begin(); }
4673 iterator args_end() { return Args.end(); }
4674
4675 static bool classof(const Metadata *MD) {
4676 return MD->getMetadataID() == DIArgListKind;
4677 }
4678
4682
4683 LLVM_ABI void handleChangedOperand(void *Ref, Metadata *New);
4684};
4685
4686/// Identifies a unique instance of a variable.
4687///
4688/// Storage for identifying a potentially inlined instance of a variable,
4689/// or a fragment thereof. This guarantees that exactly one variable instance
4690/// may be identified by this class, even when that variable is a fragment of
4691/// an aggregate variable and/or there is another inlined instance of the same
4692/// source code variable nearby.
4693/// This class does not necessarily uniquely identify that variable: it is
4694/// possible that a DebugVariable with different parameters may point to the
4695/// same variable instance, but not that one DebugVariable points to multiple
4696/// variable instances.
4698 using FragmentInfo = DIExpression::FragmentInfo;
4699
4700 const DILocalVariable *Variable;
4701 std::optional<FragmentInfo> Fragment;
4702 const DILocation *InlinedAt;
4703
4704 /// Fragment that will overlap all other fragments. Used as default when
4705 /// caller demands a fragment.
4706 LLVM_ABI static const FragmentInfo DefaultFragment;
4707
4708public:
4710
4712 std::optional<FragmentInfo> FragmentInfo,
4713 const DILocation *InlinedAt)
4714 : Variable(Var), Fragment(FragmentInfo), InlinedAt(InlinedAt) {}
4715
4716 DebugVariable(const DILocalVariable *Var, const DIExpression *DIExpr,
4717 const DILocation *InlinedAt)
4718 : Variable(Var),
4719 Fragment(DIExpr ? DIExpr->getFragmentInfo() : std::nullopt),
4720 InlinedAt(InlinedAt) {}
4721
4722 const DILocalVariable *getVariable() const { return Variable; }
4723 std::optional<FragmentInfo> getFragment() const { return Fragment; }
4724 const DILocation *getInlinedAt() const { return InlinedAt; }
4725
4726 FragmentInfo getFragmentOrDefault() const {
4727 return Fragment.value_or(DefaultFragment);
4728 }
4729
4730 static bool isDefaultFragment(const FragmentInfo F) {
4731 return F == DefaultFragment;
4732 }
4733
4734 bool operator==(const DebugVariable &Other) const {
4735 return std::tie(Variable, Fragment, InlinedAt) ==
4736 std::tie(Other.Variable, Other.Fragment, Other.InlinedAt);
4737 }
4738
4739 bool operator<(const DebugVariable &Other) const {
4740 return std::tie(Variable, Fragment, InlinedAt) <
4741 std::tie(Other.Variable, Other.Fragment, Other.InlinedAt);
4742 }
4743};
4744
4745template <> struct DenseMapInfo<DebugVariable> {
4747
4748 /// Empty key: no key should be generated that has no DILocalVariable.
4749 static inline DebugVariable getEmptyKey() {
4750 return DebugVariable(nullptr, std::nullopt, nullptr);
4751 }
4752
4753 /// Difference in tombstone is that the Optional is meaningful.
4755 return DebugVariable(nullptr, {{0, 0}}, nullptr);
4756 }
4757
4758 static unsigned getHashValue(const DebugVariable &D) {
4759 unsigned HV = 0;
4760 const std::optional<FragmentInfo> Fragment = D.getFragment();
4761 if (Fragment)
4763
4764 return hash_combine(D.getVariable(), HV, D.getInlinedAt());
4765 }
4766
4767 static bool isEqual(const DebugVariable &A, const DebugVariable &B) {
4768 return A == B;
4769 }
4770};
4771
4772/// Identifies a unique instance of a whole variable (discards/ignores fragment
4773/// information).
4780
4781template <>
4783 : public DenseMapInfo<DebugVariable> {};
4784} // end namespace llvm
4785
4786#undef DEFINE_MDNODE_GET_UNPACK_IMPL
4787#undef DEFINE_MDNODE_GET_UNPACK
4788#undef DEFINE_MDNODE_GET
4789
4790#endif // LLVM_IR_DEBUGINFOMETADATA_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static std::string getLinkageName(GlobalValue::LinkageTypes LT)
BitTracker BT
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
This file contains the declarations for the subclasses of Constant, which represent the different fla...
dxil translate DXIL Translate Metadata
#define DEFINE_MDNODE_GET(CLASS, FORMAL, ARGS)
#define DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
static unsigned getNextComponentInDiscriminator(unsigned D)
Returns the next component stored in discriminator.
static unsigned getUnsignedFromPrefixEncoding(unsigned U)
Reverse transformation as getPrefixEncodingFromUnsigned.
static const DILocalScope * getRetainedNodeScope(const MDNode *N)
static SmallString< 128 > getFilename(const DIScope *SP, vfs::FileSystem &VFS)
Extract a filename for a DIScope.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
This file contains the declarations for metadata subclasses.
#define T
This file defines the PointerUnion class, which is a discriminated union of pointer types.
static StringRef getName(Value *V)
static void r2(uint32_t &A, uint32_t &B, uint32_t &C, uint32_t &D, uint32_t &E, int I, uint32_t *Buf)
Definition SHA1.cpp:51
static void r1(uint32_t &A, uint32_t &B, uint32_t &C, uint32_t &D, uint32_t &E, int I, uint32_t *Buf)
Definition SHA1.cpp:45
This file contains some templates that are useful if you are working with the STL at all.
static enum BaseType getBaseType(const Value *Val)
Return the baseType for Val which states whether Val is exclusively derived from constant/null,...
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
This file defines the SmallVector class.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
static uint32_t getFlags(const Symbol *Sym)
Definition TapiFile.cpp:26
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
Class for arbitrary precision integers.
Definition APInt.h:78
Annotations lets you mark points and ranges inside source code, for tests:
Definition Annotations.h:53
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator end() const
Definition ArrayRef.h:131
const_pointer iterator
Definition ArrayRef.h:47
iterator begin() const
Definition ArrayRef.h:130
static ConstantAsMetadata * get(Constant *C)
Definition Metadata.h:536
This is the shared class of boolean and integer constants.
Definition Constants.h:87
This is an important base class in LLVM.
Definition Constant.h:43
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
ArrayRef< ValueAsMetadata * > getArgs() const
LLVM_ABI void handleChangedOperand(void *Ref, Metadata *New)
static bool classof(const Metadata *MD)
static LLVM_ABI DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
friend class ReplaceableMetadataImpl
friend class LLVMContextImpl
SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
static bool classof(const Metadata *MD)
SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
static TempDIAssignID getTemporary(LLVMContext &Context)
static DIAssignID * getDistinct(LLVMContext &Context)
friend class LLVMContextImpl
void replaceOperandWith(unsigned I, Metadata *New)=delete
Basic type, like 'int' or 'float'.
static DIBasicType * getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, StorageType Storage, bool ShouldCreate=true)
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned Encoding
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags
TempDIBasicType cloneImpl() const
DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, ArrayRef< Metadata * > Ops)
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags unsigned StringRef uint64_t uint32_t unsigned uint32_t DIFlags Flags unsigned MDString uint64_t uint32_t unsigned uint32_t uint32_t DataSizeInBits
~DIBasicType()=default
static bool classof(const Metadata *MD)
DEFINE_MDNODE_GET(DIBasicType,(unsigned Tag, StringRef Name),(Tag, Name, 0, 0, 0, 0, 0, FlagZero)) DEFINE_MDNODE_GET(DIBasicType
static DIBasicType * getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, StorageType Storage, bool ShouldCreate=true)
uint32_t getDataSizeInBits() const
unsigned StringRef uint64_t SizeInBits
friend class LLVMContextImpl
LLVM_ABI std::optional< Signedness > getSignedness() const
Return the signedness of this type, or std::nullopt if this type is neither signed nor unsigned.
unsigned getEncoding() const
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags unsigned StringRef uint64_t uint32_t unsigned uint32_t NumExtraInhabitants
DIBasicType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, ArrayRef< Metadata * > Ops)
unsigned StringRef Name
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t AlignInBits
Debug common block.
Metadata * getRawScope() const
Metadata Metadata MDString Metadata unsigned LineNo TempDICommonBlock clone() const
Metadata * getRawDecl() const
Metadata Metadata * Decl
Metadata * getRawFile() const
Metadata Metadata MDString Metadata unsigned LineNo
Metadata Metadata MDString * Name
MDString * getRawName() const
DIFile * getFile() const
static bool classof(const Metadata *MD)
unsigned getLineNo() const
Metadata Metadata MDString Metadata * File
StringRef getName() const
DIScope * getScope() const
DEFINE_MDNODE_GET(DICommonBlock,(DIScope *Scope, DIGlobalVariable *Decl, StringRef Name, DIFile *File, unsigned LineNo),(Scope, Decl, Name, File, LineNo)) DEFINE_MDNODE_GET(DICommonBlock
DIGlobalVariable * getDecl() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned NameTableKind
MDString * getRawSplitDebugFilename() const
bool getDebugInfoForProfiling() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool DebugInfoForProfiling
Metadata * getRawRetainedTypes() const
static LLVM_ABI const char * nameTableKindString(DebugNameTableKind PK)
static LLVM_ABI const char * emissionKindString(DebugEmissionKind EK)
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool MDString * SysRoot
DISourceLanguageName Metadata MDString bool MDString * Flags
void setSplitDebugInlining(bool SplitDebugInlining)
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool MDString MDString * SDK
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata * GlobalVariables
DICompositeTypeArray getEnumTypes() const
DebugEmissionKind getEmissionKind() const
bool isDebugDirectivesOnly() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t DWOId
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata * EnumTypes
StringRef getFlags() const
MDString * getRawProducer() const
DISourceLanguageName Metadata MDString * Producer
void replaceEnumTypes(DICompositeTypeArray N)
Replace arrays.
MDString * getRawSysRoot() const
DISourceLanguageName Metadata MDString bool MDString unsigned RuntimeVersion
StringRef getSDK() const
static void getIfExists()=delete
bool getRangesBaseAddress() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata * RetainedTypes
DIMacroNodeArray getMacros() const
unsigned getRuntimeVersion() const
Metadata * getRawMacros() const
void replaceRetainedTypes(DITypeArray N)
static bool classof(const Metadata *MD)
DISourceLanguageName Metadata MDString bool MDString unsigned MDString * SplitDebugFilename
void replaceGlobalVariables(DIGlobalVariableExpressionArray N)
void replaceMacros(DIMacroNodeArray N)
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool MDString MDString SDK TempDICompileUnit clone() const
bool getSplitDebugInlining() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata * ImportedEntities
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata * Macros
StringRef getSysRoot() const
DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(DICompileUnit,(DISourceLanguageName SourceLanguage, DIFile *File, StringRef Producer, bool IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling, DebugNameTableKind NameTableKind, bool RangesBaseAddress, StringRef SysRoot, StringRef SDK),(SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling,(unsigned) NameTableKind, RangesBaseAddress, SysRoot, SDK)) DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(DICompileUnit
DebugNameTableKind getNameTableKind() const
MDString * getRawSDK() const
DISourceLanguageName Metadata MDString bool IsOptimized
DISourceLanguageName Metadata * File
MDString * getRawFlags() const
DIImportedEntityArray getImportedEntities() const
Metadata * getRawEnumTypes() const
StringRef getProducer() const
void setDWOId(uint64_t DwoId)
DIScopeArray getRetainedTypes() const
void replaceImportedEntities(DIImportedEntityArray N)
Metadata * getRawGlobalVariables() const
DIGlobalVariableExpressionArray getGlobalVariables() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool SplitDebugInlining
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned EmissionKind
DISourceLanguageName getSourceLanguage() const
Metadata * getRawImportedEntities() const
DISourceLanguageName Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool RangesBaseAddress
uint64_t getDWOId() const
StringRef getSplitDebugFilename() const
static void get()=delete
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t AlignInBits
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > EnumKind
Metadata * getRawVTableHolder() const
DIExpression * getRankExp() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata * DataLocation
static LLVM_ABI DICompositeType * buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, Metadata *SizeInBits, uint32_t AlignInBits, Metadata *OffsetInBits, Metadata *Specification, uint32_t NumExtraInhabitants, DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, std::optional< uint32_t > EnumKind, Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator, Metadata *DataLocation, Metadata *Associated, Metadata *Allocated, Metadata *Rank, Metadata *Annotations, Metadata *BitStride)
Build a DICompositeType with the given ODR identifier.
unsigned MDString Metadata unsigned Line
Metadata * getRawRank() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata * Elements
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned RuntimeLang
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata * Annotations
Metadata * getRawSpecification() const
DIExpression * getAssociatedExp() const
DIVariable * getAllocated() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString * Identifier
DIExpression * getDataLocationExp() const
Metadata * getRawDiscriminator() const
static LLVM_ABI DICompositeType * getODRTypeIfExists(LLVMContext &Context, MDString &Identifier)
DIVariable * getAssociated() const
DIDerivedType * getDiscriminator() const
DIVariable * getDataLocation() const
unsigned getRuntimeLang() const
DIType * getSpecification() const
Metadata * getRawElements() const
unsigned MDString * Name
void replaceVTableHolder(DIType *VTableHolder)
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata * Discriminator
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata * TemplateParams
StringRef getIdentifier() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t OffsetInBits
unsigned MDString Metadata unsigned Metadata * Scope
unsigned MDString Metadata * File
Metadata * getRawDataLocation() const
Metadata * getRawTemplateParams() const
unsigned MDString Metadata unsigned Metadata Metadata * BaseType
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Flags
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata * Allocated
DINodeArray getElements() const
DITemplateParameterArray getTemplateParams() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata * Specification
Metadata * getRawAnnotations() const
Metadata * getRawAllocated() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata * VTableHolder
DIExpression * getAllocatedExp() const
void replaceElements(DINodeArray Elements)
Replace operands.
ConstantInt * getBitStrideConst() const
std::optional< uint32_t > getEnumKind() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t SizeInBits
DIType * getVTableHolder() const
DINodeArray getAnnotations() const
Metadata * getRawAssociated() const
ConstantInt * getRankConst() const
void replaceTemplateParams(DITemplateParameterArray TemplateParams)
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata * Associated
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata uint32_t NumExtraInhabitants
Metadata * getRawBitStride() const
Metadata * getRawBaseType() const
DEFINE_MDNODE_GET(DICompositeType,(unsigned Tag, StringRef Name, DIFile *File, unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags, DINodeArray Elements, unsigned RuntimeLang, std::optional< uint32_t > EnumKind, DIType *VTableHolder, DITemplateParameterArray TemplateParams=nullptr, StringRef Identifier="", DIDerivedType *Discriminator=nullptr, Metadata *DataLocation=nullptr, Metadata *Associated=nullptr, Metadata *Allocated=nullptr, Metadata *Rank=nullptr, DINodeArray Annotations=nullptr, DIType *Specification=nullptr, uint32_t NumExtraInhabitants=0, Metadata *BitStride=nullptr),(Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Specification, NumExtraInhabitants, Flags, Elements, RuntimeLang, EnumKind, VTableHolder, TemplateParams, Identifier, Discriminator, DataLocation, Associated, Allocated, Rank, Annotations, BitStride)) DEFINE_MDNODE_GET(DICompositeType
MDString * getRawIdentifier() const
static bool classof(const Metadata *MD)
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata * Rank
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned std::optional< uint32_t > Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata uint32_t Metadata * BitStride
DIType * getBaseType() const
Metadata * getRawExtraData() const
unsigned StringRef DIFile unsigned DIScope DIType * BaseType
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata * OffsetInBits
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata std::optional< unsigned > std::optional< PtrAuthData > DIFlags Flags
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t AlignInBits
DINodeArray getAnnotations() const
Get annotations associated with this derived type.
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata std::optional< unsigned > std::optional< PtrAuthData > PtrAuthData
DEFINE_MDNODE_GET(DIDerivedType,(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, Metadata *SizeInBits, uint32_t AlignInBits, Metadata *OffsetInBits, std::optional< unsigned > DWARFAddressSpace, std::optional< PtrAuthData > PtrAuthData, DIFlags Flags, Metadata *ExtraData=nullptr, Metadata *Annotations=nullptr),(Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData, Flags, ExtraData, Annotations)) DEFINE_MDNODE_GET(DIDerivedType
Metadata * getExtraData() const
Get extra data associated with this derived type.
DITemplateParameterArray getTemplateParams() const
Get the template parameters from a template alias.
unsigned StringRef DIFile * File
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata std::optional< unsigned > std::optional< PtrAuthData > DIFlags Metadata DINodeArray Annotations
DIObjCProperty * getObjCProperty() const
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata std::optional< unsigned > DWARFAddressSpace
unsigned StringRef DIFile unsigned DIScope * Scope
Metadata * getRawAnnotations() const
LLVM_ABI DIType * getClassType() const
Get casted version of extra data.
static bool classof(const Metadata *MD)
LLVM_ABI Constant * getConstant() const
unsigned StringRef DIFile unsigned DIScope DIType Metadata * SizeInBits
LLVM_ABI Constant * getStorageOffsetInBits() const
LLVM_ABI Constant * getDiscriminantValue() const
unsigned StringRef Name
LLVM_ABI uint32_t getVBPtrOffset() const
unsigned StringRef DIFile unsigned DIScope DIType Metadata uint32_t Metadata std::optional< unsigned > std::optional< PtrAuthData > DIFlags Metadata * ExtraData
unsigned StringRef DIFile unsigned Line
Enumeration value.
int64_t bool MDString APInt(64, Value, !IsUnsigned)
const APInt & getValue() const
int64_t bool MDString Name APInt bool MDString Name TempDIEnumerator clone() const
MDString * getRawName() const
StringRef getName() const
friend class LLVMContextImpl
DEFINE_MDNODE_GET(DIEnumerator,(int64_t Value, bool IsUnsigned, StringRef Name),(APInt(64, Value, !IsUnsigned), IsUnsigned, Name)) DEFINE_MDNODE_GET(DIEnumerator
static bool classof(const Metadata *MD)
int64_t bool MDString * Name
std::optional< DIExpression::ExprOperand > peekNext() const
Return the next operation.
std::optional< DIExpression::FragmentInfo > getFragmentInfo() const
Retrieve the fragment information, if any.
DIExpressionCursor(const DIExpressionCursor &)=default
DIExpressionCursor(const DIExpression *Expr)
DIExpression::expr_op_iterator end() const
std::optional< DIExpression::ExprOperand > peekNextN(unsigned N) const
std::optional< DIExpression::ExprOperand > peek() const
Return the current operation.
void consume(unsigned N)
Consume N operations.
std::optional< DIExpression::ExprOperand > take()
Consume one operation.
DIExpressionCursor(ArrayRef< uint64_t > Expr)
DIExpression::expr_op_iterator begin() const
void assignNewExpr(ArrayRef< uint64_t > Expr)
A lightweight wrapper around an expression operand.
LLVM_ABI unsigned getSize() const
Return the size of the operand.
uint64_t getArg(unsigned I) const
Get an argument to the operand.
uint64_t getOp() const
Get the operand code.
void appendToVector(SmallVectorImpl< uint64_t > &V) const
Append the elements of this operand to V.
An iterator for expression operands.
bool operator==(const expr_op_iterator &X) const
const ExprOperand * operator->() const
bool operator!=(const expr_op_iterator &X) const
const ExprOperand & operator*() const
expr_op_iterator getNext() const
Get the next iterator.
DWARF expression.
element_iterator elements_end() const
LLVM_ABI bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
iterator_range< expr_op_iterator > expr_ops() const
bool isFragment() const
Return whether this is a piece of an aggregate variable.
static LLVM_ABI DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
std::array< uint64_t, 6 > ExtOps
unsigned getNumElements() const
ArrayRef< uint64_t >::iterator element_iterator
static LLVM_ABI ExtOps getExtOps(unsigned FromSize, unsigned ToSize, bool Signed)
Returns the ops for a zero- or sign-extension in a DIExpression.
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
LLVM_ABI bool extractIfOffset(int64_t &Offset) const
If this is a constant offset, extract it.
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
DbgVariableFragmentInfo FragmentInfo
int fragmentCmp(const DIExpression *Other) const
Determine the relative position of the fragments described by this DIExpression and Other.
LLVM_ABI bool startsWithDeref() const
Return whether the first element a DW_OP_deref.
static LLVM_ABI bool isEqualExpression(const DIExpression *FirstExpr, bool FirstIndirect, const DIExpression *SecondExpr, bool SecondIndirect)
Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpres...
expr_op_iterator expr_op_end() const
LLVM_ABI bool isImplicit() const
Return whether this is an implicit location description.
DEFINE_MDNODE_GET(DIExpression,(ArrayRef< uint64_t > Elements),(Elements)) TempDIExpression clone() const
static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B)
Check if fragments overlap between a pair of FragmentInfos.
static LLVM_ABI bool calculateFragmentIntersect(const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits, int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag, std::optional< DIExpression::FragmentInfo > &Result, int64_t &OffsetFromLocationInBits)
Computes a fragment, bit-extract operation if needed, and new constant offset to describe a part of a...
element_iterator elements_begin() const
LLVM_ABI bool hasAllLocationOps(unsigned N) const
Returns true iff this DIExpression contains at least one instance of DW_OP_LLVM_arg,...
std::optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
static LLVM_ABI DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
PrependOps
Used for DIExpression::prepend.
static int fragmentCmp(const FragmentInfo &A, const FragmentInfo &B)
Determine the relative position of the fragments passed in.
LLVM_ABI bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
bool fragmentsOverlap(const DIExpression *Other) const
Check if fragments overlap between this DIExpression and Other.
LLVM_ABI DIExpression * foldConstantMath()
Try to shorten an expression with constant math operations that can be evaluated at compile time.
static LLVM_ABI std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
LLVM_ABI std::pair< DIExpression *, const ConstantInt * > constantFold(const ConstantInt *CI)
Try to shorten an expression with an initial constant operand.
LLVM_ABI bool isDeref() const
Return whether there is exactly one operator and it is a DW_OP_deref;.
static LLVM_ABI const DIExpression * convertToVariadicExpression(const DIExpression *Expr)
If Expr is a non-variadic expression (i.e.
LLVM_ABI uint64_t getNumLocationOperands() const
Return the number of unique location operands referred to (via DW_OP_LLVM_arg) in this expression; th...
ArrayRef< uint64_t > getElements() const
static LLVM_ABI DIExpression * replaceArg(const DIExpression *Expr, uint64_t OldArg, uint64_t NewArg)
Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg,...
static bool classof(const Metadata *MD)
LLVM_ABI std::optional< uint64_t > getActiveBits(DIVariable *Var)
Return the number of bits that have an active value, i.e.
static LLVM_ABI void canonicalizeExpressionOps(SmallVectorImpl< uint64_t > &Ops, const DIExpression *Expr, bool IsIndirect)
Inserts the elements of Expr into Ops modified to a canonical form, which uses DW_OP_LLVM_arg (i....
uint64_t getElement(unsigned I) const
static LLVM_ABI std::optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
static LLVM_ABI const DIExpression * convertToUndefExpression(const DIExpression *Expr)
Removes all elements from Expr that do not apply to an undef debug value, which includes every operat...
static LLVM_ABI DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
static LLVM_ABI DIExpression * appendToStack(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Convert DIExpr into a stack value if it isn't one already by appending DW_OP_deref if needed,...
static LLVM_ABI DIExpression * appendExt(const DIExpression *Expr, unsigned FromSize, unsigned ToSize, bool Signed)
Append a zero- or sign-extension to Expr.
LLVM_ABI std::optional< ArrayRef< uint64_t > > getSingleLocationExpressionElements() const
Returns a reference to the elements contained in this expression, skipping past the leading DW_OP_LLV...
LLVM_ABI bool isSingleLocationExpression() const
Return whether the evaluated expression makes use of a single location at the start of the expression...
LLVM_ABI bool extractLeadingOffset(int64_t &OffsetInBytes, SmallVectorImpl< uint64_t > &RemainingOps) const
Assuming that the expression operates on an address, extract a constant offset and the successive ops...
LLVM_ABI std::optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
LLVM_ABI bool isValid() const
static LLVM_ABI const DIExpression * extractAddressClass(const DIExpression *Expr, unsigned &AddrClass)
Checks if the last 4 elements of the expression are DW_OP_constu <DWARFAddress Space> DW_OP_swap DW_O...
static LLVM_ABI DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
static bool classof(const Metadata *MD)
MDString MDString * Directory
MDString MDString std::optional< ChecksumInfo< MDString * > > MDString * Source
DEFINE_MDNODE_GET(DIFile,(StringRef Filename, StringRef Directory, std::optional< ChecksumInfo< StringRef > > CS=std::nullopt, std::optional< StringRef > Source=std::nullopt),(Filename, Directory, CS, Source)) DEFINE_MDNODE_GET(DIFile
MDString * Filename
static LLVM_ABI std::optional< ChecksumKind > getChecksumKind(StringRef CSKindStr)
ChecksumKind
Which algorithm (e.g.
friend class LLVMContextImpl
friend class MDNode
MDString MDString std::optional< ChecksumInfo< MDString * > > CS
unsigned StringRef uint64_t uint32_t unsigned DIFlags unsigned int Factor
static LLVM_ABI std::optional< FixedPointKind > getFixedPointKind(StringRef Str)
static LLVM_ABI const char * fixedPointKindString(FixedPointKind)
const APInt & getNumeratorRaw() const
unsigned StringRef uint64_t uint32_t unsigned Encoding
static bool classof(const Metadata *MD)
const APInt & getDenominator() const
unsigned StringRef uint64_t uint32_t AlignInBits
LLVM_ABI bool isSigned() const
@ FixedPointBinary
Scale factor 2^Factor.
@ FixedPointDecimal
Scale factor 10^Factor.
@ FixedPointRational
Arbitrary rational scale factor.
FixedPointKind getKind() const
const APInt & getNumerator() const
DEFINE_MDNODE_GET(DIFixedPointType,(unsigned Tag, MDString *Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, DIFlags Flags, unsigned Kind, int Factor, APInt Numerator, APInt Denominator),(Tag, Name, SizeInBits, AlignInBits, Encoding, Flags, Kind, Factor, Numerator, Denominator)) DEFINE_MDNODE_GET(DIFixedPointType
unsigned StringRef uint64_t uint32_t unsigned DIFlags unsigned int APInt Numerator
unsigned StringRef uint64_t uint32_t unsigned DIFlags unsigned int APInt APInt Denominator
unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags
unsigned StringRef uint64_t SizeInBits
const APInt & getDenominatorRaw() const
Metadata * getRawLowerBound() const
Metadata * getRawCountNode() const
Metadata * getRawStride() const
LLVM_ABI BoundType getLowerBound() const
DEFINE_MDNODE_GET(DIGenericSubrange,(Metadata *CountNode, Metadata *LowerBound, Metadata *UpperBound, Metadata *Stride),(CountNode, LowerBound, UpperBound, Stride)) TempDIGenericSubrange clone() const
Metadata * getRawUpperBound() const
static bool classof(const Metadata *MD)
LLVM_ABI BoundType getCount() const
LLVM_ABI BoundType getUpperBound() const
PointerUnion< DIVariable *, DIExpression * > BoundType
LLVM_ABI BoundType getStride() const
A pair of DIGlobalVariable and DIExpression.
DEFINE_MDNODE_GET(DIGlobalVariableExpression,(Metadata *Variable, Metadata *Expression),(Variable, Expression)) TempDIGlobalVariableExpression clone() const
DIGlobalVariable * getVariable() const
static bool classof(const Metadata *MD)
Metadata * getRawAnnotations() const
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata * TemplateParams
Metadata MDString MDString Metadata unsigned Metadata bool bool IsDefinition
Metadata MDString MDString Metadata unsigned Line
Metadata MDString MDString Metadata unsigned Metadata * Type
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata uint32_t Metadata * Annotations
DIDerivedType * getStaticDataMemberDeclaration() const
DEFINE_MDNODE_GET(DIGlobalVariable,(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition, DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams, uint32_t AlignInBits, DINodeArray Annotations),(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations)) DEFINE_MDNODE_GET(DIGlobalVariable
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata uint32_t Metadata Annotations TempDIGlobalVariable clone() const
Metadata MDString * Name
MDTuple * getTemplateParams() const
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata * StaticDataMemberDeclaration
Metadata * getRawStaticDataMemberDeclaration() const
Metadata MDString MDString * LinkageName
MDString * getRawLinkageName() const
StringRef getLinkageName() const
static bool classof(const Metadata *MD)
StringRef getDisplayName() const
Metadata MDString MDString Metadata * File
DINodeArray getAnnotations() const
Metadata MDString MDString Metadata unsigned Metadata bool IsLocalToUnit
Metadata * getRawTemplateParams() const
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata uint32_t AlignInBits
An imported module (C++ using directive or similar).
unsigned Metadata Metadata * Entity
DEFINE_MDNODE_GET(DIImportedEntity,(unsigned Tag, DIScope *Scope, DINode *Entity, DIFile *File, unsigned Line, StringRef Name="", DINodeArray Elements=nullptr),(Tag, Scope, Entity, File, Line, Name, Elements)) DEFINE_MDNODE_GET(DIImportedEntity
unsigned Metadata Metadata Metadata unsigned Line
unsigned Metadata Metadata Metadata unsigned MDString * Name
unsigned Metadata Metadata Metadata * File
unsigned Metadata * Scope
Metadata MDString Metadata unsigned unsigned bool std::optional< unsigned > CoroSuspendIdx
DIFile * getFile() const
Metadata MDString Metadata unsigned unsigned bool std::optional< unsigned > CoroSuspendIdx TempDILabel clone() const
StringRef getName() const
static bool classof(const Metadata *MD)
Metadata MDString Metadata unsigned unsigned Column
unsigned getLine() const
bool isArtificial() const
Metadata MDString Metadata unsigned unsigned bool IsArtificial
Metadata * getRawFile() const
unsigned getColumn() const
DILocalScope * getScope() const
Get the local scope for this label.
MDString * getRawName() const
std::optional< unsigned > getCoroSuspendIdx() const
Metadata MDString Metadata unsigned Line
Metadata MDString * Name
DEFINE_MDNODE_GET(DILabel,(DILocalScope *Scope, StringRef Name, DIFile *File, unsigned Line, unsigned Column, bool IsArtificial, std::optional< unsigned > CoroSuspendIdx),(Scope, Name, File, Line, Column, IsArtificial, CoroSuspendIdx)) DEFINE_MDNODE_GET(DILabel
friend class LLVMContextImpl
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this label.
Metadata * getRawScope() const
friend class MDNode
Metadata MDString Metadata * File
static bool classof(const Metadata *MD)
void replaceScope(DIScope *Scope)
Metadata * getRawScope() const
LLVM_ABI DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops)
DILocalScope * getScope() const
Metadata Metadata unsigned Discriminator
static bool classof(const Metadata *MD)
unsigned getDiscriminator() const
Metadata Metadata unsigned Discriminator TempDILexicalBlockFile clone() const
DEFINE_MDNODE_GET(DILexicalBlockFile,(DILocalScope *Scope, DIFile *File, unsigned Discriminator),(Scope, File, Discriminator)) DEFINE_MDNODE_GET(DILexicalBlockFile
Debug lexical block.
Metadata Metadata unsigned unsigned Column
Metadata Metadata unsigned Line
DEFINE_MDNODE_GET(DILexicalBlock,(DILocalScope *Scope, DIFile *File, unsigned Line, unsigned Column),(Scope, File, Line, Column)) DEFINE_MDNODE_GET(DILexicalBlock
static bool classof(const Metadata *MD)
Metadata Metadata * File
unsigned getColumn() const
Metadata Metadata unsigned unsigned Column TempDILexicalBlock clone() const
A scope for locals.
LLVM_ABI DISubprogram * getSubprogram() const
Get the subprogram for this scope.
LLVM_ABI DILocalScope * getNonLexicalBlockFileScope() const
Get the first non DILexicalBlockFile scope of this scope.
~DILocalScope()=default
DILocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, ArrayRef< Metadata * > Ops)
static bool classof(const Metadata *MD)
static LLVM_ABI DILocalScope * cloneScopeForSubprogram(DILocalScope &RootScope, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Traverses the scope chain rooted at RootScope until it hits a Subprogram, recreating the chain with "...
Metadata MDString Metadata unsigned Metadata * Type
Metadata MDString Metadata * File
static bool classof(const Metadata *MD)
Metadata MDString Metadata unsigned Metadata unsigned DIFlags uint32_t Metadata Annotations TempDILocalVariable clone() const
DILocalScope * getScope() const
Get the local scope for this variable.
Metadata MDString * Name
Metadata MDString Metadata unsigned Metadata unsigned Arg
DINodeArray getAnnotations() const
DEFINE_MDNODE_GET(DILocalVariable,(DILocalScope *Scope, StringRef Name, DIFile *File, unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations),(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits, Annotations)) DEFINE_MDNODE_GET(DILocalVariable
Metadata MDString Metadata unsigned Line
Metadata MDString Metadata unsigned Metadata unsigned DIFlags uint32_t Metadata * Annotations
Metadata MDString Metadata unsigned Metadata unsigned DIFlags uint32_t AlignInBits
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
Metadata * getRawAnnotations() const
unsigned unsigned DILocalScope * Scope
const DILocation * getWithoutAtom() const
static unsigned getDuplicationFactorFromDiscriminator(unsigned D)
Returns the duplication factor for a given encoded discriminator D, or 1 if no value or 0 is encoded.
static bool isPseudoProbeDiscriminator(unsigned Discriminator)
unsigned unsigned DILocalScope DILocation bool uint64_t AtomGroup
unsigned getDuplicationFactor() const
Returns the duplication factor stored in the discriminator, or 1 if no duplication factor (or 0) is e...
uint64_t getAtomGroup() const
static LLVM_ABI DILocation * getMergedLocations(ArrayRef< DILocation * > Locs)
Try to combine the vector of locations passed as input in a single one.
static unsigned getBaseDiscriminatorBits()
Return the bits used for base discriminators.
static LLVM_ABI std::optional< unsigned > encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI)
Raw encoding of the discriminator.
unsigned unsigned DILocalScope DILocation bool ImplicitCode
Metadata * getRawScope() const
static LLVM_ABI void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, unsigned &CI)
Raw decoder for values in an encoded discriminator D.
static LLVM_ABI DILocation * getMergedLocation(DILocation *LocA, DILocation *LocB)
Attempts to merge LocA and LocB into a single location; see DebugLoc::getMergedLocation for more deta...
std::optional< const DILocation * > cloneWithBaseDiscriminator(unsigned BD) const
Returns a new DILocation with updated base discriminator BD.
unsigned getBaseDiscriminator() const
Returns the base discriminator stored in the discriminator.
static unsigned getBaseDiscriminatorFromDiscriminator(unsigned D, bool IsFSDiscriminator=false)
Returns the base discriminator for a given encoded discriminator D.
unsigned unsigned Column
Metadata * getRawInlinedAt() const
unsigned unsigned DILocalScope DILocation * InlinedAt
friend class LLVMContextImpl
static unsigned getMaskedDiscriminator(unsigned D, unsigned B)
Return the masked discriminator value for an input discrimnator value D (i.e.
const DILocation * cloneWithDiscriminator(unsigned Discriminator) const
Returns a new DILocation with updated Discriminator.
static unsigned getCopyIdentifierFromDiscriminator(unsigned D)
Returns the copy identifier for a given encoded discriminator D.
uint8_t getAtomRank() const
DEFINE_MDNODE_GET(DILocation,(unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt=nullptr, bool ImplicitCode=false, uint64_t AtomGroup=0, uint8_t AtomRank=0),(Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup, AtomRank)) DEFINE_MDNODE_GET(DILocation
void replaceOperandWith(unsigned I, Metadata *New)=delete
std::optional< const DILocation * > cloneByMultiplyingDuplicationFactor(unsigned DF) const
Returns a new DILocation with duplication factor DF * current duplication factor encoded in the discr...
static bool classof(const Metadata *MD)
unsigned getCopyIdentifier() const
Returns the copy identifier stored in the discriminator.
unsigned unsigned DILocalScope DILocation bool uint64_t uint8_t AtomRank
unsigned unsigned Metadata * File
Metadata * getRawElements() const
DEFINE_MDNODE_GET(DIMacroFile,(unsigned MIType, unsigned Line, DIFile *File, DIMacroNodeArray Elements),(MIType, Line, File, Elements)) DEFINE_MDNODE_GET(DIMacroFile
unsigned unsigned Line
DIFile * getFile() const
unsigned getLine() const
unsigned unsigned Metadata Metadata * Elements
Metadata * getRawFile() const
static bool classof(const Metadata *MD)
friend class LLVMContextImpl
void replaceElements(DIMacroNodeArray Elements)
unsigned unsigned Metadata Metadata Elements TempDIMacroFile clone() const
DIMacroNodeArray getElements() const
DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
unsigned getMacinfoType() const
StringRef getStringOperand(unsigned I) const
static bool classof(const Metadata *MD)
static MDString * getCanonicalMDString(LLVMContext &Context, StringRef S)
friend class LLVMContextImpl
Ty * getOperandAs(unsigned I) const
~DIMacroNode()=default
unsigned getLine() const
MDString * getRawName() const
unsigned unsigned MDString MDString Value TempDIMacro clone() const
unsigned unsigned MDString MDString * Value
unsigned unsigned MDString * Name
StringRef getName() const
MDString * getRawValue() const
unsigned unsigned Line
friend class LLVMContextImpl
DEFINE_MDNODE_GET(DIMacro,(unsigned MIType, unsigned Line, StringRef Name, StringRef Value=""),(MIType, Line, Name, Value)) DEFINE_MDNODE_GET(DIMacro
friend class MDNode
StringRef getValue() const
static bool classof(const Metadata *MD)
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Metadata Metadata * Scope
Metadata Metadata MDString * Name
Metadata Metadata MDString MDString MDString MDString * APINotesFile
Metadata Metadata MDString MDString MDString * IncludePath
Metadata Metadata MDString MDString * ConfigurationMacros
friend class LLVMContextImpl
DEFINE_MDNODE_GET(DIModule,(DIFile *File, DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef APINotesFile, unsigned LineNo, bool IsDecl=false),(File, Scope, Name, ConfigurationMacros, IncludePath, APINotesFile, LineNo, IsDecl)) DEFINE_MDNODE_GET(DIModule
Metadata Metadata MDString MDString MDString MDString unsigned LineNo
Debug lexical block.
Metadata MDString bool ExportSymbols TempDINamespace clone() const
static bool classof(const Metadata *MD)
DEFINE_MDNODE_GET(DINamespace,(DIScope *Scope, StringRef Name, bool ExportSymbols),(Scope, Name, ExportSymbols)) DEFINE_MDNODE_GET(DINamespace
DIScope * getScope() const
Metadata MDString bool ExportSymbols
StringRef getName() const
MDString * getRawName() const
Metadata MDString * Name
friend class LLVMContextImpl
bool getExportSymbols() const
Metadata * getRawScope() const
Tagged DWARF-like metadata node.
LLVM_ABI dwarf::Tag getTag() const
static MDString * getCanonicalMDString(LLVMContext &Context, StringRef S)
static LLVM_ABI DIFlags getFlag(StringRef Flag)
static LLVM_ABI DIFlags splitFlags(DIFlags Flags, SmallVectorImpl< DIFlags > &SplitFlags)
Split up a flags bitfield.
void setTag(unsigned Tag)
Allow subclasses to mutate the tag.
DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
StringRef getStringOperand(unsigned I) const
Ty * getOperandAs(unsigned I) const
friend class LLVMContextImpl
static bool classof(const Metadata *MD)
static LLVM_ABI StringRef getFlagString(DIFlags Flag)
friend class MDNode
~DINode()=default
DIFlags
Debug info flags.
MDString Metadata unsigned MDString MDString unsigned Metadata Type TempDIObjCProperty clone() const
unsigned getAttributes() const
StringRef getFilename() const
MDString * getRawName() const
StringRef getDirectory() const
MDString * getRawSetterName() const
Metadata * getRawType() const
StringRef getGetterName() const
MDString Metadata * File
MDString Metadata unsigned MDString MDString unsigned Metadata * Type
static bool classof(const Metadata *MD)
MDString * getRawGetterName() const
Metadata * getRawFile() const
MDString Metadata unsigned MDString * GetterName
MDString Metadata unsigned MDString MDString * SetterName
StringRef getName() const
DEFINE_MDNODE_GET(DIObjCProperty,(StringRef Name, DIFile *File, unsigned Line, StringRef GetterName, StringRef SetterName, unsigned Attributes, DIType *Type),(Name, File, Line, GetterName, SetterName, Attributes, Type)) DEFINE_MDNODE_GET(DIObjCProperty
StringRef getSetterName() const
Base class for scope-like contexts.
~DIScope()=default
StringRef getFilename() const
LLVM_ABI StringRef getName() const
static bool classof(const Metadata *MD)
DIFile * getFile() const
StringRef getDirectory() const
std::optional< StringRef > getSource() const
LLVM_ABI DIScope * getScope() const
Metadata * getRawFile() const
Return the raw underlying file.
DIScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, ArrayRef< Metadata * > Ops)
Wrapper structure that holds a language name and its version.
uint16_t getUnversionedName() const
Transitional API for cases where we do not yet support versioned source language names.
uint32_t getVersion() const
Returns language version. Only valid for versioned language names.
DISourceLanguageName(uint16_t Lang, uint32_t Version)
uint16_t getName() const
Returns a versioned or unversioned language name.
String type, Fortran CHARACTER(n)
unsigned MDString * Name
unsigned MDString Metadata Metadata Metadata uint64_t SizeInBits
unsigned getEncoding() const
unsigned MDString Metadata Metadata Metadata uint64_t uint32_t AlignInBits
static bool classof(const Metadata *MD)
unsigned MDString Metadata Metadata Metadata * StringLocationExp
unsigned MDString Metadata Metadata Metadata uint64_t uint32_t unsigned Encoding unsigned MDString Metadata Metadata Metadata Metadata uint32_t unsigned Encoding TempDIStringType clone() const
DIExpression * getStringLengthExp() const
unsigned MDString Metadata Metadata * StringLengthExp
Metadata * getRawStringLengthExp() const
unsigned MDString Metadata Metadata Metadata uint64_t uint32_t unsigned Encoding
Metadata * getRawStringLength() const
DIVariable * getStringLength() const
DIExpression * getStringLocationExp() const
unsigned MDString Metadata * StringLength
Metadata * getRawStringLocationExp() const
DEFINE_MDNODE_GET(DIStringType,(unsigned Tag, StringRef Name, uint64_t SizeInBits, uint32_t AlignInBits),(Tag, Name, nullptr, nullptr, nullptr, SizeInBits, AlignInBits, 0)) DEFINE_MDNODE_GET(DIStringType
Subprogram description. Uses SubclassData1.
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata * Unit
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata MDString bool UsesKeyInstructions
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata * Annotations
Metadata MDString MDString Metadata unsigned Metadata unsigned ScopeLine
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags SPFlags
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata * ContainingType
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata * TemplateParams
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata * Declaration
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata MDString * TargetFuncName
void forEachRetainedNode(FuncLVT &&FuncLV, FuncLabelT &&FuncLabel, FuncImportedEntityT &&FuncIE) const
For each retained node, applies one of the given functions depending on the type of a node.
static LLVM_ABI DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
static const DIScope * getRawRetainedNodeScope(const MDNode *N)
Metadata MDString * Name
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata * ThrownTypes
DEFINE_MDNODE_GET(DISubprogram,(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned Line, DISubroutineType *Type, unsigned ScopeLine, DIType *ContainingType, unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, DICompileUnit *Unit, DITemplateParameterArray TemplateParams=nullptr, DISubprogram *Declaration=nullptr, DINodeArray RetainedNodes=nullptr, DITypeArray ThrownTypes=nullptr, DINodeArray Annotations=nullptr, StringRef TargetFuncName="", bool UsesKeyInstructions=false),(Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes, Annotations, TargetFuncName, UsesKeyInstructions)) DEFINE_MDNODE_GET(DISubprogram
static LLVM_ABI DISPFlags getFlag(StringRef Flag)
Metadata MDString MDString Metadata * File
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned VirtualIndex
static LLVM_ABI DISPFlags splitFlags(DISPFlags Flags, SmallVectorImpl< DISPFlags > &SplitFlags)
Split up a flags bitfield for easier printing.
static bool classof(const Metadata *MD)
Metadata MDString MDString * LinkageName
static LLVM_ABI StringRef getFlagString(DISPFlags Flag)
Metadata MDString MDString Metadata unsigned Metadata * Type
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata * RetainedNodes
DISPFlags
Debug info subprogram flags.
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int ThisAdjustment
LLVM_ABI bool describes(const Function *F) const
Check if this subprogram describes the given function.
StringRef DIFile unsigned Line
Metadata * getRawUpperBound() const
BoundType getLowerBound() const
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata * UpperBound
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType * BaseType
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata Metadata Metadata * Bias
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata Metadata * Stride
StringRef DIFile unsigned DIScope uint64_t SizeInBits
static bool classof(const Metadata *MD)
BoundType getBias() const
DEFINE_MDNODE_GET(DISubrangeType,(MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *SizeInBits, uint32_t AlignInBits, DIFlags Flags, Metadata *BaseType, Metadata *LowerBound, Metadata *UpperBound, Metadata *Stride, Metadata *Bias),(Name, File, Line, Scope, SizeInBits, AlignInBits, Flags, BaseType, LowerBound, UpperBound, Stride, Bias)) DEFINE_MDNODE_GET(DISubrangeType
Metadata * getRawBias() const
Metadata * getRawBaseType() const
StringRef DIFile * File
PointerUnion< ConstantInt *, DIVariable *, DIExpression *, DIDerivedType * > BoundType
StringRef DIFile unsigned DIScope * Scope
BoundType getUpperBound() const
DIType * getBaseType() const
Get the base type this is derived from.
BoundType getStride() const
Metadata * getRawLowerBound() const
StringRef DIFile unsigned DIScope uint64_t uint32_t AlignInBits
Metadata * getRawStride() const
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata * LowerBound
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags Flags
StringRef DIFile unsigned DIScope uint64_t uint32_t DIFlags DIType Metadata Metadata Metadata Metadata Bias TempDISubrangeType clone() const
static bool classof(const Metadata *MD)
LLVM_ABI BoundType getUpperBound() const
LLVM_ABI BoundType getStride() const
LLVM_ABI BoundType getLowerBound() const
DEFINE_MDNODE_GET(DISubrange,(int64_t Count, int64_t LowerBound=0),(Count, LowerBound)) DEFINE_MDNODE_GET(DISubrange
friend class LLVMContextImpl
LLVM_ABI BoundType getCount() const
Metadata int64_t LowerBound
Type array for a subprogram.
TempDISubroutineType cloneWithCC(uint8_t CC) const
DEFINE_MDNODE_GET(DISubroutineType,(DIFlags Flags, uint8_t CC, DITypeRefArray TypeArray),(Flags, CC, TypeArray)) DEFINE_MDNODE_GET(DISubroutineType
DIFlags uint8_t Metadata * TypeArray
static bool classof(const Metadata *MD)
Metadata * getRawTypeArray() const
DITypeRefArray getTypeArray() const
DIFlags uint8_t Metadata TypeArray TempDISubroutineType clone() const
static bool classof(const Metadata *MD)
DITemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage, unsigned Tag, bool IsDefault, ArrayRef< Metadata * > Ops)
MDString Metadata bool IsDefault
DEFINE_MDNODE_GET(DITemplateTypeParameter,(StringRef Name, DIType *Type, bool IsDefault),(Name, Type, IsDefault)) DEFINE_MDNODE_GET(DITemplateTypeParameter
MDString Metadata bool IsDefault TempDITemplateTypeParameter clone() const
static bool classof(const Metadata *MD)
unsigned MDString Metadata bool Metadata Value TempDITemplateValueParameter clone() const
unsigned MDString Metadata * Type
static bool classof(const Metadata *MD)
DEFINE_MDNODE_GET(DITemplateValueParameter,(unsigned Tag, StringRef Name, DIType *Type, bool IsDefault, Metadata *Value),(Tag, Name, Type, IsDefault, Value)) DEFINE_MDNODE_GET(DITemplateValueParameter
unsigned MDString Metadata bool IsDefault
unsigned MDString Metadata bool Metadata * Value
bool operator!=(const iterator &X) const
bool operator==(const iterator &X) const
std::input_iterator_tag iterator_category
iterator(MDNode::op_iterator I)
DIType * operator[](unsigned I) const
MDTuple & operator*() const
DITypeRefArray()=default
MDTuple * operator->() const
MDTuple * get() const
DITypeRefArray(const MDTuple *N)
Base class for types.
bool isLittleEndian() const
static constexpr unsigned N_OPERANDS
bool isPublic() const
bool isPrivate() const
uint32_t getNumExtraInhabitants() const
bool isBigEndian() const
bool isLValueReference() const
bool isBitField() const
~DIType()=default
bool isStaticMember() const
bool isVirtual() const
TempDIType cloneWithFlags(DIFlags NewFlags) const
Returns a new temporary DIType with updated Flags.
bool isObjcClassComplete() const
MDString * getRawName() const
bool isAppleBlockExtension() const
uint64_t getOffsetInBits() const
bool isVector() const
bool isProtected() const
bool isObjectPointer() const
DIFlags getFlags() const
Metadata * getRawScope() const
StringRef getName() const
bool isForwardDecl() const
bool isTypePassByValue() const
uint64_t getSizeInBits() const
static bool classof(const Metadata *MD)
DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants, DIFlags Flags, ArrayRef< Metadata * > Ops)
uint32_t getAlignInBytes() const
void mutate(unsigned Tag, unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants, DIFlags Flags)
Change fields in place.
void init(unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants, DIFlags Flags)
LLVM_ABI uint32_t getAlignInBits() const
Metadata * getRawSizeInBits() const
unsigned getLine() const
bool isRValueReference() const
bool isArtificial() const
bool getExportSymbols() const
TempDIType clone() const
DIScope * getScope() const
bool isTypePassByReference() const
Metadata * getRawOffsetInBits() const
Base class for variables.
std::optional< DIBasicType::Signedness > getSignedness() const
Return the signedness of this variable's type, or std::nullopt if this type is neither signed nor uns...
uint32_t getAlignInBits() const
DIFile * getFile() const
MDString * getRawName() const
uint32_t getAlignInBytes() const
DIScope * getScope() const
~DIVariable()=default
StringRef getDirectory() const
LLVM_ABI std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
Metadata * getRawFile() const
std::optional< StringRef > getSource() const
StringRef getFilename() const
Metadata * getRawType() const
static bool classof(const Metadata *MD)
LLVM_ABI DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, signed Line, ArrayRef< Metadata * > Ops, uint32_t AlignInBits=0)
DIType * getType() const
unsigned getLine() const
StringRef getName() const
Metadata * getRawScope() const
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Identifies a unique instance of a whole variable (discards/ignores fragment information).
LLVM_ABI DebugVariableAggregate(const DbgVariableRecord *DVR)
DebugVariableAggregate(const DebugVariable &V)
Identifies a unique instance of a variable.
static bool isDefaultFragment(const FragmentInfo F)
DebugVariable(const DILocalVariable *Var, const DIExpression *DIExpr, const DILocation *InlinedAt)
const DILocation * getInlinedAt() const
bool operator<(const DebugVariable &Other) const
DebugVariable(const DILocalVariable *Var, std::optional< FragmentInfo > FragmentInfo, const DILocation *InlinedAt)
bool operator==(const DebugVariable &Other) const
FragmentInfo getFragmentOrDefault() const
std::optional< FragmentInfo > getFragment() const
const DILocalVariable * getVariable() const
LLVM_ABI DebugVariable(const DbgVariableRecord *DVR)
Class representing an expression and its matching format.
Generic tagged DWARF-like metadata node.
static bool classof(const Metadata *MD)
unsigned MDString ArrayRef< Metadata * > DwarfOps TempGenericDINode clone() const
Return a (temporary) clone of this.
LLVM_ABI dwarf::Tag getTag() const
StringRef getHeader() const
MDString * getRawHeader() const
const MDOperand & getDwarfOperand(unsigned I) const
unsigned getHash() const
unsigned getNumDwarfOperands() const
op_iterator dwarf_op_end() const
op_iterator dwarf_op_begin() const
unsigned MDString * Header
op_range dwarf_operands() const
DEFINE_MDNODE_GET(GenericDINode,(unsigned Tag, StringRef Header, ArrayRef< Metadata * > DwarfOps),(Tag, Header, DwarfOps)) DEFINE_MDNODE_GET(GenericDINode
void replaceDwarfOperandWith(unsigned I, Metadata *New)
unsigned MDString ArrayRef< Metadata * > DwarfOps
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1078
friend class DIAssignID
Definition Metadata.h:1081
LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
const MDOperand & getOperand(unsigned I) const
Definition Metadata.h:1442
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1581
op_iterator op_end() const
Definition Metadata.h:1436
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1569
bool isUniqued() const
Definition Metadata.h:1260
unsigned getNumOperands() const
Return number of MDNode operands.
Definition Metadata.h:1448
iterator_range< op_iterator > op_range
Definition Metadata.h:1430
LLVM_ABI TempMDNode clone() const
Create a (temporary) clone of this.
Definition Metadata.cpp:669
bool isDistinct() const
Definition Metadata.h:1261
LLVM_ABI void setOperand(unsigned I, Metadata *New)
Set an operand.
op_iterator op_begin() const
Definition Metadata.h:1432
LLVMContext & getContext() const
Definition Metadata.h:1242
LLVM_ABI void dropAllReferences()
Definition Metadata.cpp:909
const MDOperand * op_iterator
Definition Metadata.h:1429
Tracking metadata reference owned by Metadata.
Definition Metadata.h:900
Metadata * get() const
Definition Metadata.h:929
A single uniqued string.
Definition Metadata.h:721
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:608
Tuple of metadata.
Definition Metadata.h:1497
Root of the metadata hierarchy.
Definition Metadata.h:64
StorageType
Active type of storage.
Definition Metadata.h:72
unsigned short SubclassData16
Definition Metadata.h:78
unsigned SubclassData32
Definition Metadata.h:79
unsigned char Storage
Storage flag for non-uniqued, otherwise unowned, metadata.
Definition Metadata.h:75
unsigned getMetadataID() const
Definition Metadata.h:104
unsigned char SubclassData1
Definition Metadata.h:77
Metadata(unsigned ID, StorageType Storage)
Definition Metadata.h:88
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
LLVM_ABI SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
Returns the list of all DbgVariableRecord users of this.
Definition Metadata.cpp:273
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::iterator iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:143
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:297
LLVM Value Representation.
Definition Value.h:75
A range adaptor for a pair of iterators.
LLVM_ABI unsigned getVirtuality(StringRef VirtualityString)
Definition Dwarf.cpp:385
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
template class LLVM_TEMPLATE_ABI opt< bool >
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:532
bool operator<(int64_t V1, const APSInt &V2)
Definition APSInt.h:362
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI cl::opt< bool > EnableFSDiscriminator
bool operator!=(uint64_t V1, const APInt &V2)
Definition APInt.h:2114
auto cast_or_null(const Y &Val)
Definition Casting.h:714
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
static unsigned getBaseFSBitEnd()
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Ref
The access may reference the value stored in memory.
Definition ModRef.h:32
@ LLVM_MARK_AS_BITMASK_ENUM
Definition ModRef.h:37
@ Other
Any other memory.
Definition ModRef.h:68
static unsigned getN1Bits(int N)
FunctionAddr VTableAddr Next
Definition InstrProf.h:141
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
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:1909
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition Hashing.h:592
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870
#define N
Pointer authentication (__ptrauth) metadata.
PtrAuthData(unsigned Key, bool IsDiscr, unsigned Discriminator, bool IsaPointer, bool AuthenticatesNullValues)
A single checksum, represented by a Kind and a Value (a string).
bool operator==(const ChecksumInfo< T > &X) const
T Value
The string value of the checksum.
ChecksumKind Kind
The kind of checksum which Value encodes.
ChecksumInfo(ChecksumKind Kind, T Value)
bool operator!=(const ChecksumInfo< T > &X) const
StringRef getKindAsString() const
static bool isEqual(const FragInfo &A, const FragInfo &B)
static unsigned getHashValue(const FragInfo &Frag)
static unsigned getHashValue(const DebugVariable &D)
static DebugVariable getEmptyKey()
Empty key: no key should be generated that has no DILocalVariable.
DIExpression::FragmentInfo FragmentInfo
static DebugVariable getTombstoneKey()
Difference in tombstone is that the Optional is meaningful.
static bool isEqual(const DebugVariable &A, const DebugVariable &B)
An information struct used to provide DenseMap with the various necessary components for a given valu...
static uint32_t extractProbeIndex(uint32_t Value)
Definition PseudoProbe.h:75
static std::optional< uint32_t > extractDwarfBaseDiscriminator(uint32_t Value)
Definition PseudoProbe.h:81