LLVM 24.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"
24#include "llvm/IR/Constants.h"
26#include "llvm/IR/Metadata.h"
27#include "llvm/IR/PseudoProbe.h"
32#include <cassert>
33#include <climits>
34#include <cstddef>
35#include <cstdint>
36#include <iterator>
37#include <optional>
38#include <type_traits>
39#include <vector>
40
41// Helper macros for defining get() overrides.
42#define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__
43#define DEFINE_MDNODE_GET_UNPACK(ARGS) DEFINE_MDNODE_GET_UNPACK_IMPL ARGS
44#define DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS) \
45 static CLASS *getDistinct(LLVMContext &Context, \
46 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
47 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct); \
48 } \
49 static Temp##CLASS getTemporary(LLVMContext &Context, \
50 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
51 return Temp##CLASS( \
52 getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary)); \
53 }
54#define DEFINE_MDNODE_GET(CLASS, FORMAL, ARGS) \
55 static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
56 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued); \
57 } \
58 static CLASS *getIfExists(LLVMContext &Context, \
59 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
60 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued, \
61 /* ShouldCreate */ false); \
62 } \
63 DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)
64
65namespace llvm {
66
67namespace dwarf {
68enum Tag : uint16_t;
69}
70
71/// Wrapper structure that holds source language identity metadata that includes
72/// language name, optional language version, and an optional language dialect.
73///
74/// Some debug-info formats, particularly DWARF, distniguish between
75/// language codes that include the version name and codes that don't.
76/// DISourceLanguageName may hold either of these.
77///
79 /// Language version. The version scheme is language
80 /// dependent.
81 uint32_t Version = 0;
82
83 /// Language name.
84 /// If \ref HasVersion is \c true, then this name
85 /// is version independent (i.e., doesn't include the language
86 /// version in its name).
87 uint16_t Name;
88
89 /// If \c true, then \ref Version is interpretable and \ref Name
90 /// is a version independent name.
91 bool HasVersion;
92
93 /// Optional target-specific language dialect for DWARF that can be used to
94 /// indicate the programming/execution model.
95 ///
96 /// This is intentionally not modeled as a DICompileUnit operand. Code that
97 /// introspects DICompileUnit through getNumOperands()/getOperand(i) will not
98 /// see this field.
99 uint16_t Dialect = 0;
100
101public:
102 bool hasVersionedName() const { return HasVersion; }
103
104 /// Returns a versioned or unversioned language name.
105 uint16_t getName() const { return Name; }
106
107 /// Transitional API for cases where we do not yet support
108 /// versioned source language names. Use \ref getName instead.
109 ///
110 /// FIXME: remove once all callers of this API account for versioned
111 /// names.
114 return Name;
115 }
116
117 /// Returns language version. Only valid for versioned language names.
120 return Version;
121 }
122
123 uint16_t getDialect() const { return Dialect; }
124
125 DISourceLanguageName(uint16_t Lang, uint32_t Version, uint16_t Dialect = 0)
126 : Version(Version), Name(Lang), HasVersion(true), Dialect(Dialect) {}
128 : Version(0), Name(Lang), HasVersion(false), Dialect(Dialect) {}
129};
130
131class DbgVariableRecord;
132
134
135/// Tagged DWARF-like metadata node.
136///
137/// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,
138/// defined in llvm/BinaryFormat/Dwarf.h). Called \a DINode because it's
139/// potentially used for non-DWARF output.
140///
141/// Uses the SubclassData16 Metadata slot.
142class DINode : public MDNode {
143 friend class LLVMContextImpl;
144 friend class MDNode;
145
146protected:
147 DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
149 : MDNode(C, ID, Storage, Ops1, Ops2) {
150 assert(Tag < 1u << 16);
152 }
153 ~DINode() = default;
154
155 template <class Ty> Ty *getOperandAs(unsigned I) const {
157 }
158
159 StringRef getStringOperand(unsigned I) const {
160 if (auto *S = getOperandAs<MDString>(I))
161 return S->getString();
162 return StringRef();
163 }
164
166 if (S.empty())
167 return nullptr;
168 return MDString::get(Context, S);
169 }
170
171 /// Allow subclasses to mutate the tag.
172 void setTag(unsigned Tag) { SubclassData16 = Tag; }
173
174public:
175 LLVM_ABI dwarf::Tag getTag() const;
176
177 /// Debug info flags.
178 ///
179 /// The three accessibility flags are mutually exclusive and rolled together
180 /// in the first two bits.
182#define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = ID,
183#define DI_FLAG_LARGEST_NEEDED
184#include "llvm/IR/DebugInfoFlags.def"
185 FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic,
186 FlagPtrToMemberRep = FlagSingleInheritance | FlagMultipleInheritance |
187 FlagVirtualInheritance,
188 LLVM_MARK_AS_BITMASK_ENUM(FlagLargest)
189 };
190
191 LLVM_ABI static DIFlags getFlag(StringRef Flag);
192 LLVM_ABI static StringRef getFlagString(DIFlags Flag);
193
194 /// Split up a flags bitfield.
195 ///
196 /// Split \c Flags into \c SplitFlags, a vector of its components. Returns
197 /// any remaining (unrecognized) bits.
198 LLVM_ABI static DIFlags splitFlags(DIFlags Flags,
199 SmallVectorImpl<DIFlags> &SplitFlags);
200
201 static bool classof(const Metadata *MD) {
202 switch (MD->getMetadataID()) {
203 default:
204 return false;
205 case GenericDINodeKind:
206 case DISubrangeKind:
207 case DIEnumeratorKind:
208 case DIBasicTypeKind:
209 case DIFixedPointTypeKind:
210 case DIStringTypeKind:
211 case DISubrangeTypeKind:
212 case DIDerivedTypeKind:
213 case DICompositeTypeKind:
214 case DISubroutineTypeKind:
215 case DIFileKind:
216 case DICompileUnitKind:
217 case DISubprogramKind:
218 case DILexicalBlockKind:
219 case DILexicalBlockFileKind:
220 case DINamespaceKind:
221 case DICommonBlockKind:
222 case DITemplateTypeParameterKind:
223 case DITemplateValueParameterKind:
224 case DIGlobalVariableKind:
225 case DILocalVariableKind:
226 case DILabelKind:
227 case DIObjCPropertyKind:
228 case DIPropertyKind:
229 case DIImportedEntityKind:
230 case DIModuleKind:
231 case DIGenericSubrangeKind:
232 case DIAssignIDKind:
233 return true;
234 }
235 }
236};
237
238/// Generic tagged DWARF-like metadata node.
239///
240/// An un-specialized DWARF-like metadata node. The first operand is a
241/// (possibly empty) null-separated \a MDString header that contains arbitrary
242/// fields. The remaining operands are \a dwarf_operands(), and are pointers
243/// to other metadata.
244///
245/// Uses the SubclassData32 Metadata slot.
246class GenericDINode : public DINode {
247 friend class LLVMContextImpl;
248 friend class MDNode;
249
250 GenericDINode(LLVMContext &C, StorageType Storage, unsigned Hash,
251 unsigned Tag, ArrayRef<Metadata *> Ops1,
253 : DINode(C, GenericDINodeKind, Storage, Tag, Ops1, Ops2) {
254 setHash(Hash);
255 }
257
258 void setHash(unsigned Hash) { SubclassData32 = Hash; }
259 void recalculateHash();
260
261 static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
263 StorageType Storage, bool ShouldCreate = true) {
264 return getImpl(Context, Tag, getCanonicalMDString(Context, Header),
265 DwarfOps, Storage, ShouldCreate);
266 }
267
268 LLVM_ABI static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
269 MDString *Header,
272 bool ShouldCreate = true);
273
274 TempGenericDINode cloneImpl() const {
277 }
278
279public:
280 unsigned getHash() const { return SubclassData32; }
281
282 DEFINE_MDNODE_GET(GenericDINode,
283 (unsigned Tag, StringRef Header,
285 (Tag, Header, DwarfOps))
286 DEFINE_MDNODE_GET(GenericDINode,
287 (unsigned Tag, MDString *Header,
290
291 /// Return a (temporary) clone of this.
292 TempGenericDINode clone() const { return cloneImpl(); }
293
294 LLVM_ABI dwarf::Tag getTag() const;
295 StringRef getHeader() const { return getStringOperand(0); }
297
298 op_iterator dwarf_op_begin() const { return op_begin() + 1; }
299 op_iterator dwarf_op_end() const { return op_end(); }
302 }
303
304 unsigned getNumDwarfOperands() const { return getNumOperands() - 1; }
305 const MDOperand &getDwarfOperand(unsigned I) const {
306 return getOperand(I + 1);
307 }
308 void replaceDwarfOperandWith(unsigned I, Metadata *New) {
309 replaceOperandWith(I + 1, New);
310 }
311
312 static bool classof(const Metadata *MD) {
313 return MD->getMetadataID() == GenericDINodeKind;
314 }
315};
316
317/// Assignment ID.
318/// Used to link stores (as an attachment) and dbg.assigns (as an operand).
319/// DIAssignID metadata is never uniqued as we compare instances using
320/// referential equality (the instance/address is the ID).
321class DIAssignID : public MDNode {
322 friend class LLVMContextImpl;
323 friend class MDNode;
324 friend class Instruction;
325 friend class DebugValueUser;
326
327 /// The instructions this ID is attached to and the dbg_assign records that
328 /// refer to it, maintained by Instruction and DebugValueUser.
331
333 : MDNode(C, DIAssignIDKind, Storage, {}) {}
334
335 ~DIAssignID() { dropAllReferences(); }
336
337 LLVM_ABI static DIAssignID *getImpl(LLVMContext &Context, StorageType Storage,
338 bool ShouldCreate = true);
339
340 TempDIAssignID cloneImpl() const { return getTemporary(getContext()); }
341
342public:
343 // This node has no operands to replace.
344 void replaceOperandWith(unsigned I, Metadata *New) = delete;
345
346 ArrayRef<Instruction *> getInstructions() const { return Instrs; }
347 ArrayRef<DbgVariableRecord *> getRecords() const { return Records; }
348
349 static DIAssignID *getDistinct(LLVMContext &Context) {
350 return getImpl(Context, Distinct);
351 }
352 static TempDIAssignID getTemporary(LLVMContext &Context) {
353 return TempDIAssignID(getImpl(Context, Temporary));
354 }
355 // NOTE: Do not define get(LLVMContext&) - see class comment.
356
357 static bool classof(const Metadata *MD) {
358 return MD->getMetadataID() == DIAssignIDKind;
359 }
360};
361
362/// Array subrange.
363class DISubrange : public DINode {
364 friend class LLVMContextImpl;
365 friend class MDNode;
366
368
369 ~DISubrange() = default;
370
371 LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, int64_t Count,
373 bool ShouldCreate = true);
374
375 LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
377 bool ShouldCreate = true);
378
379 LLVM_ABI static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
381 Metadata *UpperBound, Metadata *Stride,
383 bool ShouldCreate = true);
384
385 TempDISubrange cloneImpl() const {
386 return getTemporary(getContext(), getRawCountNode(), getRawLowerBound(),
387 getRawUpperBound(), getRawStride());
388 }
389
390public:
391 DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0),
392 (Count, LowerBound))
393
394 DEFINE_MDNODE_GET(DISubrange, (Metadata * CountNode, int64_t LowerBound = 0),
396
397 DEFINE_MDNODE_GET(DISubrange,
399 Metadata *UpperBound, Metadata *Stride),
400 (CountNode, LowerBound, UpperBound, Stride))
401
402 TempDISubrange clone() const { return cloneImpl(); }
403
404 Metadata *getRawCountNode() const { return getOperand(0).get(); }
405
406 Metadata *getRawLowerBound() const { return getOperand(1).get(); }
407
408 Metadata *getRawUpperBound() const { return getOperand(2).get(); }
409
410 Metadata *getRawStride() const { return getOperand(3).get(); }
411
412 typedef PointerUnion<ConstantInt *, DIVariable *, DIExpression *> BoundType;
413
414 LLVM_ABI BoundType getCount() const;
415
416 LLVM_ABI BoundType getLowerBound() const;
417
418 LLVM_ABI BoundType getUpperBound() const;
419
420 LLVM_ABI BoundType getStride() const;
421
422 static bool classof(const Metadata *MD) {
423 return MD->getMetadataID() == DISubrangeKind;
424 }
425};
426
427class DIGenericSubrange : public DINode {
428 friend class LLVMContextImpl;
429 friend class MDNode;
430
431 DIGenericSubrange(LLVMContext &C, StorageType Storage,
433
434 ~DIGenericSubrange() = default;
435
436 LLVM_ABI static DIGenericSubrange *
437 getImpl(LLVMContext &Context, Metadata *CountNode, Metadata *LowerBound,
438 Metadata *UpperBound, Metadata *Stride, StorageType Storage,
439 bool ShouldCreate = true);
440
441 TempDIGenericSubrange cloneImpl() const {
444 }
445
446public:
447 DEFINE_MDNODE_GET(DIGenericSubrange,
448 (Metadata * CountNode, Metadata *LowerBound,
449 Metadata *UpperBound, Metadata *Stride),
450 (CountNode, LowerBound, UpperBound, Stride))
451
452 TempDIGenericSubrange clone() const { return cloneImpl(); }
453
454 Metadata *getRawCountNode() const { return getOperand(0).get(); }
455 Metadata *getRawLowerBound() const { return getOperand(1).get(); }
456 Metadata *getRawUpperBound() const { return getOperand(2).get(); }
457 Metadata *getRawStride() const { return getOperand(3).get(); }
458
460
465
466 static bool classof(const Metadata *MD) {
467 return MD->getMetadataID() == DIGenericSubrangeKind;
468 }
469};
470
471/// Enumeration value.
472///
473/// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
474/// longer creates a type cycle.
475class DIEnumerator : public DINode {
476 friend class LLVMContextImpl;
477 friend class MDNode;
478
479 APInt Value;
480 LLVM_ABI DIEnumerator(LLVMContext &C, StorageType Storage, const APInt &Value,
482 DIEnumerator(LLVMContext &C, StorageType Storage, int64_t Value,
484 : DIEnumerator(C, Storage, APInt(64, Value, !IsUnsigned), IsUnsigned,
485 Ops) {}
486 ~DIEnumerator() = default;
487
488 static DIEnumerator *getImpl(LLVMContext &Context, const APInt &Value,
490 StorageType Storage, bool ShouldCreate = true) {
491 return getImpl(Context, Value, IsUnsigned,
492 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
493 }
494 LLVM_ABI static DIEnumerator *getImpl(LLVMContext &Context,
495 const APInt &Value, bool IsUnsigned,
496 MDString *Name, StorageType Storage,
497 bool ShouldCreate = true);
498
499 TempDIEnumerator cloneImpl() const {
501 }
502
503public:
504 DEFINE_MDNODE_GET(DIEnumerator,
505 (int64_t Value, bool IsUnsigned, StringRef Name),
506 (APInt(64, Value, !IsUnsigned), IsUnsigned, Name))
507 DEFINE_MDNODE_GET(DIEnumerator,
508 (int64_t Value, bool IsUnsigned, MDString *Name),
509 (APInt(64, Value, !IsUnsigned), IsUnsigned, Name))
510 DEFINE_MDNODE_GET(DIEnumerator,
511 (APInt Value, bool IsUnsigned, StringRef Name),
512 (Value, IsUnsigned, Name))
513 DEFINE_MDNODE_GET(DIEnumerator,
514 (APInt Value, bool IsUnsigned, MDString *Name),
515 (Value, IsUnsigned, Name))
516
517 TempDIEnumerator clone() const { return cloneImpl(); }
518
519 const APInt &getValue() const { return Value; }
520 bool isUnsigned() const { return SubclassData32; }
521 StringRef getName() const { return getStringOperand(0); }
522
524
525 static bool classof(const Metadata *MD) {
526 return MD->getMetadataID() == DIEnumeratorKind;
527 }
528};
529
530/// Base class for scope-like contexts.
531///
532/// Base class for lexical scopes and types (which are also declaration
533/// contexts).
534///
535/// TODO: Separate the concepts of declaration contexts and lexical scopes.
536class DIScope : public DINode {
537protected:
538 DIScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
540 : DINode(C, ID, Storage, Tag, Ops) {}
541 ~DIScope() = default;
542
543public:
545
546 inline StringRef getFilename() const;
547 inline StringRef getDirectory() const;
548 inline std::optional<StringRef> getSource() const;
549
550 LLVM_ABI StringRef getName() const;
551 LLVM_ABI DIScope *getScope() const;
552
553 /// Return the raw underlying file.
554 ///
555 /// A \a DIFile is a \a DIScope, but it doesn't point at a separate file (it
556 /// \em is the file). If \c this is an \a DIFile, we need to return \c this.
557 /// Otherwise, return the first operand, which is where all other subclasses
558 /// store their file pointer.
560 return isa<DIFile>(this) ? const_cast<DIScope *>(this)
561 : static_cast<Metadata *>(getOperand(0));
562 }
563
564 static bool classof(const Metadata *MD) {
565 switch (MD->getMetadataID()) {
566 default:
567 return false;
568 case DIBasicTypeKind:
569 case DIFixedPointTypeKind:
570 case DIStringTypeKind:
571 case DISubrangeTypeKind:
572 case DIDerivedTypeKind:
573 case DICompositeTypeKind:
574 case DISubroutineTypeKind:
575 case DIFileKind:
576 case DICompileUnitKind:
577 case DISubprogramKind:
578 case DILexicalBlockKind:
579 case DILexicalBlockFileKind:
580 case DINamespaceKind:
581 case DICommonBlockKind:
582 case DIModuleKind:
583 return true;
584 }
585 }
586};
587
588/// File.
589///
590/// TODO: Merge with directory/file node (including users).
591/// TODO: Canonicalize paths on creation.
592class DIFile : public DIScope {
593 friend class LLVMContextImpl;
594 friend class MDNode;
595
596public:
597 /// Which algorithm (e.g. MD5) a checksum was generated with.
598 ///
599 /// The encoding is explicit because it is used directly in Bitcode. The
600 /// value 0 is reserved to indicate the absence of a checksum in Bitcode.
602 // The first variant was originally CSK_None, encoded as 0. The new
603 // internal representation removes the need for this by wrapping the
604 // ChecksumInfo in an Optional, but to preserve Bitcode compatibility the 0
605 // encoding is reserved.
609 CSK_Last = CSK_SHA256 // Should be last enumeration.
610 };
611
612 /// A single checksum, represented by a \a Kind and a \a Value (a string).
613 template <typename T> struct ChecksumInfo {
614 /// The kind of checksum which \a Value encodes.
616 /// The string value of the checksum.
618
620 ~ChecksumInfo() = default;
621 bool operator==(const ChecksumInfo<T> &X) const {
622 return Kind == X.Kind && Value == X.Value;
623 }
624 bool operator!=(const ChecksumInfo<T> &X) const { return !(*this == X); }
625 StringRef getKindAsString() const { return getChecksumKindAsString(Kind); }
626 };
627
628private:
629 std::optional<ChecksumInfo<MDString *>> Checksum;
630 /// An optional source. A nullptr means none.
632
634 std::optional<ChecksumInfo<MDString *>> CS, MDString *Src,
636 ~DIFile() = default;
637
638 static DIFile *getImpl(LLVMContext &Context, StringRef Filename,
640 std::optional<ChecksumInfo<StringRef>> CS,
641 std::optional<StringRef> Source, StorageType Storage,
642 bool ShouldCreate = true) {
643 std::optional<ChecksumInfo<MDString *>> MDChecksum;
644 if (CS)
645 MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value));
646 return getImpl(Context, getCanonicalMDString(Context, Filename),
647 getCanonicalMDString(Context, Directory), MDChecksum,
648 Source ? MDString::get(Context, *Source) : nullptr, Storage,
649 ShouldCreate);
650 }
651 LLVM_ABI static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
652 MDString *Directory,
653 std::optional<ChecksumInfo<MDString *>> CS,
654 MDString *Source, StorageType Storage,
655 bool ShouldCreate = true);
656
657 TempDIFile cloneImpl() const {
659 getChecksum(), getSource());
660 }
661
662public:
665 std::optional<ChecksumInfo<StringRef>> CS = std::nullopt,
666 std::optional<StringRef> Source = std::nullopt),
667 (Filename, Directory, CS, Source))
668 DEFINE_MDNODE_GET(DIFile,
670 std::optional<ChecksumInfo<MDString *>> CS = std::nullopt,
671 MDString *Source = nullptr),
672 (Filename, Directory, CS, Source))
673
674 TempDIFile clone() const { return cloneImpl(); }
675
676 StringRef getFilename() const { return getStringOperand(0); }
677 StringRef getDirectory() const { return getStringOperand(1); }
678 std::optional<ChecksumInfo<StringRef>> getChecksum() const {
679 std::optional<ChecksumInfo<StringRef>> StringRefChecksum;
680 if (Checksum)
681 StringRefChecksum.emplace(Checksum->Kind, Checksum->Value->getString());
682 return StringRefChecksum;
683 }
684 std::optional<StringRef> getSource() const {
685 return Source ? std::optional<StringRef>(Source->getString())
686 : std::nullopt;
687 }
688
689 MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
690 MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
691 std::optional<ChecksumInfo<MDString *>> getRawChecksum() const {
692 return Checksum;
693 }
694 MDString *getRawSource() const { return Source; }
695
696 LLVM_ABI static StringRef getChecksumKindAsString(ChecksumKind CSKind);
697 LLVM_ABI static std::optional<ChecksumKind>
698 getChecksumKind(StringRef CSKindStr);
699
700 static bool classof(const Metadata *MD) {
701 return MD->getMetadataID() == DIFileKind;
702 }
703};
704
706 if (auto *F = getFile())
707 return F->getFilename();
708 return "";
709}
710
712 if (auto *F = getFile())
713 return F->getDirectory();
714 return "";
715}
716
717std::optional<StringRef> DIScope::getSource() const {
718 if (auto *F = getFile())
719 return F->getSource();
720 return std::nullopt;
721}
722
723/// Base class for types.
724///
725/// TODO: Remove the hardcoded name and context, since many types don't use
726/// them.
727/// TODO: Split up flags.
728///
729/// Uses the SubclassData32 Metadata slot.
730class DIType : public DIScope {
731 unsigned Line;
732 DIFlags Flags;
733 uint32_t NumExtraInhabitants;
734
735protected:
736 static constexpr unsigned N_OPERANDS = 5;
737
738 DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
739 unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants,
741 : DIScope(C, ID, Storage, Tag, Ops) {
742 init(Line, AlignInBits, NumExtraInhabitants, Flags);
743 }
744 ~DIType() = default;
745
746 void init(unsigned Line, uint32_t AlignInBits, uint32_t NumExtraInhabitants,
747 DIFlags Flags) {
748 this->Line = Line;
749 this->Flags = Flags;
750 this->SubclassData32 = AlignInBits;
751 this->NumExtraInhabitants = NumExtraInhabitants;
752 }
753
754 /// Change fields in place.
755 void mutate(unsigned Tag, unsigned Line, uint32_t AlignInBits,
756 uint32_t NumExtraInhabitants, DIFlags Flags) {
757 assert(isDistinct() && "Only distinct nodes can mutate");
758 setTag(Tag);
759 init(Line, AlignInBits, NumExtraInhabitants, Flags);
760 }
761
762public:
763 TempDIType clone() const {
764 return TempDIType(cast<DIType>(MDNode::clone().release()));
765 }
766
767 unsigned getLine() const { return Line; }
769 uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
770 uint32_t getNumExtraInhabitants() const { return NumExtraInhabitants; }
771 DIFlags getFlags() const { return Flags; }
772
774 StringRef getName() const { return getStringOperand(2); }
775
776 Metadata *getRawScope() const { return getOperand(1); }
778
779 Metadata *getRawSizeInBits() const { return getOperand(3); }
782 if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(MD->getValue()))
783 return CI->getZExtValue();
784 }
785 return 0;
786 }
787
788 Metadata *getRawOffsetInBits() const { return getOperand(4); }
791 if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(MD->getValue()))
792 return CI->getZExtValue();
793 }
794 return 0;
795 }
796
797 /// Returns a new temporary DIType with updated Flags
798 TempDIType cloneWithFlags(DIFlags NewFlags) const {
799 auto NewTy = clone();
800 NewTy->Flags = NewFlags;
801 return NewTy;
802 }
803
804 bool isPrivate() const {
805 return (getFlags() & FlagAccessibility) == FlagPrivate;
806 }
807 bool isProtected() const {
808 return (getFlags() & FlagAccessibility) == FlagProtected;
809 }
810 bool isPublic() const {
811 return (getFlags() & FlagAccessibility) == FlagPublic;
812 }
813 bool isForwardDecl() const { return getFlags() & FlagFwdDecl; }
814 bool isAppleBlockExtension() const { return getFlags() & FlagAppleBlock; }
815 bool isVirtual() const { return getFlags() & FlagVirtual; }
816 bool isArtificial() const { return getFlags() & FlagArtificial; }
817 bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
818 bool isObjcClassComplete() const {
819 return getFlags() & FlagObjcClassComplete;
820 }
821 bool isVector() const { return getFlags() & FlagVector; }
822 bool isBitField() const { return getFlags() & FlagBitField; }
823 bool isStaticMember() const { return getFlags() & FlagStaticMember; }
824 bool isLValueReference() const { return getFlags() & FlagLValueReference; }
825 bool isRValueReference() const { return getFlags() & FlagRValueReference; }
826 bool isTypePassByValue() const { return getFlags() & FlagTypePassByValue; }
828 return getFlags() & FlagTypePassByReference;
829 }
830 bool isBigEndian() const { return getFlags() & FlagBigEndian; }
831 bool isLittleEndian() const { return getFlags() & FlagLittleEndian; }
832 bool getExportSymbols() const { return getFlags() & FlagExportSymbols; }
833
834 static bool classof(const Metadata *MD) {
835 switch (MD->getMetadataID()) {
836 default:
837 return false;
838 case DIBasicTypeKind:
839 case DIFixedPointTypeKind:
840 case DIStringTypeKind:
841 case DISubrangeTypeKind:
842 case DIDerivedTypeKind:
843 case DICompositeTypeKind:
844 case DISubroutineTypeKind:
845 return true;
846 }
847 }
848};
849
850/// Basic type, like 'int' or 'float'.
851///
852/// TODO: Split out DW_TAG_unspecified_type.
853/// TODO: Drop unused accessors.
854class DIBasicType : public DIType {
855 friend class LLVMContextImpl;
856 friend class MDNode;
857
858 unsigned Encoding;
859 /// Describes the number of bits used by the value of the object. Non-zero
860 /// when the value of an object does not fully occupy the storage size
861 /// specified by SizeInBits.
862 uint32_t DataSizeInBits;
863
864protected:
866 unsigned LineNo, uint32_t AlignInBits, unsigned Encoding,
867 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
869 : DIType(C, DIBasicTypeKind, Storage, Tag, LineNo, AlignInBits,
871 Encoding(Encoding), DataSizeInBits(DataSizeInBits) {}
872 DIBasicType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
873 unsigned LineNo, uint32_t AlignInBits, unsigned Encoding,
874 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
877 Flags, Ops),
878 Encoding(Encoding), DataSizeInBits(DataSizeInBits) {}
879 ~DIBasicType() = default;
880
881 static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
882 StringRef Name, DIFile *File, unsigned LineNo,
884 uint32_t AlignInBits, unsigned Encoding,
886 uint32_t DataSizeInBits, DIFlags Flags,
887 StorageType Storage, bool ShouldCreate = true) {
888 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
889 LineNo, Scope, SizeInBits, AlignInBits, Encoding,
890 NumExtraInhabitants, DataSizeInBits, Flags, Storage,
891 ShouldCreate);
892 }
893 static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
894 MDString *Name, DIFile *File, unsigned LineNo,
896 uint32_t AlignInBits, unsigned Encoding,
898 uint32_t DataSizeInBits, DIFlags Flags,
899 StorageType Storage, bool ShouldCreate = true) {
900 auto *SizeInBitsNode = ConstantAsMetadata::get(
901 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
902 return getImpl(Context, Tag, Name, File, LineNo, Scope, SizeInBitsNode,
903 AlignInBits, Encoding, NumExtraInhabitants, DataSizeInBits,
904 Flags, Storage, ShouldCreate);
905 }
906 LLVM_ABI static DIBasicType *
907 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
908 unsigned LineNo, Metadata *Scope, Metadata *SizeInBits,
911 bool ShouldCreate = true);
912
913 TempDIBasicType cloneImpl() const {
914 return getTemporary(
918 }
919
920public:
922 (Tag, Name, nullptr, 0, nullptr, 0, 0, 0, 0, 0, FlagZero))
925 (Tag, Name, nullptr, 0, nullptr, SizeInBits, 0, 0, 0, 0,
926 FlagZero))
928 (unsigned Tag, MDString *Name, uint64_t SizeInBits),
929 (Tag, Name, nullptr, 0, nullptr, SizeInBits, 0, 0, 0, 0,
930 FlagZero))
933 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
934 (Tag, Name, nullptr, 0, nullptr, SizeInBits, AlignInBits,
935 Encoding, 0, 0, Flags))
937 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
938 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
939 (Tag, Name, nullptr, 0, nullptr, SizeInBits, AlignInBits,
940 Encoding, 0, 0, Flags))
943 uint32_t AlignInBits, unsigned Encoding,
945 (Tag, Name, nullptr, 0, nullptr, SizeInBits, AlignInBits,
949 uint32_t AlignInBits, unsigned Encoding,
950 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
951 DIFlags Flags),
952 (Tag, Name, nullptr, 0, nullptr, SizeInBits, AlignInBits,
953 Encoding, NumExtraInhabitants, DataSizeInBits, Flags))
957 uint32_t AlignInBits, unsigned Encoding,
961 Encoding, NumExtraInhabitants, DataSizeInBits, Flags))
963 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
964 uint32_t AlignInBits, unsigned Encoding,
965 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
966 DIFlags Flags),
967 (Tag, Name, nullptr, 0, nullptr, SizeInBits, AlignInBits,
968 Encoding, NumExtraInhabitants, DataSizeInBits, Flags))
971 uint32_t AlignInBits, unsigned Encoding,
974 (Tag, Name, nullptr, 0, nullptr, SizeInBits, AlignInBits,
975 Encoding, NumExtraInhabitants, DataSizeInBits, Flags))
977 (unsigned Tag, MDString *Name, Metadata *File,
979 uint32_t AlignInBits, unsigned Encoding,
980 uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
981 DIFlags Flags),
983 Encoding, NumExtraInhabitants, DataSizeInBits, Flags))
984
985 TempDIBasicType clone() const { return cloneImpl(); }
986
987 unsigned getEncoding() const { return Encoding; }
988
989 uint32_t getDataSizeInBits() const { return DataSizeInBits; }
990
991 enum class Signedness { Signed, Unsigned };
992
993 /// Return the signedness of this type, or std::nullopt if this type is
994 /// neither signed nor unsigned.
995 LLVM_ABI std::optional<Signedness> getSignedness() const;
996
997 static bool classof(const Metadata *MD) {
998 return MD->getMetadataID() == DIBasicTypeKind ||
999 MD->getMetadataID() == DIFixedPointTypeKind;
1000 }
1001};
1002
1003/// Fixed-point type.
1004class DIFixedPointType : public DIBasicType {
1005 friend class LLVMContextImpl;
1006 friend class MDNode;
1007
1008 // Actually FixedPointKind.
1009 unsigned Kind;
1010 // Used for binary and decimal.
1011 int Factor;
1012 // Used for rational.
1013 APInt Numerator;
1014 APInt Denominator;
1015
1016 DIFixedPointType(LLVMContext &C, StorageType Storage, unsigned Tag,
1017 unsigned LineNo, uint32_t AlignInBits, unsigned Encoding,
1018 DIFlags Flags, unsigned Kind, int Factor,
1020 : DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, LineNo, AlignInBits,
1021 Encoding, 0, 0, Flags, Ops),
1022 Kind(Kind), Factor(Factor) {
1023 assert(Kind == FixedPointBinary || Kind == FixedPointDecimal);
1024 }
1026 unsigned LineNo, uint32_t AlignInBits, unsigned Encoding,
1027 DIFlags Flags, unsigned Kind, APInt Numerator,
1029 : DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, LineNo, AlignInBits,
1030 Encoding, 0, 0, Flags, Ops),
1031 Kind(Kind), Factor(0), Numerator(Numerator), Denominator(Denominator) {
1032 assert(Kind == FixedPointRational);
1033 }
1034 DIFixedPointType(LLVMContext &C, StorageType Storage, unsigned Tag,
1035 unsigned LineNo, uint32_t AlignInBits, unsigned Encoding,
1036 DIFlags Flags, unsigned Kind, int Factor, APInt Numerator,
1038 : DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, LineNo, AlignInBits,
1039 Encoding, 0, 0, Flags, Ops),
1040 Kind(Kind), Factor(Factor), Numerator(Numerator),
1042 ~DIFixedPointType() = default;
1043
1044 static DIFixedPointType *
1045 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
1047 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags, unsigned Kind,
1048 int Factor, APInt Numerator, APInt Denominator, StorageType Storage,
1049 bool ShouldCreate = true) {
1050 auto *SizeInBitsNode = ConstantAsMetadata::get(
1051 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1052 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1053 LineNo, Scope, SizeInBitsNode, AlignInBits, Encoding, Flags,
1054 Kind, Factor, Numerator, Denominator, Storage, ShouldCreate);
1055 }
1056 static DIFixedPointType *
1057 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
1058 unsigned LineNo, DIScope *Scope, Metadata *SizeInBits,
1059 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags, unsigned Kind,
1060 int Factor, APInt Numerator, APInt Denominator, StorageType Storage,
1061 bool ShouldCreate = true) {
1062 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1064 Kind, Factor, Numerator, Denominator, Storage, ShouldCreate);
1065 }
1066 static DIFixedPointType *
1067 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, DIFile *File,
1069 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags, unsigned Kind,
1070 int Factor, APInt Numerator, APInt Denominator, StorageType Storage,
1071 bool ShouldCreate = true) {
1072 auto *SizeInBitsNode = ConstantAsMetadata::get(
1073 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1074 return getImpl(Context, Tag, Name, File, LineNo, Scope, SizeInBitsNode,
1075 AlignInBits, Encoding, Flags, Kind, Factor, Numerator,
1076 Denominator, Storage, ShouldCreate);
1077 }
1078 LLVM_ABI static DIFixedPointType *
1079 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
1081 uint32_t AlignInBits, unsigned Encoding, DIFlags Flags, unsigned Kind,
1082 int Factor, APInt Numerator, APInt Denominator, StorageType Storage,
1083 bool ShouldCreate = true);
1084
1085 TempDIFixedPointType cloneImpl() const {
1088 getAlignInBits(), getEncoding(), getFlags(), Kind,
1089 Factor, Numerator, Denominator);
1090 }
1091
1092public:
1093 enum FixedPointKind : unsigned {
1094 /// Scale factor 2^Factor.
1096 /// Scale factor 10^Factor.
1098 /// Arbitrary rational scale factor.
1101 };
1102
1103 LLVM_ABI static std::optional<FixedPointKind>
1105 LLVM_ABI static const char *fixedPointKindString(FixedPointKind);
1106
1107 DEFINE_MDNODE_GET(DIFixedPointType,
1108 (unsigned Tag, MDString *Name, DIFile *File,
1111 unsigned Kind, int Factor, APInt Numerator,
1112 APInt Denominator),
1114 Encoding, Flags, Kind, Factor, Numerator, Denominator))
1115 DEFINE_MDNODE_GET(DIFixedPointType,
1119 unsigned Kind, int Factor, APInt Numerator,
1120 APInt Denominator),
1122 Encoding, Flags, Kind, Factor, Numerator, Denominator))
1123 DEFINE_MDNODE_GET(DIFixedPointType,
1124 (unsigned Tag, MDString *Name, Metadata *File,
1127 unsigned Kind, int Factor, APInt Numerator,
1128 APInt Denominator),
1130 Encoding, Flags, Kind, Factor, Numerator, Denominator))
1131
1132 TempDIFixedPointType clone() const { return cloneImpl(); }
1133
1134 bool isBinary() const { return Kind == FixedPointBinary; }
1135 bool isDecimal() const { return Kind == FixedPointDecimal; }
1136 bool isRational() const { return Kind == FixedPointRational; }
1137
1138 LLVM_ABI bool isSigned() const;
1139
1140 FixedPointKind getKind() const { return static_cast<FixedPointKind>(Kind); }
1141
1142 int getFactorRaw() const { return Factor; }
1143 int getFactor() const {
1144 assert(Kind == FixedPointBinary || Kind == FixedPointDecimal);
1145 return Factor;
1146 }
1147
1148 const APInt &getNumeratorRaw() const { return Numerator; }
1149 const APInt &getNumerator() const {
1150 assert(Kind == FixedPointRational);
1151 return Numerator;
1152 }
1153
1154 const APInt &getDenominatorRaw() const { return Denominator; }
1155 const APInt &getDenominator() const {
1156 assert(Kind == FixedPointRational);
1157 return Denominator;
1158 }
1159
1160 static bool classof(const Metadata *MD) {
1161 return MD->getMetadataID() == DIFixedPointTypeKind;
1162 }
1163};
1164
1165/// String type, Fortran CHARACTER(n)
1166class DIStringType : public DIType {
1167 friend class LLVMContextImpl;
1168 friend class MDNode;
1169
1170 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1171
1172 unsigned Encoding;
1173
1174 DIStringType(LLVMContext &C, StorageType Storage, unsigned Tag,
1175 uint32_t AlignInBits, unsigned Encoding,
1177 : DIType(C, DIStringTypeKind, Storage, Tag, 0, AlignInBits, 0, FlagZero,
1178 Ops),
1179 Encoding(Encoding) {}
1180 ~DIStringType() = default;
1181
1182 static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
1184 Metadata *StrLenExp, Metadata *StrLocationExp,
1186 unsigned Encoding, Metadata *CharType,
1187 StorageType Storage, bool ShouldCreate = true) {
1188 auto *SizeInBitsNode = ConstantAsMetadata::get(
1189 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1190 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
1191 StringLength, StrLenExp, StrLocationExp, SizeInBitsNode,
1192 AlignInBits, Encoding, CharType, Storage, ShouldCreate);
1193 }
1194 static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
1195 MDString *Name, Metadata *StringLength,
1196 Metadata *StrLenExp, Metadata *StrLocationExp,
1198 unsigned Encoding, Metadata *CharType,
1199 StorageType Storage, bool ShouldCreate = true) {
1200 auto *SizeInBitsNode = ConstantAsMetadata::get(
1201 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1202 return getImpl(Context, Tag, Name, StringLength, StrLenExp, StrLocationExp,
1203 SizeInBitsNode, AlignInBits, Encoding, CharType, Storage,
1204 ShouldCreate);
1205 }
1206 LLVM_ABI static DIStringType *
1207 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
1208 Metadata *StringLength, Metadata *StrLenExp, Metadata *StrLocationExp,
1209 Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1210 Metadata *CharType, StorageType Storage, bool ShouldCreate = true);
1211
1212 TempDIStringType cloneImpl() const {
1214 getRawStringLength(), getRawStringLengthExp(),
1215 getRawStringLocationExp(), getRawSizeInBits(),
1216 getAlignInBits(), getEncoding(), getRawCharType());
1217 }
1218
1219public:
1220 DEFINE_MDNODE_GET(DIStringType,
1221 (unsigned Tag, StringRef Name, uint64_t SizeInBits,
1223 (Tag, Name, nullptr, nullptr, nullptr, SizeInBits,
1224 AlignInBits, 0, nullptr))
1225 DEFINE_MDNODE_GET(DIStringType,
1229 unsigned Encoding, Metadata *CharType = nullptr),
1232 CharType))
1233 DEFINE_MDNODE_GET(DIStringType,
1234 (unsigned Tag, StringRef Name, Metadata *StringLength,
1237 unsigned Encoding, Metadata *CharType = nullptr),
1240 CharType))
1241 DEFINE_MDNODE_GET(DIStringType,
1242 (unsigned Tag, MDString *Name, Metadata *StringLength,
1245 unsigned Encoding, Metadata *CharType = nullptr),
1248 CharType))
1249
1250 TempDIStringType clone() const { return cloneImpl(); }
1251
1252 static bool classof(const Metadata *MD) {
1253 return MD->getMetadataID() == DIStringTypeKind;
1254 }
1255
1256 DIVariable *getStringLength() const {
1257 return cast_or_null<DIVariable>(getRawStringLength());
1258 }
1259
1260 DIExpression *getStringLengthExp() const {
1261 return cast_or_null<DIExpression>(getRawStringLengthExp());
1262 }
1263
1264 DIExpression *getStringLocationExp() const {
1265 return cast_or_null<DIExpression>(getRawStringLocationExp());
1266 }
1267
1268 unsigned getEncoding() const { return Encoding; }
1269
1270 DIType *getCharType() const { return cast_or_null<DIType>(getRawCharType()); }
1271
1272 Metadata *getRawStringLength() const { return getOperand(MY_FIRST_OPERAND); }
1273
1274 Metadata *getRawStringLengthExp() const {
1275 return getOperand(MY_FIRST_OPERAND + 1);
1276 }
1277
1278 Metadata *getRawStringLocationExp() const {
1279 return getOperand(MY_FIRST_OPERAND + 2);
1280 }
1281
1282 Metadata *getRawCharType() const { return getOperand(MY_FIRST_OPERAND + 3); }
1283};
1284
1285/// Derived types.
1286///
1287/// This includes qualified types, pointers, references, friends, typedefs, and
1288/// class members.
1289///
1290/// TODO: Split out members (inheritance, fields, methods, etc.).
1291class DIDerivedType : public DIType {
1292public:
1293 /// Pointer authentication (__ptrauth) metadata.
1295 // RawData layout:
1296 // - Bits 0..3: Key
1297 // - Bit 4: IsAddressDiscriminated
1298 // - Bits 5..20: ExtraDiscriminator
1299 // - Bit 21: IsaPointer
1300 // - Bit 22: AuthenticatesNullValues
1301 unsigned RawData;
1302
1303 PtrAuthData(unsigned FromRawData) : RawData(FromRawData) {}
1304 PtrAuthData(unsigned Key, bool IsDiscr, unsigned Discriminator,
1305 bool IsaPointer, bool AuthenticatesNullValues) {
1306 assert(Key < 16);
1307 assert(Discriminator <= 0xffff);
1308 RawData = (Key << 0) | (IsDiscr ? (1 << 4) : 0) | (Discriminator << 5) |
1309 (IsaPointer ? (1 << 21) : 0) |
1310 (AuthenticatesNullValues ? (1 << 22) : 0);
1311 }
1312
1313 unsigned key() { return (RawData >> 0) & 0b1111; }
1314 bool isAddressDiscriminated() { return (RawData >> 4) & 1; }
1315 unsigned extraDiscriminator() { return (RawData >> 5) & 0xffff; }
1316 bool isaPointer() { return (RawData >> 21) & 1; }
1317 bool authenticatesNullValues() { return (RawData >> 22) & 1; }
1318 };
1319
1320private:
1321 friend class LLVMContextImpl;
1322 friend class MDNode;
1323
1324 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1325
1326 /// The DWARF address space of the memory pointed to or referenced by a
1327 /// pointer or reference type respectively.
1328 std::optional<unsigned> DWARFAddressSpace;
1329
1330 DIDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
1331 unsigned Line, uint32_t AlignInBits,
1332 std::optional<unsigned> DWARFAddressSpace,
1333 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1335 : DIType(C, DIDerivedTypeKind, Storage, Tag, Line, AlignInBits, 0, Flags,
1336 Ops),
1337 DWARFAddressSpace(DWARFAddressSpace) {
1338 if (PtrAuthData)
1340 }
1341 ~DIDerivedType() = default;
1342 static DIDerivedType *
1343 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
1344 unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
1346 std::optional<unsigned> DWARFAddressSpace,
1347 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1349 bool ShouldCreate = true) {
1350 auto *SizeInBitsNode = ConstantAsMetadata::get(
1351 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1352 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1353 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1354 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1355 Line, Scope, BaseType, SizeInBitsNode, AlignInBits,
1356 OffsetInBitsNode, DWARFAddressSpace, PtrAuthData, Flags,
1357 ExtraData, Annotations.get(), Storage, ShouldCreate);
1358 }
1359 static DIDerivedType *
1360 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, DIFile *File,
1361 unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
1363 std::optional<unsigned> DWARFAddressSpace,
1364 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1366 bool ShouldCreate = true) {
1367 auto *SizeInBitsNode = ConstantAsMetadata::get(
1368 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1369 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1370 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1371 return getImpl(Context, Tag, Name, File, Line, Scope, BaseType,
1372 SizeInBitsNode, AlignInBits, OffsetInBitsNode,
1374 Annotations.get(), Storage, ShouldCreate);
1375 }
1376 static DIDerivedType *
1377 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
1380 std::optional<unsigned> DWARFAddressSpace,
1381 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1383 bool ShouldCreate = true) {
1384 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1386 DWARFAddressSpace, PtrAuthData, Flags, ExtraData,
1387 Annotations.get(), Storage, ShouldCreate);
1388 }
1389 LLVM_ABI static DIDerivedType *
1390 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
1391 unsigned Line, Metadata *Scope, Metadata *BaseType,
1393 std::optional<unsigned> DWARFAddressSpace,
1394 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1396 bool ShouldCreate = true);
1397
1398 TempDIDerivedType cloneImpl() const {
1399 return getTemporary(
1402 getRawOffsetInBits(), getDWARFAddressSpace(), getPtrAuthData(),
1404 }
1405
1406public:
1407 DEFINE_MDNODE_GET(DIDerivedType,
1408 (unsigned Tag, MDString *Name, Metadata *File,
1409 unsigned Line, Metadata *Scope, Metadata *BaseType,
1412 std::optional<unsigned> DWARFAddressSpace,
1413 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1414 Metadata *ExtraData = nullptr,
1415 Metadata *Annotations = nullptr),
1417 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1419 DEFINE_MDNODE_GET(DIDerivedType,
1420 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1423 std::optional<unsigned> DWARFAddressSpace,
1424 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1426 DINodeArray Annotations = nullptr),
1428 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1430 DEFINE_MDNODE_GET(DIDerivedType,
1431 (unsigned Tag, MDString *Name, DIFile *File, unsigned Line,
1434 std::optional<unsigned> DWARFAddressSpace,
1435 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1436 Metadata *ExtraData = nullptr,
1437 DINodeArray Annotations = nullptr),
1439 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1441 DEFINE_MDNODE_GET(DIDerivedType,
1442 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1445 std::optional<unsigned> DWARFAddressSpace,
1446 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,
1447 Metadata *ExtraData = nullptr,
1448 DINodeArray Annotations = nullptr),
1450 AlignInBits, OffsetInBits, DWARFAddressSpace, PtrAuthData,
1452
1453 TempDIDerivedType clone() const { return cloneImpl(); }
1454
1455 /// Get the base type this is derived from.
1456 DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
1457 Metadata *getRawBaseType() const { return getOperand(MY_FIRST_OPERAND); }
1458
1459 /// \returns The DWARF address space of the memory pointed to or referenced by
1460 /// a pointer or reference type respectively.
1461 std::optional<unsigned> getDWARFAddressSpace() const {
1462 return DWARFAddressSpace;
1463 }
1464
1465 LLVM_ABI std::optional<PtrAuthData> getPtrAuthData() const;
1466
1467 /// Get extra data associated with this derived type.
1468 ///
1469 /// Class type for pointer-to-members, objective-c property node for ivars,
1470 /// global constant wrapper for static members, virtual base pointer offset
1471 /// for inheritance, a tuple of template parameters for template aliases,
1472 /// discriminant for a variant, or storage offset for a bit field.
1473 ///
1474 /// TODO: Separate out types that need this extra operand: pointer-to-member
1475 /// types and member fields (static members and ivars).
1477 Metadata *getRawExtraData() const { return getOperand(MY_FIRST_OPERAND + 1); }
1478
1479 /// Get the template parameters from a template alias.
1480 DITemplateParameterArray getTemplateParams() const {
1482 }
1483
1484 /// Get annotations associated with this derived type.
1485 DINodeArray getAnnotations() const {
1487 }
1489 return getOperand(MY_FIRST_OPERAND + 2);
1490 }
1491
1492 /// Get casted version of extra data.
1493 /// @{
1494 LLVM_ABI DIType *getClassType() const;
1495
1499
1501
1503
1504 LLVM_ABI Constant *getConstant() const;
1505
1507 /// @}
1508
1509 static bool classof(const Metadata *MD) {
1510 return MD->getMetadataID() == DIDerivedTypeKind;
1511 }
1512};
1513
1516 return Lhs.RawData == Rhs.RawData;
1517}
1518
1521 return !(Lhs == Rhs);
1522}
1523
1524/// Subrange type. This is somewhat similar to DISubrange, but it
1525/// is also a DIType.
1526class DISubrangeType : public DIType {
1527public:
1529 DIDerivedType *>
1531
1532private:
1533 friend class LLVMContextImpl;
1534 friend class MDNode;
1535
1536 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1537
1538 DISubrangeType(LLVMContext &C, StorageType Storage, unsigned Line,
1540
1541 ~DISubrangeType() = default;
1542
1543 static DISubrangeType *
1544 getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
1548 StorageType Storage, bool ShouldCreate = true) {
1549 auto *SizeInBitsNode = ConstantAsMetadata::get(
1550 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1551 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
1552 Scope, SizeInBitsNode, AlignInBits, Flags, BaseType,
1553 LowerBound, UpperBound, Stride, Bias, Storage, ShouldCreate);
1554 }
1555
1556 LLVM_ABI static DISubrangeType *
1557 getImpl(LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
1559 DIFlags Flags, Metadata *BaseType, Metadata *LowerBound,
1561 StorageType Storage, bool ShouldCreate = true);
1562
1563 TempDISubrangeType cloneImpl() const {
1568 }
1569
1570 LLVM_ABI BoundType convertRawToBound(Metadata *IN) const;
1571
1572public:
1573 DEFINE_MDNODE_GET(DISubrangeType,
1574 (MDString * Name, Metadata *File, unsigned Line,
1581 DEFINE_MDNODE_GET(DISubrangeType,
1588
1589 TempDISubrangeType clone() const { return cloneImpl(); }
1590
1591 /// Get the base type this is derived from.
1593 Metadata *getRawBaseType() const { return getOperand(MY_FIRST_OPERAND); }
1594
1596 return getOperand(MY_FIRST_OPERAND + 1).get();
1597 }
1598
1600 return getOperand(MY_FIRST_OPERAND + 2).get();
1601 }
1602
1604 return getOperand(MY_FIRST_OPERAND + 3).get();
1605 }
1606
1608 return getOperand(MY_FIRST_OPERAND + 4).get();
1609 }
1610
1612 return convertRawToBound(getRawLowerBound());
1613 }
1614
1616 return convertRawToBound(getRawUpperBound());
1617 }
1618
1619 BoundType getStride() const { return convertRawToBound(getRawStride()); }
1620
1621 BoundType getBias() const { return convertRawToBound(getRawBias()); }
1622
1623 static bool classof(const Metadata *MD) {
1624 return MD->getMetadataID() == DISubrangeTypeKind;
1625 }
1626};
1627
1628/// Composite types.
1629///
1630/// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
1631/// TODO: Create a custom, unrelated node for DW_TAG_array_type.
1632class DICompositeType : public DIType {
1633 friend class LLVMContextImpl;
1634 friend class MDNode;
1635
1636 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1637
1638 unsigned RuntimeLang;
1639 std::optional<uint32_t> EnumKind;
1640
1641 DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
1642 unsigned Line, unsigned RuntimeLang, uint32_t AlignInBits,
1644 std::optional<uint32_t> EnumKind, DIFlags Flags,
1646 : DIType(C, DICompositeTypeKind, Storage, Tag, Line, AlignInBits,
1648 RuntimeLang(RuntimeLang), EnumKind(EnumKind) {}
1649 ~DICompositeType() = default;
1650
1651 /// Change fields in place.
1652 void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang,
1654 std::optional<uint32_t> EnumKind, DIFlags Flags) {
1655 assert(isDistinct() && "Only distinct nodes can mutate");
1656 assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate");
1657 this->RuntimeLang = RuntimeLang;
1658 this->EnumKind = EnumKind;
1660 }
1661
1662 static DICompositeType *
1663 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
1664 unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
1666 uint32_t NumExtraInhabitants, DIFlags Flags, DINodeArray Elements,
1667 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1668 DIType *VTableHolder, DITemplateParameterArray TemplateParams,
1669 StringRef Identifier, DIDerivedType *Discriminator,
1671 Metadata *Rank, DINodeArray Annotations, Metadata *BitStride,
1672 StorageType Storage, bool ShouldCreate = true) {
1673 auto *SizeInBitsNode = ConstantAsMetadata::get(
1674 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1675 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1676 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1677 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
1678 Line, Scope, BaseType, SizeInBitsNode, AlignInBits,
1679 OffsetInBitsNode, Flags, Elements.get(), RuntimeLang,
1681 getCanonicalMDString(Context, Identifier), Discriminator,
1684 ShouldCreate);
1685 }
1686 static DICompositeType *
1687 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
1688 unsigned Line, Metadata *Scope, Metadata *BaseType,
1690 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
1691 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1696 Metadata *BitStride, StorageType Storage, bool ShouldCreate = true) {
1697 auto *SizeInBitsNode = ConstantAsMetadata::get(
1698 ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
1699 auto *OffsetInBitsNode = ConstantAsMetadata::get(
1700 ConstantInt::get(Type::getInt64Ty(Context), OffsetInBits));
1701 return getImpl(Context, Tag, Name, File, Line, Scope, BaseType,
1702 SizeInBitsNode, AlignInBits, OffsetInBitsNode, Flags,
1703 Elements, RuntimeLang, EnumKind, VTableHolder,
1706 NumExtraInhabitants, BitStride, Storage, ShouldCreate);
1707 }
1708 static DICompositeType *
1709 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
1712 uint32_t NumExtraInhabitants, DIFlags Flags, DINodeArray Elements,
1713 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1714 DIType *VTableHolder, DITemplateParameterArray TemplateParams,
1715 StringRef Identifier, DIDerivedType *Discriminator,
1717 Metadata *Rank, DINodeArray Annotations, Metadata *BitStride,
1718 StorageType Storage, bool ShouldCreate = true) {
1719 return getImpl(
1720 Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
1722 RuntimeLang, EnumKind, VTableHolder, TemplateParams.get(),
1725 NumExtraInhabitants, BitStride, Storage, ShouldCreate);
1726 }
1727 LLVM_ABI static DICompositeType *
1728 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
1729 unsigned Line, Metadata *Scope, Metadata *BaseType,
1731 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
1732 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1737 Metadata *BitStride, StorageType Storage, bool ShouldCreate = true);
1738
1739 TempDICompositeType cloneImpl() const {
1740 return getTemporary(
1748 getRawBitStride());
1749 }
1750
1751public:
1753 DICompositeType,
1754 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1757 DINodeArray Elements, unsigned RuntimeLang,
1758 std::optional<uint32_t> EnumKind, DIType *VTableHolder,
1759 DITemplateParameterArray TemplateParams = nullptr,
1761 Metadata *DataLocation = nullptr, Metadata *Associated = nullptr,
1762 Metadata *Allocated = nullptr, Metadata *Rank = nullptr,
1763 DINodeArray Annotations = nullptr, DIType *Specification = nullptr,
1767 RuntimeLang, EnumKind, VTableHolder, TemplateParams, Identifier,
1769 BitStride))
1771 DICompositeType,
1772 (unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
1775 Metadata *Elements, unsigned RuntimeLang,
1776 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1779 Metadata *Associated = nullptr, Metadata *Allocated = nullptr,
1780 Metadata *Rank = nullptr, Metadata *Annotations = nullptr,
1782 Metadata *BitStride = nullptr),
1784 OffsetInBits, Flags, Elements, RuntimeLang, EnumKind, VTableHolder,
1787 BitStride))
1789 DICompositeType,
1790 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
1793 DINodeArray Elements, unsigned RuntimeLang,
1794 std::optional<uint32_t> EnumKind, DIType *VTableHolder,
1795 DITemplateParameterArray TemplateParams = nullptr,
1797 Metadata *DataLocation = nullptr, Metadata *Associated = nullptr,
1798 Metadata *Allocated = nullptr, Metadata *Rank = nullptr,
1799 DINodeArray Annotations = nullptr, DIType *Specification = nullptr,
1803 RuntimeLang, EnumKind, VTableHolder, TemplateParams, Identifier,
1805 BitStride))
1807 DICompositeType,
1808 (unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
1811 Metadata *Elements, unsigned RuntimeLang,
1812 std::optional<uint32_t> EnumKind, Metadata *VTableHolder,
1813 Metadata *TemplateParams = nullptr, MDString *Identifier = nullptr,
1814 Metadata *Discriminator = nullptr, Metadata *DataLocation = nullptr,
1815 Metadata *Associated = nullptr, Metadata *Allocated = nullptr,
1816 Metadata *Rank = nullptr, Metadata *Annotations = nullptr,
1818 Metadata *BitStride = nullptr),
1820 OffsetInBits, Flags, Elements, RuntimeLang, EnumKind, VTableHolder,
1823 BitStride))
1824
1825 TempDICompositeType clone() const { return cloneImpl(); }
1826
1827 /// Get a DICompositeType with the given ODR identifier.
1828 ///
1829 /// If \a LLVMContext::isODRUniquingDebugTypes(), gets the mapped
1830 /// DICompositeType for the given ODR \c Identifier. If none exists, creates
1831 /// a new node.
1832 ///
1833 /// Else, returns \c nullptr.
1834 LLVM_ABI static DICompositeType *
1835 getODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
1836 MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
1840 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1846 MDString &Identifier);
1847
1848 /// Build a DICompositeType with the given ODR identifier.
1849 ///
1850 /// Looks up the mapped DICompositeType for the given ODR \c Identifier. If
1851 /// it doesn't exist, creates a new one. If it does exist and \a
1852 /// isForwardDecl(), and the new arguments would be a definition, mutates the
1853 /// the type in place. In either case, returns the type.
1854 ///
1855 /// If not \a LLVMContext::isODRUniquingDebugTypes(), this function returns
1856 /// nullptr.
1857 LLVM_ABI static DICompositeType *
1858 buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
1859 MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
1863 unsigned RuntimeLang, std::optional<uint32_t> EnumKind,
1868
1870 DINodeArray getElements() const {
1872 }
1876 DITemplateParameterArray getTemplateParams() const {
1878 }
1880 return getStringOperand(MY_FIRST_OPERAND + 4);
1881 }
1882 unsigned getRuntimeLang() const { return RuntimeLang; }
1883 std::optional<uint32_t> getEnumKind() const { return EnumKind; }
1884
1885 Metadata *getRawBaseType() const { return getOperand(MY_FIRST_OPERAND); }
1886 Metadata *getRawElements() const { return getOperand(MY_FIRST_OPERAND + 1); }
1888 return getOperand(MY_FIRST_OPERAND + 2);
1889 }
1891 return getOperand(MY_FIRST_OPERAND + 3);
1892 }
1894 return getOperandAs<MDString>(MY_FIRST_OPERAND + 4);
1895 }
1897 return getOperand(MY_FIRST_OPERAND + 5);
1898 }
1900 return getOperandAs<DIDerivedType>(MY_FIRST_OPERAND + 5);
1901 }
1903 return getOperand(MY_FIRST_OPERAND + 6);
1904 }
1912 return getOperand(MY_FIRST_OPERAND + 7);
1913 }
1920 Metadata *getRawAllocated() const { return getOperand(MY_FIRST_OPERAND + 8); }
1927 Metadata *getRawRank() const { return getOperand(MY_FIRST_OPERAND + 9); }
1930 return dyn_cast_or_null<ConstantInt>(MD->getValue());
1931 return nullptr;
1932 }
1936
1938 return getOperand(MY_FIRST_OPERAND + 10);
1939 }
1940 DINodeArray getAnnotations() const {
1942 }
1943
1945 return getOperand(MY_FIRST_OPERAND + 11);
1946 }
1950
1951 bool isNameSimplified() const { return getFlags() & FlagNameIsSimplified; }
1952
1954 return getOperand(MY_FIRST_OPERAND + 12);
1955 }
1958 return dyn_cast_or_null<ConstantInt>(MD->getValue());
1959 return nullptr;
1960 }
1961
1962 /// Replace operands.
1963 ///
1964 /// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
1965 /// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
1966 /// of its movement if necessary.
1967 /// @{
1968 void replaceElements(DINodeArray Elements) {
1969#ifndef NDEBUG
1970 for (DINode *Op : getElements())
1971 assert(is_contained(Elements->operands(), Op) &&
1972 "Lost a member during member list replacement");
1973#endif
1974 replaceOperandWith(MY_FIRST_OPERAND + 1, Elements.get());
1975 }
1976
1978 replaceOperandWith(MY_FIRST_OPERAND + 2, VTableHolder);
1979 }
1980
1981 void replaceTemplateParams(DITemplateParameterArray TemplateParams) {
1982 replaceOperandWith(MY_FIRST_OPERAND + 3, TemplateParams.get());
1983 }
1984 /// @}
1985
1986 static bool classof(const Metadata *MD) {
1987 return MD->getMetadataID() == DICompositeTypeKind;
1988 }
1989};
1990
1991/// Type array for a subprogram.
1992///
1993/// TODO: Fold the array of types in directly as operands.
1994class DISubroutineType : public DIType {
1995 friend class LLVMContextImpl;
1996 friend class MDNode;
1997
1998 static constexpr unsigned MY_FIRST_OPERAND = DIType::N_OPERANDS;
1999
2000 /// The calling convention used with DW_AT_calling_convention. Actually of
2001 /// type dwarf::CallingConvention.
2002 uint8_t CC;
2003
2004 DISubroutineType(LLVMContext &C, StorageType Storage, DIFlags Flags,
2006 ~DISubroutineType() = default;
2007
2008 static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
2009 uint8_t CC, DITypeArray TypeArray,
2011 bool ShouldCreate = true) {
2012 return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate);
2013 }
2014 LLVM_ABI static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
2017 bool ShouldCreate = true);
2018
2019 TempDISubroutineType cloneImpl() const {
2021 }
2022
2023public:
2024 DEFINE_MDNODE_GET(DISubroutineType,
2025 (DIFlags Flags, uint8_t CC, DITypeArray TypeArray),
2026 (Flags, CC, TypeArray))
2027 DEFINE_MDNODE_GET(DISubroutineType,
2030
2031 TempDISubroutineType clone() const { return cloneImpl(); }
2032 // Returns a new temporary DISubroutineType with updated CC
2033 TempDISubroutineType cloneWithCC(uint8_t CC) const {
2034 auto NewTy = clone();
2035 NewTy->CC = CC;
2036 return NewTy;
2037 }
2038
2039 uint8_t getCC() const { return CC; }
2040
2041 DITypeArray getTypeArray() const {
2043 }
2044
2045 Metadata *getRawTypeArray() const { return getOperand(MY_FIRST_OPERAND); }
2046
2047 static bool classof(const Metadata *MD) {
2048 return MD->getMetadataID() == DISubroutineTypeKind;
2049 }
2050};
2051
2052/// Compile unit.
2053class DICompileUnit : public DIScope {
2054 friend class LLVMContextImpl;
2055 friend class MDNode;
2056
2057public:
2065
2073
2074 LLVM_ABI static std::optional<DebugEmissionKind>
2076 LLVM_ABI static const char *emissionKindString(DebugEmissionKind EK);
2077 LLVM_ABI static std::optional<DebugNameTableKind>
2079 LLVM_ABI static const char *nameTableKindString(DebugNameTableKind PK);
2080
2081private:
2082 DISourceLanguageName SourceLanguage;
2083 unsigned RuntimeVersion;
2085 unsigned EmissionKind;
2086 unsigned NameTableKind;
2087 bool IsOptimized;
2088 bool SplitDebugInlining;
2090 bool RangesBaseAddress;
2091
2093 DISourceLanguageName SourceLanguage, bool IsOptimized,
2094 unsigned RuntimeVersion, unsigned EmissionKind, uint64_t DWOId,
2096 unsigned NameTableKind, bool RangesBaseAddress,
2098 ~DICompileUnit() = default;
2099
2100 static DICompileUnit *
2101 getImpl(LLVMContext &Context, DISourceLanguageName SourceLanguage,
2104 unsigned EmissionKind, DICompositeTypeArray EnumTypes,
2105 DIScopeArray RetainedTypes,
2106 DIGlobalVariableExpressionArray GlobalVariables,
2107 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
2110 StringRef SDK, StorageType Storage, bool ShouldCreate = true) {
2111 return getImpl(
2112 Context, SourceLanguage, File, getCanonicalMDString(Context, Producer),
2115 EnumTypes.get(), RetainedTypes.get(), GlobalVariables.get(),
2118 getCanonicalMDString(Context, SysRoot),
2119 getCanonicalMDString(Context, SDK), Storage, ShouldCreate);
2120 }
2121 LLVM_ABI static DICompileUnit *
2122 getImpl(LLVMContext &Context, DISourceLanguageName SourceLanguage,
2123 Metadata *File, MDString *Producer, bool IsOptimized, MDString *Flags,
2124 unsigned RuntimeVersion, MDString *SplitDebugFilename,
2128 bool DebugInfoForProfiling, unsigned NameTableKind,
2129 bool RangesBaseAddress, MDString *SysRoot, MDString *SDK,
2130 StorageType Storage, bool ShouldCreate = true);
2131
2132 TempDICompileUnit cloneImpl() const {
2133 return getTemporary(
2140 }
2141
2142public:
2143 static void get() = delete;
2144 static void getIfExists() = delete;
2145
2147 DICompileUnit,
2149 bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
2151 DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes,
2152 DIGlobalVariableExpressionArray GlobalVariables,
2153 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
2154 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
2155 DebugNameTableKind NameTableKind, bool RangesBaseAddress,
2157 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
2159 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
2160 DebugInfoForProfiling, (unsigned)NameTableKind, RangesBaseAddress,
2161 SysRoot, SDK))
2163 DICompileUnit,
2165 bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
2169 bool SplitDebugInlining, bool DebugInfoForProfiling,
2170 unsigned NameTableKind, bool RangesBaseAddress, MDString *SysRoot,
2172 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
2174 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
2175 DebugInfoForProfiling, NameTableKind, RangesBaseAddress, SysRoot, SDK))
2176
2177 TempDICompileUnit clone() const { return cloneImpl(); }
2178
2179 DISourceLanguageName getSourceLanguage() const { return SourceLanguage; }
2180 bool isOptimized() const { return IsOptimized; }
2181 bool isDebugInfoForProfiling() const { return DebugInfoForProfiling; }
2182 unsigned getRuntimeVersion() const { return RuntimeVersion; }
2184 return (DebugEmissionKind)EmissionKind;
2185 }
2186 // Return true if this CU was compiled with debug info disabled
2187 bool isNoDebug() const { return EmissionKind == NoDebug; }
2189 return EmissionKind == DebugDirectivesOnly;
2190 }
2191 bool getDebugInfoForProfiling() const { return DebugInfoForProfiling; }
2193 return (DebugNameTableKind)NameTableKind;
2194 }
2195 bool getRangesBaseAddress() const { return RangesBaseAddress; }
2197 StringRef getFlags() const { return getStringOperand(2); }
2199 DICompositeTypeArray getEnumTypes() const {
2201 }
2202 DIScopeArray getRetainedTypes() const {
2204 }
2205 DIGlobalVariableExpressionArray getGlobalVariables() const {
2207 }
2208 DIImportedEntityArray getImportedEntities() const {
2210 }
2211 DIMacroNodeArray getMacros() const {
2213 }
2214 uint64_t getDWOId() const { return DWOId; }
2215 void setDWOId(uint64_t DwoId) { DWOId = DwoId; }
2216 bool getSplitDebugInlining() const { return SplitDebugInlining; }
2217 void setSplitDebugInlining(bool SplitDebugInlining) {
2218 this->SplitDebugInlining = SplitDebugInlining;
2219 }
2221 StringRef getSDK() const { return getStringOperand(10); }
2222 /// Target-specific language dialect for DWARF.
2223 uint16_t getDialect() const { return SourceLanguage.getDialect(); }
2224
2230 Metadata *getRawEnumTypes() const { return getOperand(4); }
2234 Metadata *getRawMacros() const { return getOperand(8); }
2237 /// Replace arrays.
2238 ///
2239 /// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
2240 /// deleted on a uniquing collision. In practice, uniquing collisions on \a
2241 /// DICompileUnit should be fairly rare.
2242 /// @{
2243 void replaceEnumTypes(DICompositeTypeArray N) {
2244 replaceOperandWith(4, N.get());
2245 }
2246 void replaceRetainedTypes(DITypeArray N) { replaceOperandWith(5, N.get()); }
2247 void replaceGlobalVariables(DIGlobalVariableExpressionArray N) {
2248 replaceOperandWith(6, N.get());
2249 }
2250 void replaceImportedEntities(DIImportedEntityArray N) {
2251 replaceOperandWith(7, N.get());
2252 }
2253 void replaceMacros(DIMacroNodeArray N) { replaceOperandWith(8, N.get()); }
2254 /// @}
2255
2256 static bool classof(const Metadata *MD) {
2257 return MD->getMetadataID() == DICompileUnitKind;
2258 }
2259};
2260
2261/// A scope for locals.
2262///
2263/// A legal scope for lexical blocks, local variables, and debug info
2264/// locations. Subclasses are \a DISubprogram, \a DILexicalBlock, and \a
2265/// DILexicalBlockFile.
2266class DILocalScope : public DIScope {
2267protected:
2270 : DIScope(C, ID, Storage, Tag, Ops) {}
2271 ~DILocalScope() = default;
2272
2273public:
2274 /// Get the subprogram for this scope.
2275 ///
2276 /// Return this if it's an \a DISubprogram; otherwise, look up the scope
2277 /// chain.
2279
2280 /// Traverses the scope chain rooted at RootScope until it hits a Subprogram,
2281 /// recreating the chain with "NewSP" instead.
2282 LLVM_ABI static DILocalScope *
2284 LLVMContext &Ctx,
2286
2287 /// Get the first non DILexicalBlockFile scope of this scope.
2288 ///
2289 /// Return this if it's not a \a DILexicalBlockFIle; otherwise, look up the
2290 /// scope chain.
2292
2293 static bool classof(const Metadata *MD) {
2294 return MD->getMetadataID() == DISubprogramKind ||
2295 MD->getMetadataID() == DILexicalBlockKind ||
2296 MD->getMetadataID() == DILexicalBlockFileKind;
2297 }
2298};
2299
2300/// Subprogram description. Uses SubclassData1.
2301class DISubprogram : public DILocalScope {
2302 friend class LLVMContextImpl;
2303 friend class MDNode;
2304
2305 unsigned Line;
2306 unsigned ScopeLine;
2307 unsigned VirtualIndex;
2308
2309 /// In the MS ABI, the implicit 'this' parameter is adjusted in the prologue
2310 /// of method overrides from secondary bases by this amount. It may be
2311 /// negative.
2312 int ThisAdjustment;
2313
2314public:
2315 /// Debug info subprogram flags.
2317#define HANDLE_DISP_FLAG(ID, NAME) SPFlag##NAME = ID,
2318#define DISP_FLAG_LARGEST_NEEDED
2319#include "llvm/IR/DebugInfoFlags.def"
2320 SPFlagNonvirtual = SPFlagZero,
2321 SPFlagVirtuality = SPFlagVirtual | SPFlagPureVirtual,
2322 LLVM_MARK_AS_BITMASK_ENUM(SPFlagLargest)
2323 };
2324
2325 LLVM_ABI static DISPFlags getFlag(StringRef Flag);
2326 LLVM_ABI static StringRef getFlagString(DISPFlags Flag);
2327
2328 /// Split up a flags bitfield for easier printing.
2329 ///
2330 /// Split \c Flags into \c SplitFlags, a vector of its components. Returns
2331 /// any remaining (unrecognized) bits.
2332 LLVM_ABI static DISPFlags splitFlags(DISPFlags Flags,
2333 SmallVectorImpl<DISPFlags> &SplitFlags);
2334
2335 // Helper for converting old bitfields to new flags word.
2336 LLVM_ABI static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition,
2337 bool IsOptimized,
2338 unsigned Virtuality = SPFlagNonvirtual,
2339 bool IsMainSubprogram = false);
2340
2341private:
2342 DIFlags Flags;
2343 DISPFlags SPFlags;
2344
2345 DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
2346 unsigned ScopeLine, unsigned VirtualIndex, int ThisAdjustment,
2347 DIFlags Flags, DISPFlags SPFlags, bool UsesKeyInstructions,
2349 ~DISubprogram() = default;
2350
2351 static DISubprogram *
2352 getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
2353 StringRef LinkageName, DIFile *File, unsigned Line,
2355 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
2356 DISPFlags SPFlags, DICompileUnit *Unit,
2357 DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
2358 MDNodeArray RetainedNodes, DITypeArray ThrownTypes,
2361 bool ShouldCreate = true) {
2362 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
2363 getCanonicalMDString(Context, LinkageName), File, Line, Type,
2365 Flags, SPFlags, Unit, TemplateParams.get(), Declaration,
2366 RetainedNodes.get(), ThrownTypes.get(), Annotations.get(),
2368 UsesKeyInstructions, Storage, ShouldCreate);
2369 }
2370
2371 LLVM_ABI static DISubprogram *
2372 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
2373 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
2374 unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
2375 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
2376 Metadata *TemplateParams, Metadata *Declaration,
2378 MDString *TargetFuncName, bool UsesKeyInstructions,
2379 StorageType Storage, bool ShouldCreate = true);
2380
2381 TempDISubprogram cloneImpl() const {
2383 getFile(), getLine(), getType(), getScopeLine(),
2384 getContainingType(), getVirtualIndex(),
2385 getThisAdjustment(), getFlags(), getSPFlags(),
2386 getUnit(), getTemplateParams(), getDeclaration(),
2387 getRetainedNodes(), getThrownTypes(), getAnnotations(),
2388 getTargetFuncName(), getKeyInstructionsEnabled());
2389 }
2390
2391public:
2393 DISubprogram,
2395 unsigned Line, DISubroutineType *Type, unsigned ScopeLine,
2396 DIType *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
2397 DIFlags Flags, DISPFlags SPFlags, DICompileUnit *Unit,
2398 DITemplateParameterArray TemplateParams = nullptr,
2399 DISubprogram *Declaration = nullptr, MDNodeArray RetainedNodes = nullptr,
2400 DITypeArray ThrownTypes = nullptr, DINodeArray Annotations = nullptr,
2401 StringRef TargetFuncName = "", bool UsesKeyInstructions = false),
2402 (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
2403 VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
2406
2408 DISubprogram,
2410 unsigned Line, Metadata *Type, unsigned ScopeLine,
2411 Metadata *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
2412 DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
2416 bool UsesKeyInstructions = false),
2417 (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
2418 VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
2421
2422 TempDISubprogram clone() const { return cloneImpl(); }
2423
2424 /// Returns a new temporary DISubprogram with updated Flags
2425 TempDISubprogram cloneWithFlags(DIFlags NewFlags) const {
2426 auto NewSP = clone();
2427 NewSP->Flags = NewFlags;
2428 return NewSP;
2429 }
2430
2431 bool getKeyInstructionsEnabled() const { return SubclassData1; }
2432
2433public:
2434 unsigned getLine() const { return Line; }
2435 unsigned getVirtuality() const { return getSPFlags() & SPFlagVirtuality; }
2436 unsigned getVirtualIndex() const { return VirtualIndex; }
2437 int getThisAdjustment() const { return ThisAdjustment; }
2438 unsigned getScopeLine() const { return ScopeLine; }
2439 void setScopeLine(unsigned L) {
2440 assert(isDistinct());
2441 ScopeLine = L;
2442 }
2443 DIFlags getFlags() const { return Flags; }
2444 DISPFlags getSPFlags() const { return SPFlags; }
2445 bool isLocalToUnit() const { return getSPFlags() & SPFlagLocalToUnit; }
2446 bool isDefinition() const { return getSPFlags() & SPFlagDefinition; }
2447 bool isOptimized() const { return getSPFlags() & SPFlagOptimized; }
2448 bool isMainSubprogram() const { return getSPFlags() & SPFlagMainSubprogram; }
2449
2450 bool isArtificial() const { return getFlags() & FlagArtificial; }
2451 bool isPrivate() const {
2452 return (getFlags() & FlagAccessibility) == FlagPrivate;
2453 }
2454 bool isProtected() const {
2455 return (getFlags() & FlagAccessibility) == FlagProtected;
2456 }
2457 bool isPublic() const {
2458 return (getFlags() & FlagAccessibility) == FlagPublic;
2459 }
2460 bool isExplicit() const { return getFlags() & FlagExplicit; }
2461 bool isPrototyped() const { return getFlags() & FlagPrototyped; }
2462 bool isNameSimplified() const { return getFlags() & FlagNameIsSimplified; }
2463 bool areAllCallsDescribed() const {
2464 return getFlags() & FlagAllCallsDescribed;
2465 }
2466 bool isPure() const { return getSPFlags() & SPFlagPure; }
2467 bool isElemental() const { return getSPFlags() & SPFlagElemental; }
2468 bool isRecursive() const { return getSPFlags() & SPFlagRecursive; }
2469 bool isObjCDirect() const { return getSPFlags() & SPFlagObjCDirect; }
2470
2471 /// Check if this is deleted member function.
2472 ///
2473 /// Return true if this subprogram is a C++11 special
2474 /// member function declared deleted.
2475 bool isDeleted() const { return getSPFlags() & SPFlagDeleted; }
2476
2477 /// Check if this is reference-qualified.
2478 ///
2479 /// Return true if this subprogram is a C++11 reference-qualified non-static
2480 /// member function (void foo() &).
2481 bool isLValueReference() const { return getFlags() & FlagLValueReference; }
2482
2483 /// Check if this is rvalue-reference-qualified.
2484 ///
2485 /// Return true if this subprogram is a C++11 rvalue-reference-qualified
2486 /// non-static member function (void foo() &&).
2487 bool isRValueReference() const { return getFlags() & FlagRValueReference; }
2488
2489 /// Check if this is marked as noreturn.
2490 ///
2491 /// Return true if this subprogram is C++11 noreturn or C11 _Noreturn
2492 bool isNoReturn() const { return getFlags() & FlagNoReturn; }
2493
2494 // Check if this routine is a compiler-generated thunk.
2495 //
2496 // Returns true if this subprogram is a thunk generated by the compiler.
2497 bool isThunk() const { return getFlags() & FlagThunk; }
2498
2499 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2500
2501 StringRef getName() const { return getStringOperand(2); }
2502 StringRef getLinkageName() const { return getStringOperand(3); }
2503 /// Only used by clients of CloneFunction, and only right after the cloning.
2504 void replaceLinkageName(MDString *LN) { replaceOperandWith(3, LN); }
2505
2506 DISubroutineType *getType() const {
2507 return cast_or_null<DISubroutineType>(getRawType());
2508 }
2509 DIType *getContainingType() const {
2510 return cast_or_null<DIType>(getRawContainingType());
2511 }
2512 void replaceType(DISubroutineType *Ty) {
2513 assert(isDistinct() && "Only distinct nodes can mutate");
2514 replaceOperandWith(4, Ty);
2515 }
2516
2517 DICompileUnit *getUnit() const {
2518 return cast_or_null<DICompileUnit>(getRawUnit());
2519 }
2520 void replaceUnit(DICompileUnit *CU) { replaceOperandWith(5, CU); }
2521 DITemplateParameterArray getTemplateParams() const {
2522 return cast_or_null<MDTuple>(getRawTemplateParams());
2523 }
2524 DISubprogram *getDeclaration() const {
2525 return cast_or_null<DISubprogram>(getRawDeclaration());
2526 }
2527 void replaceDeclaration(DISubprogram *Decl) { replaceOperandWith(6, Decl); }
2528 MDNodeArray getRetainedNodes() const {
2529 return cast_or_null<MDTuple>(getRawRetainedNodes());
2530 }
2531 DITypeArray getThrownTypes() const {
2532 return cast_or_null<MDTuple>(getRawThrownTypes());
2533 }
2534 DINodeArray getAnnotations() const {
2535 return cast_or_null<MDTuple>(getRawAnnotations());
2536 }
2537 StringRef getTargetFuncName() const {
2538 return (getRawTargetFuncName()) ? getStringOperand(12) : StringRef();
2539 }
2540
2541 Metadata *getRawScope() const { return getOperand(1); }
2542 MDString *getRawName() const { return getOperandAs<MDString>(2); }
2543 MDString *getRawLinkageName() const { return getOperandAs<MDString>(3); }
2544 Metadata *getRawType() const { return getOperand(4); }
2545 Metadata *getRawUnit() const { return getOperand(5); }
2546 Metadata *getRawDeclaration() const { return getOperand(6); }
2547 Metadata *getRawRetainedNodes() const { return getOperand(7); }
2548 Metadata *getRawContainingType() const {
2549 return getNumOperands() > 8 ? getOperandAs<Metadata>(8) : nullptr;
2550 }
2551 Metadata *getRawTemplateParams() const {
2552 return getNumOperands() > 9 ? getOperandAs<Metadata>(9) : nullptr;
2553 }
2554 Metadata *getRawThrownTypes() const {
2555 return getNumOperands() > 10 ? getOperandAs<Metadata>(10) : nullptr;
2556 }
2557 Metadata *getRawAnnotations() const {
2558 return getNumOperands() > 11 ? getOperandAs<Metadata>(11) : nullptr;
2559 }
2560 MDString *getRawTargetFuncName() const {
2561 return getNumOperands() > 12 ? getOperandAs<MDString>(12) : nullptr;
2562 }
2563
2564 void replaceRawLinkageName(MDString *LinkageName) {
2566 }
2567 void replaceRetainedNodes(MDNodeArray N) { replaceOperandWith(7, N.get()); }
2568
2569 template <typename IterT> void retainNodes(IterT NodesBegin, IterT NodesEnd) {
2570 auto RetainedNodes = getRetainedNodes();
2572 MDs.append(NodesBegin, NodesEnd);
2573 replaceRetainedNodes(MDNode::get(getContext(), MDs));
2574 }
2575
2576 /// For the given retained node of DISubprogram, applies one of the
2577 /// given functions depending on the type of the node.
2578 template <typename T, typename MetadataT, typename FuncLVT,
2579 typename FuncLabelT, typename FuncImportedEntityT,
2580 typename FuncTypeT, typename FuncGVET, typename FuncUnknownT>
2581 static T visitRetainedNode(MetadataT *N, FuncLVT &&FuncLV,
2582 FuncLabelT &&FuncLabel,
2583 FuncImportedEntityT &&FuncIE, FuncTypeT &&FuncType,
2584 FuncGVET &&FuncGVE, FuncUnknownT &&FuncUnknown) {
2585 static_assert(std::is_base_of_v<Metadata, MetadataT>,
2586 "N must point to Metadata or const Metadata");
2587
2588 if (auto *LV = dyn_cast<DILocalVariable>(N))
2589 return FuncLV(LV);
2590 if (auto *L = dyn_cast<DILabel>(N))
2591 return FuncLabel(L);
2592 if (auto *IE = dyn_cast<DIImportedEntity>(N))
2593 return FuncIE(IE);
2594 if (auto *Ty = dyn_cast<DIType>(N))
2595 return FuncType(Ty);
2596 if (auto *GVE = dyn_cast<DIGlobalVariableExpression>(N))
2597 return FuncGVE(GVE);
2598 return FuncUnknown(N);
2599 }
2600
2601 /// Returns the scope of subprogram's retainedNodes.
2602 LLVM_ABI static const DILocalScope *getRetainedNodeScope(const MDNode *N);
2604 // For use in Verifier.
2605 LLVM_ABI static const DIScope *getRawRetainedNodeScope(const MDNode *N);
2607
2608 /// For each retained node, applies one of the given functions depending
2609 /// on the type of a node.
2610 template <typename FuncLVT, typename FuncLabelT, typename FuncImportedEntityT,
2611 typename FuncTypeT, typename FuncGVET>
2612 void forEachRetainedNode(FuncLVT &&FuncLV, FuncLabelT &&FuncLabel,
2613 FuncImportedEntityT &&FuncIE, FuncTypeT &&FuncType,
2614 FuncGVET &&FuncGVE) {
2615 for (MDNode *N : getRetainedNodes())
2616 visitRetainedNode<void>(
2617 N, FuncLV, FuncLabel, FuncIE, FuncType, FuncGVE,
2618 [](auto *N) { llvm_unreachable("Unexpected retained node!"); });
2619 }
2620
2621 /// When IR modules are merged, typically during LTO, the merged module
2622 /// may contain several types having the same linkageName. They are
2623 /// supposed to represent the same type included by multiple source code
2624 /// files from a single header file.
2625 ///
2626 /// DebugTypeODRUniquing feature uniques (deduplicates) such types
2627 /// based on their linkageName during metadata loading, to speed up
2628 /// compilation and reduce debug info size.
2629 ///
2630 /// However, since function-local types are tracked in DISubprogram's
2631 /// retainedNodes field, a single local type may be referenced by multiple
2632 /// DISubprograms via retainedNodes as the result of DebugTypeODRUniquing.
2633 /// But retainedNodes field of a DISubprogram is meant to hold only
2634 /// subprogram's own local entities, therefore such references may
2635 /// cause crashes.
2636 ///
2637 /// To address this problem, this method is called for each new subprogram
2638 /// after module loading. It removes references to types belonging
2639 /// to other DISubprograms from a subprogram's retainedNodes list.
2640 /// If a corresponding IR function refers to local scopes from another
2641 /// subprogram, emitted debug info (e.g. DWARF) should rely
2642 /// on cross-subprogram references (and cross-CU references, as subprograms
2643 /// may belong to different compile units). This is also a drawback:
2644 /// when a subprogram refers to types that are local to another subprogram,
2645 /// it is more complicated for debugger to properly discover local types
2646 /// of a current scope for expression evaluation.
2648
2649 template <typename T> void cleanupRetainedNodesIf(T &&Pred) {
2650 MDTuple *RetainedNodes = dyn_cast_or_null<MDTuple>(getRawRetainedNodes());
2651 // As this is expected to be called during module loading, before
2652 // stripping old or incorrect debug info, perform minimal sanity check.
2653 if (!RetainedNodes)
2654 return;
2655 // replaceRetainedNodes() should not re-unique DISubprogram if new list is
2656 // the same pointer.
2657 replaceRetainedNodes(RetainedNodes->filter(Pred));
2658 }
2659
2660 /// Calls SP->cleanupRetainedNodes() for a range of DISubprograms.
2661 template <typename RangeT>
2662 static void cleanupRetainedNodes(const RangeT &NewDistinctSPs) {
2663 for (DISubprogram *SP : NewDistinctSPs)
2664 SP->cleanupRetainedNodes();
2665 }
2666
2667 /// Check if this subprogram describes the given function.
2668 ///
2669 /// FIXME: Should this be looking through bitcasts?
2670 LLVM_ABI bool describes(const Function *F) const;
2671
2672 static bool classof(const Metadata *MD) {
2673 return MD->getMetadataID() == DISubprogramKind;
2674 }
2675};
2676
2677/// A single intermediate-IR layer location.
2678///
2679/// One source coordinate in an intermediate IR level (e.g. MLIR) that
2680/// sits between the high-level source and the final LLVM IR. It has no scope
2681/// and references its \a DIFile directly. Grouped behind a \a DILayerLocList on
2682/// \a DILocation's optional `irlayers` operand.
2683///
2684/// Uses the SubclassData16 and SubclassData32 Metadata slots.
2685class DILayerLoc : public MDNode {
2686 friend class LLVMContextImpl;
2687 friend class MDNode;
2688
2689 DILayerLoc(LLVMContext &C, StorageType Storage, unsigned Line,
2690 unsigned Column, ArrayRef<Metadata *> Ops)
2691 : MDNode(C, DILayerLocKind, Storage, Ops) {
2692 assert(Ops.size() == 2 && "Expected {kind, file}");
2693 assert(Column < (1u << 16) && "Expected 16-bit column");
2694 SubclassData32 = Line;
2695 SubclassData16 = Column;
2696 }
2698
2699 LLVM_ABI static DILayerLoc *getImpl(LLVMContext &Context, MDString *Kind,
2700 Metadata *File, unsigned Line,
2701 unsigned Column, StorageType Storage,
2702 bool ShouldCreate = true);
2703
2704 TempDILayerLoc cloneImpl() const {
2706 getColumn());
2707 }
2708
2709public:
2711 (MDString * Kind, Metadata *File, unsigned Line,
2712 unsigned Column),
2713 (Kind, File, Line, Column))
2714
2715 TempDILayerLoc clone() const { return cloneImpl(); }
2716
2717 unsigned getLine() const { return SubclassData32; }
2718 unsigned getColumn() const { return SubclassData16; }
2719
2722 }
2724 if (MDString *K = getRawKind())
2725 return K->getString();
2726 return StringRef();
2727 }
2728 Metadata *getRawFile() const { return getOperand(1); }
2730
2731 static bool classof(const Metadata *MD) {
2732 return MD->getMetadataID() == DILayerLocKind;
2733 }
2734};
2735
2736/// A sequence of \a DILayerLoc entries.
2737class DILayerLocList : public MDNode {
2738 friend class LLVMContextImpl;
2739 friend class MDNode;
2740
2741 DILayerLocList(LLVMContext &C, StorageType Storage, unsigned Hash,
2743 : MDNode(C, DILayerLocListKind, Storage, Ops) {
2744 setHash(Hash);
2745 }
2747
2748 void setHash(unsigned Hash) { SubclassData32 = Hash; }
2749 void recalculateHash();
2750
2751 LLVM_ABI static DILayerLocList *getImpl(LLVMContext &Context,
2752 ArrayRef<Metadata *> Layers,
2754 bool ShouldCreate = true);
2755
2756 TempDILayerLocList cloneImpl() const {
2758 }
2759
2760public:
2761 /// Get the operand hash (used by the MDNodeOpsKey uniquing key).
2762 unsigned getHash() const { return SubclassData32; }
2763
2764 DEFINE_MDNODE_GET(DILayerLocList, (ArrayRef<Metadata *> Layers), (Layers))
2765
2766 TempDILayerLocList clone() const { return cloneImpl(); }
2767
2768 unsigned getNumLayers() const { return getNumOperands(); }
2769 DILayerLoc *getLayer(unsigned I) const {
2771 }
2774
2775 static bool classof(const Metadata *MD) {
2776 return MD->getMetadataID() == DILayerLocListKind;
2777 }
2778};
2779
2780/// Debug location.
2781///
2782/// A debug location in source code, used for debug info and otherwise.
2783///
2784/// Uses the SubclassData1, SubclassData16 and SubclassData32
2785/// Metadata slots.
2786
2787class DILocation : public MDNode {
2788 friend class LLVMContextImpl;
2789 friend class MDNode;
2790 uint64_t AtomGroup : 60;
2791 uint64_t AtomRank : 3;
2792 // Disambiguates the two optional trailing operands, layout
2793 // [scope, (inlinedAt?), (irlayers?)]: irlayers is always last when present.
2794 uint64_t HasIRLayers : 1;
2795
2796 DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
2797 unsigned Column, uint64_t AtomGroup, uint8_t AtomRank,
2798 bool HasIRLayers, ArrayRef<Metadata *> MDs, bool ImplicitCode);
2799 ~DILocation() { dropAllReferences(); }
2800
2801 LLVM_ABI static DILocation *getImpl(LLVMContext &Context, unsigned Line,
2802 unsigned Column, Metadata *Scope,
2806 bool ShouldCreate = true);
2807 static DILocation *getImpl(LLVMContext &Context, unsigned Line,
2808 unsigned Column, DILocalScope *Scope,
2812 bool ShouldCreate = true) {
2813 return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
2814 static_cast<Metadata *>(InlinedAt), ImplicitCode, AtomGroup,
2815 AtomRank, IRLayers, Storage, ShouldCreate);
2816 }
2817
2818 TempDILocation cloneImpl() const {
2819 // Get the raw scope/inlinedAt/irlayers since it is possible to invoke this
2820 // on a DILocation containing temporary metadata.
2821 return getTemporary(getContext(), getLine(), getColumn(), getRawScope(),
2822 getRawInlinedAt(), isImplicitCode(), getAtomGroup(),
2824 }
2825
2826public:
2827 uint64_t getAtomGroup() const { return AtomGroup; }
2828 uint8_t getAtomRank() const { return AtomRank; }
2829
2830 const DILocation *getWithoutAtom() const {
2831 if (!getAtomGroup() && !getAtomRank())
2832 return this;
2833 return get(getContext(), getLine(), getColumn(), getScope(), getInlinedAt(),
2834 isImplicitCode(), /*AtomGroup=*/0, /*AtomRank=*/0,
2835 getRawIRLayers());
2836 }
2837
2838 // Disallow replacing operands.
2839 void replaceOperandWith(unsigned I, Metadata *New) = delete;
2840
2842 (unsigned Line, unsigned Column, Metadata *Scope,
2843 Metadata *InlinedAt = nullptr, bool ImplicitCode = false,
2844 uint64_t AtomGroup = 0, uint8_t AtomRank = 0,
2845 Metadata *IRLayers = nullptr),
2846 (Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup,
2847 AtomRank, IRLayers))
2848 DEFINE_MDNODE_GET(DILocation,
2849 (unsigned Line, unsigned Column, DILocalScope *Scope,
2850 DILocation *InlinedAt = nullptr, bool ImplicitCode = false,
2851 uint64_t AtomGroup = 0, uint8_t AtomRank = 0,
2852 Metadata *IRLayers = nullptr),
2853 (Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup,
2854 AtomRank, IRLayers))
2855
2856 /// Return a (temporary) clone of this.
2857 TempDILocation clone() const { return cloneImpl(); }
2858
2859 unsigned getLine() const { return SubclassData32; }
2860 unsigned getColumn() const { return SubclassData16; }
2861 DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
2862
2863 /// Return the linkage name of Subprogram. If the linkage name is empty,
2864 /// return scope name (the demangled name).
2865 StringRef getSubprogramLinkageName() const {
2866 DISubprogram *SP = getScope()->getSubprogram();
2867 if (!SP)
2868 return "";
2869 auto Name = SP->getLinkageName();
2870 if (!Name.empty())
2871 return Name;
2872 return SP->getName();
2873 }
2874
2875 DILocation *getInlinedAt() const {
2877 }
2878
2879 /// Check if the location corresponds to an implicit code.
2880 /// When the ImplicitCode flag is true, it means that the Instruction
2881 /// with this DILocation has been added by the front-end but it hasn't been
2882 /// written explicitly by the user (e.g. cleanup stuff in C++ put on a closing
2883 /// bracket). It's useful for code coverage to not show a counter on "empty"
2884 /// lines.
2885 bool isImplicitCode() const { return SubclassData1; }
2886 void setImplicitCode(bool ImplicitCode) { SubclassData1 = ImplicitCode; }
2887
2888 DIFile *getFile() const { return getScope()->getFile(); }
2889 StringRef getFilename() const { return getScope()->getFilename(); }
2890 StringRef getDirectory() const { return getScope()->getDirectory(); }
2891 std::optional<StringRef> getSource() const { return getScope()->getSource(); }
2892
2893 /// Walk through \a getInlinedAt() and return the \a DILocation of the
2894 /// outermost call site in the inlining chain.
2895 const DILocation *getInlinedAtLocation() const {
2896 const DILocation *Current = this;
2897 while (const DILocation *Next = Current->getInlinedAt())
2898 Current = Next;
2899 return Current;
2900 }
2901
2902 // Return the \a DILocalScope of the outermost call site in the inlining
2903 // chain.
2904 DILocalScope *getInlinedAtScope() const {
2905 return getInlinedAtLocation()->getScope();
2906 }
2907
2908 /// Get the DWARF discriminator.
2909 ///
2910 /// DWARF discriminators distinguish identical file locations between
2911 /// instructions that are on different basic blocks.
2912 ///
2913 /// There are 3 components stored in discriminator, from lower bits:
2914 ///
2915 /// Base discriminator: assigned by AddDiscriminators pass to identify IRs
2916 /// that are defined by the same source line, but
2917 /// different basic blocks.
2918 /// Duplication factor: assigned by optimizations that will scale down
2919 /// the execution frequency of the original IR.
2920 /// Copy Identifier: assigned by optimizations that clones the IR.
2921 /// Each copy of the IR will be assigned an identifier.
2922 ///
2923 /// Encoding:
2924 ///
2925 /// The above 3 components are encoded into a 32bit unsigned integer in
2926 /// order. If the lowest bit is 1, the current component is empty, and the
2927 /// next component will start in the next bit. Otherwise, the current
2928 /// component is non-empty, and its content starts in the next bit. The
2929 /// value of each components is either 5 bit or 12 bit: if the 7th bit
2930 /// is 0, the bit 2~6 (5 bits) are used to represent the component; if the
2931 /// 7th bit is 1, the bit 2~6 (5 bits) and 8~14 (7 bits) are combined to
2932 /// represent the component. Thus, the number of bits used for a component
2933 /// is either 0 (if it and all the next components are empty); 1 - if it is
2934 /// empty; 7 - if its value is up to and including 0x1f (lsb and msb are both
2935 /// 0); or 14, if its value is up to and including 0x1ff. Note that the last
2936 /// component is also capped at 0x1ff, even in the case when both first
2937 /// components are 0, and we'd technically have 29 bits available.
2938 ///
2939 /// For precise control over the data being encoded in the discriminator,
2940 /// use encodeDiscriminator/decodeDiscriminator.
2941
2942 inline unsigned getDiscriminator() const;
2943
2944 // For the regular discriminator, it stands for all empty components if all
2945 // the lowest 3 bits are non-zero and all higher 29 bits are unused(zero by
2946 // default). Here we fully leverage the higher 29 bits for pseudo probe use.
2947 // This is the format:
2948 // [2:0] - 0x7
2949 // [31:3] - pseudo probe fields guaranteed to be non-zero as a whole
2950 // So if the lower 3 bits is non-zero and the others has at least one
2951 // non-zero bit, it guarantees to be a pseudo probe discriminator
2952 inline static bool isPseudoProbeDiscriminator(unsigned Discriminator) {
2953 return ((Discriminator & 0x7) == 0x7) && (Discriminator & 0xFFFFFFF8);
2954 }
2955
2956 /// Returns a new DILocation with updated \p Discriminator.
2957 inline const DILocation *cloneWithDiscriminator(unsigned Discriminator) const;
2958
2959 /// Returns a new DILocation with updated base discriminator \p BD. Only the
2960 /// base discriminator is set in the new DILocation, the other encoded values
2961 /// are elided.
2962 /// If the discriminator cannot be encoded, the function returns std::nullopt.
2963 inline std::optional<const DILocation *>
2964 cloneWithBaseDiscriminator(unsigned BD) const;
2965
2966 /// Returns the duplication factor stored in the discriminator, or 1 if no
2967 /// duplication factor (or 0) is encoded.
2968 inline unsigned getDuplicationFactor() const;
2969
2970 /// Returns the copy identifier stored in the discriminator.
2971 inline unsigned getCopyIdentifier() const;
2972
2973 /// Returns the base discriminator stored in the discriminator.
2974 inline unsigned getBaseDiscriminator() const;
2975
2976 /// Returns a new DILocation with duplication factor \p DF * current
2977 /// duplication factor encoded in the discriminator. The current duplication
2978 /// factor is as defined by getDuplicationFactor().
2979 /// Returns std::nullopt if encoding failed.
2980 inline std::optional<const DILocation *>
2982
2983 /// Attempts to merge \p LocA and \p LocB into a single location; see
2984 /// DebugLoc::getMergedLocation for more details.
2985 /// NB: When merging the locations of instructions, prefer to use
2986 /// DebugLoc::getMergedLocation(), as an instruction's DebugLoc may contain
2987 /// additional metadata that will not be preserved when merging the unwrapped
2988 /// DILocations.
2990 DILocation *LocB);
2991
2992 /// Try to combine the vector of locations passed as input in a single one.
2993 /// This function applies getMergedLocation() repeatedly left-to-right.
2994 /// NB: When merging the locations of instructions, prefer to use
2995 /// DebugLoc::getMergedLocations(), as an instruction's DebugLoc may contain
2996 /// additional metadata that will not be preserved when merging the unwrapped
2997 /// DILocations.
2998 ///
2999 /// \p Locs: The locations to be merged.
3001
3002 /// Return the masked discriminator value for an input discrimnator value D
3003 /// (i.e. zero out the (B+1)-th and above bits for D (B is 0-base).
3004 // Example: an input of (0x1FF, 7) returns 0xFF.
3005 static unsigned getMaskedDiscriminator(unsigned D, unsigned B) {
3006 return (D & getN1Bits(B));
3007 }
3008
3009 /// Return the bits used for base discriminators.
3010 static unsigned getBaseDiscriminatorBits() { return getBaseFSBitEnd(); }
3011
3012 /// Returns the base discriminator for a given encoded discriminator \p D.
3013 static unsigned
3015 bool IsFSDiscriminator = false) {
3016 // Extract the dwarf base discriminator if it's encoded in the pseudo probe
3017 // discriminator.
3019 auto DwarfBaseDiscriminator =
3021 if (DwarfBaseDiscriminator)
3022 return *DwarfBaseDiscriminator;
3023 // Return the probe id instead of zero for a pseudo probe discriminator.
3024 // This should help differenciate callsites with same line numbers to
3025 // achieve a decent AutoFDO profile under -fpseudo-probe-for-profiling,
3026 // where the original callsite dwarf discriminator is overwritten by
3027 // callsite probe information.
3029 }
3030
3031 if (IsFSDiscriminator)
3034 }
3035
3036 /// Raw encoding of the discriminator. APIs such as cloneWithDuplicationFactor
3037 /// have certain special case behavior (e.g. treating empty duplication factor
3038 /// as the value '1').
3039 /// This API, in conjunction with cloneWithDiscriminator, may be used to
3040 /// encode the raw values provided.
3041 ///
3042 /// \p BD: base discriminator
3043 /// \p DF: duplication factor
3044 /// \p CI: copy index
3045 ///
3046 /// The return is std::nullopt if the values cannot be encoded in 32 bits -
3047 /// for example, values for BD or DF larger than 12 bits. Otherwise, the
3048 /// return is the encoded value.
3049 LLVM_ABI static std::optional<unsigned>
3050 encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI);
3051
3052 /// Raw decoder for values in an encoded discriminator D.
3053 LLVM_ABI static void decodeDiscriminator(unsigned D, unsigned &BD,
3054 unsigned &DF, unsigned &CI);
3055
3056 /// Returns the duplication factor for a given encoded discriminator \p D, or
3057 /// 1 if no value or 0 is encoded.
3058 static unsigned getDuplicationFactorFromDiscriminator(unsigned D) {
3060 return 1;
3062 unsigned Ret = getUnsignedFromPrefixEncoding(D);
3063 if (Ret == 0)
3064 return 1;
3065 return Ret;
3066 }
3067
3068 /// Returns the copy identifier for a given encoded discriminator \p D.
3073
3074 Metadata *getRawScope() const { return getOperand(0); }
3076 // irlayers, when present, is always the last operand.
3077 if (getNumOperands() - HasIRLayers == 2)
3078 return getOperand(1);
3079 return nullptr;
3080 }
3081
3082 /// The optional intermediate-IR layer list (\a DILayerLocList), or null.
3083 /// Raw form: returns the operand without casting, so it is safe to call
3084 /// before forward-ref resolution (the operand may still be a placeholder).
3086 if (HasIRLayers)
3087 return getOperand(getNumOperands() - 1);
3088 return nullptr;
3089 }
3093 unsigned getNumLayers() const {
3095 return L ? L->getNumLayers() : 0;
3096 }
3097 DILayerLoc *getLayer(unsigned I) const {
3099 return L ? L->getLayer(I) : nullptr;
3100 }
3101
3102 static bool classof(const Metadata *MD) {
3103 return MD->getMetadataID() == DILocationKind;
3104 }
3105};
3106
3108protected:
3112
3113public:
3115
3116 Metadata *getRawScope() const { return getOperand(1); }
3117
3118 void replaceScope(DIScope *Scope) {
3119 assert(!isUniqued());
3120 setOperand(1, Scope);
3121 }
3122
3123 static bool classof(const Metadata *MD) {
3124 return MD->getMetadataID() == DILexicalBlockKind ||
3125 MD->getMetadataID() == DILexicalBlockFileKind;
3126 }
3127};
3128
3129/// Debug lexical block.
3130///
3131/// Uses the SubclassData32 Metadata slot.
3132class DILexicalBlock : public DILexicalBlockBase {
3133 friend class LLVMContextImpl;
3134 friend class MDNode;
3135
3136 uint16_t Column;
3137
3138 DILexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
3139 unsigned Column, ArrayRef<Metadata *> Ops)
3140 : DILexicalBlockBase(C, DILexicalBlockKind, Storage, Ops),
3141 Column(Column) {
3143 assert(Column < (1u << 16) && "Expected 16-bit column");
3144 }
3145 ~DILexicalBlock() = default;
3146
3147 static DILexicalBlock *getImpl(LLVMContext &Context, DILocalScope *Scope,
3148 DIFile *File, unsigned Line, unsigned Column,
3150 bool ShouldCreate = true) {
3151 return getImpl(Context, static_cast<Metadata *>(Scope),
3152 static_cast<Metadata *>(File), Line, Column, Storage,
3153 ShouldCreate);
3154 }
3155
3156 LLVM_ABI static DILexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
3157 Metadata *File, unsigned Line,
3158 unsigned Column, StorageType Storage,
3159 bool ShouldCreate = true);
3160
3161 TempDILexicalBlock cloneImpl() const {
3163 getColumn());
3164 }
3165
3166public:
3167 DEFINE_MDNODE_GET(DILexicalBlock,
3168 (DILocalScope * Scope, DIFile *File, unsigned Line,
3169 unsigned Column),
3170 (Scope, File, Line, Column))
3171 DEFINE_MDNODE_GET(DILexicalBlock,
3173 unsigned Column),
3174 (Scope, File, Line, Column))
3175
3176 TempDILexicalBlock clone() const { return cloneImpl(); }
3177
3178 unsigned getLine() const { return SubclassData32; }
3179 unsigned getColumn() const { return Column; }
3180
3181 static bool classof(const Metadata *MD) {
3182 return MD->getMetadataID() == DILexicalBlockKind;
3183 }
3184};
3185
3186class DILexicalBlockFile : public DILexicalBlockBase {
3187 friend class LLVMContextImpl;
3188 friend class MDNode;
3189
3190 DILexicalBlockFile(LLVMContext &C, StorageType Storage,
3192 : DILexicalBlockBase(C, DILexicalBlockFileKind, Storage, Ops) {
3194 }
3195 ~DILexicalBlockFile() = default;
3196
3197 static DILexicalBlockFile *getImpl(LLVMContext &Context, DILocalScope *Scope,
3198 DIFile *File, unsigned Discriminator,
3200 bool ShouldCreate = true) {
3201 return getImpl(Context, static_cast<Metadata *>(Scope),
3202 static_cast<Metadata *>(File), Discriminator, Storage,
3203 ShouldCreate);
3204 }
3205
3206 LLVM_ABI static DILexicalBlockFile *getImpl(LLVMContext &Context,
3207 Metadata *Scope, Metadata *File,
3208 unsigned Discriminator,
3210 bool ShouldCreate = true);
3211
3212 TempDILexicalBlockFile cloneImpl() const {
3213 return getTemporary(getContext(), getScope(), getFile(),
3215 }
3216
3217public:
3218 DEFINE_MDNODE_GET(DILexicalBlockFile,
3220 unsigned Discriminator),
3222 DEFINE_MDNODE_GET(DILexicalBlockFile,
3225
3226 TempDILexicalBlockFile clone() const { return cloneImpl(); }
3227 unsigned getDiscriminator() const { return SubclassData32; }
3228
3229 static bool classof(const Metadata *MD) {
3230 return MD->getMetadataID() == DILexicalBlockFileKind;
3231 }
3232};
3233
3234unsigned DILocation::getDiscriminator() const {
3236 return F->getDiscriminator();
3237 return 0;
3238}
3239
3240const DILocation *
3241DILocation::cloneWithDiscriminator(unsigned Discriminator) const {
3242 DIScope *Scope = getScope();
3243 // Skip all parent DILexicalBlockFile that already have a discriminator
3244 // assigned. We do not want to have nested DILexicalBlockFiles that have
3245 // multiple discriminators because only the leaf DILexicalBlockFile's
3246 // dominator will be used.
3247 for (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope);
3248 LBF && LBF->getDiscriminator() != 0;
3250 Scope = LBF->getScope();
3251 DILexicalBlockFile *NewScope =
3252 DILexicalBlockFile::get(getContext(), Scope, getFile(), Discriminator);
3253 return DILocation::get(getContext(), getLine(), getColumn(), NewScope,
3254 getInlinedAt(), isImplicitCode(), getAtomGroup(),
3256}
3257
3259 return getBaseDiscriminatorFromDiscriminator(getDiscriminator(),
3261}
3262
3264 return getDuplicationFactorFromDiscriminator(getDiscriminator());
3265}
3266
3268 return getCopyIdentifierFromDiscriminator(getDiscriminator());
3269}
3270
3271std::optional<const DILocation *>
3273 // Do not interfere with pseudo probes. Pseudo probe at a callsite uses
3274 // the dwarf discriminator to store pseudo probe related information,
3275 // such as the probe id.
3276 if (isPseudoProbeDiscriminator(getDiscriminator()))
3277 return this;
3278
3279 unsigned BD, DF, CI;
3280
3282 BD = getBaseDiscriminator();
3283 if (D == BD)
3284 return this;
3285 return cloneWithDiscriminator(D);
3286 }
3287
3288 decodeDiscriminator(getDiscriminator(), BD, DF, CI);
3289 if (D == BD)
3290 return this;
3291 if (std::optional<unsigned> Encoded = encodeDiscriminator(D, DF, CI))
3292 return cloneWithDiscriminator(*Encoded);
3293 return std::nullopt;
3294}
3295
3296std::optional<const DILocation *>
3298 assert(!EnableFSDiscriminator && "FSDiscriminator should not call this.");
3299 // Do no interfere with pseudo probes. Pseudo probe doesn't need duplication
3300 // factor support as samples collected on cloned probes will be aggregated.
3301 // Also pseudo probe at a callsite uses the dwarf discriminator to store
3302 // pseudo probe related information, such as the probe id.
3303 if (isPseudoProbeDiscriminator(getDiscriminator()))
3304 return this;
3305
3307 if (DF <= 1)
3308 return this;
3309
3310 unsigned BD = getBaseDiscriminator();
3311 unsigned CI = getCopyIdentifier();
3312 if (std::optional<unsigned> D = encodeDiscriminator(BD, DF, CI))
3313 return cloneWithDiscriminator(*D);
3314 return std::nullopt;
3315}
3316
3317/// Debug lexical block.
3318///
3319/// Uses the SubclassData1 Metadata slot.
3320class DINamespace : public DIScope {
3321 friend class LLVMContextImpl;
3322 friend class MDNode;
3323
3324 DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols,
3326 ~DINamespace() = default;
3327
3328 static DINamespace *getImpl(LLVMContext &Context, DIScope *Scope,
3330 StorageType Storage, bool ShouldCreate = true) {
3331 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
3332 ExportSymbols, Storage, ShouldCreate);
3333 }
3334 LLVM_ABI static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope,
3337 bool ShouldCreate = true);
3338
3339 TempDINamespace cloneImpl() const {
3340 return getTemporary(getContext(), getScope(), getName(),
3342 }
3343
3344public:
3348 DEFINE_MDNODE_GET(DINamespace,
3351
3352 TempDINamespace clone() const { return cloneImpl(); }
3353
3354 bool getExportSymbols() const { return SubclassData1; }
3356 StringRef getName() const { return getStringOperand(2); }
3357
3358 Metadata *getRawScope() const { return getOperand(1); }
3360
3361 static bool classof(const Metadata *MD) {
3362 return MD->getMetadataID() == DINamespaceKind;
3363 }
3364};
3365
3366/// Represents a module in the programming language, for example, a Clang
3367/// module, or a Fortran module.
3368///
3369/// Uses the SubclassData1 and SubclassData32 Metadata slots.
3370class DIModule : public DIScope {
3371 friend class LLVMContextImpl;
3372 friend class MDNode;
3373
3374 DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo,
3375 bool IsDecl, ArrayRef<Metadata *> Ops);
3376 ~DIModule() = default;
3377
3378 static DIModule *getImpl(LLVMContext &Context, DIFile *File, DIScope *Scope,
3381 unsigned LineNo, bool IsDecl, StorageType Storage,
3382 bool ShouldCreate = true) {
3383 return getImpl(Context, File, Scope, getCanonicalMDString(Context, Name),
3386 getCanonicalMDString(Context, APINotesFile), LineNo, IsDecl,
3387 Storage, ShouldCreate);
3388 }
3389 LLVM_ABI static DIModule *
3390 getImpl(LLVMContext &Context, Metadata *File, Metadata *Scope, MDString *Name,
3392 MDString *APINotesFile, unsigned LineNo, bool IsDecl,
3393 StorageType Storage, bool ShouldCreate = true);
3394
3395 TempDIModule cloneImpl() const {
3397 getConfigurationMacros(), getIncludePath(),
3398 getAPINotesFile(), getLineNo(), getIsDecl());
3399 }
3400
3401public:
3405 StringRef APINotesFile, unsigned LineNo,
3406 bool IsDecl = false),
3408 APINotesFile, LineNo, IsDecl))
3409 DEFINE_MDNODE_GET(DIModule,
3413 bool IsDecl = false),
3415 APINotesFile, LineNo, IsDecl))
3416
3417 TempDIModule clone() const { return cloneImpl(); }
3418
3419 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
3420 StringRef getName() const { return getStringOperand(2); }
3421 StringRef getConfigurationMacros() const { return getStringOperand(3); }
3422 StringRef getIncludePath() const { return getStringOperand(4); }
3423 StringRef getAPINotesFile() const { return getStringOperand(5); }
3424 unsigned getLineNo() const { return SubclassData32; }
3425 bool getIsDecl() const { return SubclassData1; }
3426
3427 Metadata *getRawScope() const { return getOperand(1); }
3428 MDString *getRawName() const { return getOperandAs<MDString>(2); }
3429 MDString *getRawConfigurationMacros() const {
3430 return getOperandAs<MDString>(3);
3431 }
3432 MDString *getRawIncludePath() const { return getOperandAs<MDString>(4); }
3433 MDString *getRawAPINotesFile() const { return getOperandAs<MDString>(5); }
3434
3435 static bool classof(const Metadata *MD) {
3436 return MD->getMetadataID() == DIModuleKind;
3437 }
3438};
3439
3440/// Base class for template parameters.
3441///
3442/// Uses the SubclassData1 Metadata slot.
3444protected:
3446 unsigned Tag, bool IsDefault, ArrayRef<Metadata *> Ops)
3447 : DINode(Context, ID, Storage, Tag, Ops) {
3448 SubclassData1 = IsDefault;
3449 }
3451
3452public:
3453 StringRef getName() const { return getStringOperand(0); }
3455
3457 Metadata *getRawType() const { return getOperand(1); }
3458 bool isDefault() const { return SubclassData1; }
3459
3460 static bool classof(const Metadata *MD) {
3461 return MD->getMetadataID() == DITemplateTypeParameterKind ||
3462 MD->getMetadataID() == DITemplateValueParameterKind;
3463 }
3464};
3465
3466class DITemplateTypeParameter : public DITemplateParameter {
3467 friend class LLVMContextImpl;
3468 friend class MDNode;
3469
3470 DITemplateTypeParameter(LLVMContext &Context, StorageType Storage,
3472 ~DITemplateTypeParameter() = default;
3473
3474 static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
3475 DIType *Type, bool IsDefault,
3477 bool ShouldCreate = true) {
3478 return getImpl(Context, getCanonicalMDString(Context, Name), Type,
3479 IsDefault, Storage, ShouldCreate);
3480 }
3482 getImpl(LLVMContext &Context, MDString *Name, Metadata *Type, bool IsDefault,
3483 StorageType Storage, bool ShouldCreate = true);
3484
3485 TempDITemplateTypeParameter cloneImpl() const {
3486 return getTemporary(getContext(), getName(), getType(), isDefault());
3487 }
3488
3489public:
3490 DEFINE_MDNODE_GET(DITemplateTypeParameter,
3492 (Name, Type, IsDefault))
3493 DEFINE_MDNODE_GET(DITemplateTypeParameter,
3496
3497 TempDITemplateTypeParameter clone() const { return cloneImpl(); }
3498
3499 static bool classof(const Metadata *MD) {
3500 return MD->getMetadataID() == DITemplateTypeParameterKind;
3501 }
3502};
3503
3504class DITemplateValueParameter : public DITemplateParameter {
3505 friend class LLVMContextImpl;
3506 friend class MDNode;
3507
3508 DITemplateValueParameter(LLVMContext &Context, StorageType Storage,
3509 unsigned Tag, bool IsDefault,
3511 : DITemplateParameter(Context, DITemplateValueParameterKind, Storage, Tag,
3512 IsDefault, Ops) {}
3513 ~DITemplateValueParameter() = default;
3514
3515 static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
3517 bool IsDefault, Metadata *Value,
3519 bool ShouldCreate = true) {
3520 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
3521 IsDefault, Value, Storage, ShouldCreate);
3522 }
3523 LLVM_ABI static DITemplateValueParameter *
3524 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
3525 bool IsDefault, Metadata *Value, StorageType Storage,
3526 bool ShouldCreate = true);
3527
3528 TempDITemplateValueParameter cloneImpl() const {
3529 return getTemporary(getContext(), getTag(), getName(), getType(),
3530 isDefault(), getValue());
3531 }
3532
3533public:
3534 DEFINE_MDNODE_GET(DITemplateValueParameter,
3535 (unsigned Tag, StringRef Name, DIType *Type, bool IsDefault,
3536 Metadata *Value),
3537 (Tag, Name, Type, IsDefault, Value))
3538 DEFINE_MDNODE_GET(DITemplateValueParameter,
3542
3543 TempDITemplateValueParameter clone() const { return cloneImpl(); }
3544
3545 Metadata *getValue() const { return getOperand(2); }
3546
3547 static bool classof(const Metadata *MD) {
3548 return MD->getMetadataID() == DITemplateValueParameterKind;
3549 }
3550};
3551
3552/// Base class for variables.
3553///
3554/// Uses the SubclassData32 Metadata slot.
3555class DIVariable : public DINode {
3556 unsigned Line;
3557
3558protected:
3560 signed Line, ArrayRef<Metadata *> Ops,
3561 uint32_t AlignInBits = 0);
3562 ~DIVariable() = default;
3563
3564public:
3565 unsigned getLine() const { return Line; }
3567 StringRef getName() const { return getStringOperand(1); }
3571 uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
3572 /// Determines the size of the variable's type.
3573 LLVM_ABI std::optional<uint64_t> getSizeInBits() const;
3574
3575 /// Return the signedness of this variable's type, or std::nullopt if this
3576 /// type is neither signed nor unsigned.
3577 std::optional<DIBasicType::Signedness> getSignedness() const {
3578 if (auto *BT = dyn_cast<DIBasicType>(getType()))
3579 return BT->getSignedness();
3580 return std::nullopt;
3581 }
3582
3584 if (auto *F = getFile())
3585 return F->getFilename();
3586 return "";
3587 }
3588
3590 if (auto *F = getFile())
3591 return F->getDirectory();
3592 return "";
3593 }
3594
3595 std::optional<StringRef> getSource() const {
3596 if (auto *F = getFile())
3597 return F->getSource();
3598 return std::nullopt;
3599 }
3600
3601 Metadata *getRawScope() const { return getOperand(0); }
3603 Metadata *getRawFile() const { return getOperand(2); }
3604 Metadata *getRawType() const { return getOperand(3); }
3605
3606 static bool classof(const Metadata *MD) {
3607 return MD->getMetadataID() == DILocalVariableKind ||
3608 MD->getMetadataID() == DIGlobalVariableKind;
3609 }
3610};
3611
3612/// DWARF expression.
3613///
3614/// This is (almost) a DWARF expression that modifies the location of a
3615/// variable, or the location of a single piece of a variable, or (when using
3616/// DW_OP_stack_value) is the constant variable value.
3617///
3618/// TODO: Co-allocate the expression elements.
3619/// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
3620/// storage types.
3621class DIExpression : public MDNode {
3622 friend class LLVMContextImpl;
3623 friend class MDNode;
3624
3625 std::vector<uint64_t> Elements;
3626
3627 DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
3628 : MDNode(C, DIExpressionKind, Storage, {}),
3629 Elements(Elements.begin(), Elements.end()) {}
3630 ~DIExpression() = default;
3631
3632 LLVM_ABI static DIExpression *getImpl(LLVMContext &Context,
3633 ArrayRef<uint64_t> Elements,
3635 bool ShouldCreate = true);
3636
3637 TempDIExpression cloneImpl() const {
3638 return getTemporary(getContext(), getElements());
3639 }
3640
3641public:
3642 DEFINE_MDNODE_GET(DIExpression, (ArrayRef<uint64_t> Elements), (Elements))
3643
3644 TempDIExpression clone() const { return cloneImpl(); }
3645
3646 ArrayRef<uint64_t> getElements() const { return Elements; }
3647
3648 unsigned getNumElements() const { return Elements.size(); }
3649
3650 uint64_t getElement(unsigned I) const {
3651 assert(I < Elements.size() && "Index out of range");
3652 return Elements[I];
3653 }
3654
3656 /// Determine whether this represents a constant value, if so
3657 // return it's sign information.
3658 LLVM_ABI std::optional<SignedOrUnsignedConstant> isConstant() const;
3659
3660 /// Return the value of a constant expression, as recognized by isConstant().
3661 /// This accounts for DW_OP_lit<n>, which encodes its value in the opcode.
3663
3664 /// Return true if \p Op is one of DW_OP_lit0 through DW_OP_lit31.
3665 LLVM_ABI static bool isLitOp(uint64_t Op);
3666
3667 /// Return the number of unique location operands referred to (via
3668 /// DW_OP_LLVM_arg) in this expression; this is not necessarily the number of
3669 /// instances of DW_OP_LLVM_arg within the expression.
3670 /// For example, for the expression:
3671 /// (DW_OP_LLVM_arg 0, DW_OP_LLVM_arg 1, DW_OP_plus,
3672 /// DW_OP_LLVM_arg 0, DW_OP_mul)
3673 /// This function would return 2, as there are two unique location operands
3674 /// (0 and 1).
3676
3678
3681
3682 /// A lightweight wrapper around an expression operand.
3683 ///
3684 /// TODO: Store arguments directly and change \a DIExpression to store a
3685 /// range of these.
3687 const uint64_t *Op = nullptr;
3688
3689 public:
3690 ExprOperand() = default;
3691 explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
3692
3693 explicit operator bool() const { return Op != nullptr; }
3694
3695 const uint64_t *get() const { return Op; }
3696
3697 /// Get the operand code.
3698 ///
3699 /// The operand has to be present.
3700 uint64_t getOp() const {
3701 assert(Op && "operand is not present");
3702 return *Op;
3703 }
3704
3705 /// Return true if this is \p Opcode.
3706 bool is(uint64_t Opcode) const { return getOp() == Opcode; }
3707
3708 /// Get an argument to the operand.
3709 ///
3710 /// Never returns the operand itself. The operand has to be present and \p I
3711 /// has to be less than getNumArgs().
3712 uint64_t getArg(unsigned I) const {
3713 assert(Op && "operand is not present");
3714 return Op[I + 1];
3715 }
3716
3717 unsigned getNumArgs() const { return getSize() - 1; }
3718
3719 /// Return the size of the operand.
3720 ///
3721 /// Return the number of elements in the operand (1 + args).
3722 LLVM_ABI unsigned getSize() const;
3723
3724 /// Return true if CodeGen handles this operand without adding bytes to the
3725 /// DWARF expression.
3726 LLVM_ABI bool isNonEmitting() const;
3727
3728 /// Append the elements of this operand to \p V.
3730 V.append(get(), get() + getSize());
3731 }
3732 };
3733
3734 // Typed views name an ExprOperand's arguments. Use cast<FragmentOp>(Op) for a
3735 // known opcode and dyn_cast<ArgOp>(Op) for a conditional match. A failed
3736 // dyn_cast returns an empty view, which tests false and holds no operand to
3737 // read, so check it before calling an accessor. Keep using ExprOperand for
3738 // operations without a typed view.
3739 //
3740 // A view takes an operand rather than an optional one. A cursor hands back
3741 // std::optional<ExprOperand>, so check it and then dereference it.
3742 // dyn_cast_if_present does not compile on std::optional<ExprOperand>, because
3743 // an operand is constructible from a null pointer, which leaves
3744 // ValueIsPresent ambiguous between its optional and its nullable
3745 // specialization.
3746
3747 /// A view of a DW_OP_LLVM_arg operation.
3748 class ArgOp : public ExprOperand {
3749 template <typename To, typename From, typename Enable>
3750 friend struct llvm::CastInfo;
3751
3752 explicit ArgOp(ExprOperand Op) : ExprOperand(Op) {}
3753
3754 public:
3755 /// Return the location operand index.
3756 uint64_t getIndex() const { return getArg(0); }
3757
3758 LLVM_ABI static bool classof(const ExprOperand *Op);
3759 };
3760
3761 /// A view of a DW_OP_LLVM_fragment operation.
3762 class FragmentOp : public ExprOperand {
3763 template <typename To, typename From, typename Enable>
3764 friend struct llvm::CastInfo;
3765
3766 explicit FragmentOp(ExprOperand Op) : ExprOperand(Op) {}
3767
3768 public:
3769 /// Return the fragment offset in bits.
3770 uint64_t getOffsetInBits() const { return getArg(0); }
3771
3772 /// Return the fragment size in bits.
3773 uint64_t getSizeInBits() const { return getArg(1); }
3774
3775 LLVM_ABI static bool classof(const ExprOperand *Op);
3776 };
3777
3778 /// A view of the DW_OP_LLVM_extract_bits_[sz]ext operations.
3779 class ExtractBitsOp : public ExprOperand {
3780 template <typename To, typename From, typename Enable>
3781 friend struct llvm::CastInfo;
3782
3783 explicit ExtractBitsOp(ExprOperand Op) : ExprOperand(Op) {}
3784
3785 public:
3786 /// Return the extract offset in bits.
3787 uint64_t getOffsetInBits() const { return getArg(0); }
3788
3789 /// Return the extract size in bits.
3790 uint64_t getSizeInBits() const { return getArg(1); }
3791
3792 /// Return whether the extracted value is sign-extended.
3793 LLVM_ABI bool isSigned() const;
3794
3795 LLVM_ABI static bool classof(const ExprOperand *Op);
3796 };
3797
3798 /// A view of a DW_OP_LLVM_convert operation.
3799 class ConvertOp : public ExprOperand {
3800 template <typename To, typename From, typename Enable>
3801 friend struct llvm::CastInfo;
3802
3803 explicit ConvertOp(ExprOperand Op) : ExprOperand(Op) {}
3804
3805 public:
3806 /// Return the destination size in bits.
3807 uint64_t getBitSize() const { return getArg(0); }
3808
3809 /// Return the raw destination type encoding.
3810 uint64_t getEncoding() const { return getArg(1); }
3811
3812 LLVM_ABI static bool classof(const ExprOperand *Op);
3813 };
3814
3815 /// A view of a DW_OP_LLVM_entry_value operation.
3816 class EntryValueOp : public ExprOperand {
3817 template <typename To, typename From, typename Enable>
3818 friend struct llvm::CastInfo;
3819
3820 explicit EntryValueOp(ExprOperand Op) : ExprOperand(Op) {}
3821
3822 public:
3823 /// Return the number of operations the entry value covers. The count
3824 /// includes the operation that precedes it, so the operations that follow
3825 /// are one fewer than this.
3826 uint64_t getNumOperations() const { return getArg(0); }
3827
3828 LLVM_ABI static bool classof(const ExprOperand *Op);
3829 };
3830
3831 /// A view of a DW_OP_LLVM_tag_offset operation.
3832 class TagOffsetOp : public ExprOperand {
3833 template <typename To, typename From, typename Enable>
3834 friend struct llvm::CastInfo;
3835
3836 explicit TagOffsetOp(ExprOperand Op) : ExprOperand(Op) {}
3837
3838 public:
3839 /// Return the offset a memory tag is derived from. How a target derives
3840 /// the tag from it is implementation defined.
3841 uint64_t getTagOffset() const { return getArg(0); }
3842
3843 LLVM_ABI static bool classof(const ExprOperand *Op);
3844 };
3845
3846 /// A view of a DW_OP_constu operation.
3847 class ConstuOp : public ExprOperand {
3848 template <typename To, typename From, typename Enable>
3849 friend struct llvm::CastInfo;
3850
3851 explicit ConstuOp(ExprOperand Op) : ExprOperand(Op) {}
3852
3853 public:
3854 /// Return the unsigned constant value.
3855 uint64_t getValue() const { return getArg(0); }
3856
3857 LLVM_ABI static bool classof(const ExprOperand *Op);
3858 };
3859
3860 /// A view of a DW_OP_plus_uconst operation.
3861 class PlusUconstOp : public ExprOperand {
3862 template <typename To, typename From, typename Enable>
3863 friend struct llvm::CastInfo;
3864
3865 explicit PlusUconstOp(ExprOperand Op) : ExprOperand(Op) {}
3866
3867 public:
3868 /// Return the unsigned offset.
3869 uint64_t getOffset() const { return getArg(0); }
3870
3871 LLVM_ABI static bool classof(const ExprOperand *Op);
3872 };
3873
3874 /// An iterator for expression operands.
3876 ExprOperand Op;
3877
3878 public:
3879 using iterator_category = std::input_iterator_tag;
3881 using difference_type = std::ptrdiff_t;
3884
3885 expr_op_iterator() = default;
3887
3888 element_iterator getBase() const { return Op.get(); }
3889 const ExprOperand &operator*() const { return Op; }
3890 const ExprOperand *operator->() const { return &Op; }
3891
3893 increment();
3894 return *this;
3895 }
3897 expr_op_iterator T(*this);
3898 increment();
3899 return T;
3900 }
3901
3902 /// Get the next iterator.
3903 ///
3904 /// \a std::next() doesn't work because this is technically an
3905 /// input_iterator, but it's a perfectly valid operation. This is an
3906 /// accessor to provide the same functionality.
3907 expr_op_iterator getNext() const { return ++expr_op_iterator(*this); }
3908
3909 bool operator==(const expr_op_iterator &X) const {
3910 return getBase() == X.getBase();
3911 }
3912 bool operator!=(const expr_op_iterator &X) const {
3913 return getBase() != X.getBase();
3914 }
3915
3916 private:
3917 void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
3918 };
3919
3920 /// Visit the elements via ExprOperand wrappers.
3921 ///
3922 /// These range iterators visit elements through \a ExprOperand wrappers.
3923 /// This is not guaranteed to be a valid range unless \a isValid() gives \c
3924 /// true.
3925 ///
3926 /// \pre \a isValid() gives \c true.
3927 /// @{
3937 /// @}
3938
3939 LLVM_ABI bool isValid() const;
3940
3941 static bool classof(const Metadata *MD) {
3942 return MD->getMetadataID() == DIExpressionKind;
3943 }
3944
3945 /// Return whether the first element a DW_OP_deref.
3946 LLVM_ABI bool startsWithDeref() const;
3947
3948 /// Return whether there is exactly one operator and it is a DW_OP_deref;
3949 LLVM_ABI bool isDeref() const;
3950
3952
3953 /// Return the number of bits that have an active value, i.e. those that
3954 /// aren't known to be zero/sign (depending on the type of Var) and which
3955 /// are within the size of this fragment (if it is one). If we can't deduce
3956 /// anything from the expression this will return the size of Var.
3957 LLVM_ABI std::optional<uint64_t> getActiveBits(DIVariable *Var);
3958
3959 /// Retrieve the details of this fragment expression.
3960 LLVM_ABI static std::optional<FragmentInfo>
3962
3963 /// Retrieve the details of this fragment expression.
3964 std::optional<FragmentInfo> getFragmentInfo() const {
3966 }
3967
3968 /// Return whether this is a piece of an aggregate variable.
3969 bool isFragment() const { return getFragmentInfo().has_value(); }
3970
3971 /// Return whether this is an implicit location description.
3972 LLVM_ABI bool isImplicit() const;
3973
3974 /// Return whether the location is computed on the expression stack, meaning
3975 /// it cannot be a simple register location.
3976 LLVM_ABI bool isComplex() const;
3977
3978 /// Return whether the evaluated expression makes use of a single location at
3979 /// the start of the expression, i.e. if it contains only a single
3980 /// DW_OP_LLVM_arg op as its first operand, or if it contains none.
3982
3983 /// Returns a reference to the elements contained in this expression, skipping
3984 /// past the leading `DW_OP_LLVM_arg, 0` if one is present.
3985 /// Similar to `convertToNonVariadicExpression`, but faster and cheaper - it
3986 /// does not check whether the expression is a single-location expression, and
3987 /// it returns elements rather than creating a new DIExpression.
3988 LLVM_ABI std::optional<ArrayRef<uint64_t>>
3990
3991 /// Removes all elements from \p Expr that do not apply to an undef debug
3992 /// value, which includes every operator that computes the value/location on
3993 /// the DWARF stack, including any DW_OP_LLVM_arg elements (making the result
3994 /// of this function always a single-location expression) while leaving
3995 /// everything that defines what the computed value applies to, i.e. the
3996 /// fragment information.
3997 LLVM_ABI static const DIExpression *
3999
4000 /// If \p Expr is a non-variadic expression (i.e. one that does not contain
4001 /// DW_OP_LLVM_arg), returns \p Expr converted to variadic form by adding a
4002 /// leading [DW_OP_LLVM_arg, 0] to the expression; otherwise returns \p Expr.
4003 LLVM_ABI static const DIExpression *
4005
4006 /// If \p Expr is a valid single-location expression, i.e. it refers to only a
4007 /// single debug operand at the start of the expression, then return that
4008 /// expression in a non-variadic form by removing DW_OP_LLVM_arg from the
4009 /// expression if it is present; otherwise returns std::nullopt.
4010 /// See also `getSingleLocationExpressionElements` above, which skips
4011 /// checking `isSingleLocationExpression` and returns a list of elements
4012 /// rather than a DIExpression.
4013 LLVM_ABI static std::optional<const DIExpression *>
4015
4016 /// Inserts the elements of \p Expr into \p Ops modified to a canonical form,
4017 /// which uses DW_OP_LLVM_arg (i.e. is a variadic expression) and folds the
4018 /// implied derefence from the \p IsIndirect flag into the expression. This
4019 /// allows us to check equivalence between expressions with differing
4020 /// directness or variadicness.
4022 const DIExpression *Expr,
4023 bool IsIndirect);
4024
4025 /// Determines whether two debug values should produce equivalent DWARF
4026 /// expressions, using their DIExpressions and directness, ignoring the
4027 /// differences between otherwise identical expressions in variadic and
4028 /// non-variadic form and not considering the debug operands.
4029 /// \p FirstExpr is the DIExpression for the first debug value.
4030 /// \p FirstIndirect should be true if the first debug value is indirect; in
4031 /// IR this should be true for dbg.declare intrinsics and false for
4032 /// dbg.values, and in MIR this should be true only for DBG_VALUE instructions
4033 /// whose second operand is an immediate value.
4034 /// \p SecondExpr and \p SecondIndirect have the same meaning as the prior
4035 /// arguments, but apply to the second debug value.
4036 LLVM_ABI static bool isEqualExpression(const DIExpression *FirstExpr,
4037 bool FirstIndirect,
4038 const DIExpression *SecondExpr,
4039 bool SecondIndirect);
4040
4041 /// Append \p Ops with operations to apply the \p Offset.
4043 int64_t Offset);
4044
4045 LLVM_ABI static bool
4046 extractLeadingOffset(ArrayRef<uint64_t> Ops, int64_t &OffsetInBytes,
4047 SmallVectorImpl<uint64_t> &RemainingOps);
4048
4049 /// If this is a constant offset, extract it. If there is no expression,
4050 /// return true with an offset of zero.
4051 LLVM_ABI bool extractIfOffset(int64_t &Offset) const;
4052
4053 /// Assuming that the expression operates on an address, extract a constant
4054 /// offset and the successive ops. Return false if the expression contains
4055 /// any incompatible ops (including non-zero DW_OP_LLVM_args - only a single
4056 /// address operand to the expression is permitted).
4057 ///
4058 /// We don't try very hard to interpret the expression because we assume that
4059 /// foldConstantMath has canonicalized the expression.
4060 LLVM_ABI bool
4061 extractLeadingOffset(int64_t &OffsetInBytes,
4062 SmallVectorImpl<uint64_t> &RemainingOps) const;
4063
4064 /// Returns true iff this DIExpression contains at least one instance of
4065 /// `DW_OP_LLVM_arg, n` for all n in [0, N).
4066 LLVM_ABI bool hasAllLocationOps(unsigned N) const;
4067
4068 /// Checks if the expression ends with <DWARF Address Space> DW_OP_swap
4069 /// DW_OP_xderef[_size], where the address space is pushed by DW_OP_constu or
4070 /// DW_OP_lit<n>, and extracts the <DWARF Address Space>. Returns the
4071 /// expression with that sequence removed (nullptr if nothing remains), or
4072 /// \p Expr unchanged if the sequence is not present.
4073 LLVM_ABI static const DIExpression *
4074 extractAddressClass(const DIExpression *Expr, unsigned &AddrClass);
4075
4076 /// Used for DIExpression::prepend.
4079 DerefBefore = 1 << 0,
4080 DerefAfter = 1 << 1,
4081 StackValue = 1 << 2,
4082 EntryValue = 1 << 3
4083 };
4084
4085 /// Prepend \p DIExpr with a deref and offset operation and optionally turn it
4086 /// into a stack value or/and an entry value.
4087 LLVM_ABI static DIExpression *prepend(const DIExpression *Expr, uint8_t Flags,
4088 int64_t Offset = 0);
4089
4090 /// Prepend \p DIExpr with the given opcodes and optionally turn it into a
4091 /// stack value.
4094 bool StackValue = false,
4095 bool EntryValue = false);
4096
4097 /// Append the opcodes \p Ops to \p DIExpr. Unlike \ref appendToStack, the
4098 /// returned expression is a stack value only if \p DIExpr is a stack value.
4099 /// If \p DIExpr describes a fragment, the returned expression will describe
4100 /// the same fragment.
4101 LLVM_ABI static DIExpression *append(const DIExpression *Expr,
4103
4104 /// Convert \p DIExpr into a stack value if it isn't one already by appending
4105 /// DW_OP_deref if needed, and appending \p Ops to the resulting expression.
4106 /// If \p DIExpr describes a fragment, the returned expression will describe
4107 /// the same fragment.
4108 LLVM_ABI static DIExpression *appendToStack(const DIExpression *Expr,
4110
4111 /// Create a copy of \p Expr by appending the given list of \p Ops to each
4112 /// instance of the operand `DW_OP_LLVM_arg, \p ArgNo`. This is used to
4113 /// modify a specific location used by \p Expr, such as when salvaging that
4114 /// location.
4117 unsigned ArgNo,
4118 bool StackValue = false);
4119
4120 /// Create a copy of \p Expr with each instance of
4121 /// `DW_OP_LLVM_arg, \p OldArg` replaced with `DW_OP_LLVM_arg, \p NewArg`,
4122 /// and each instance of `DW_OP_LLVM_arg, Arg` with `DW_OP_LLVM_arg, Arg - 1`
4123 /// for all Arg > \p OldArg.
4124 /// This is used when replacing one of the operands of a debug value list
4125 /// with another operand in the same list and deleting the old operand.
4126 LLVM_ABI static DIExpression *replaceArg(const DIExpression *Expr,
4127 uint64_t OldArg, uint64_t NewArg);
4128
4129 /// Create a DIExpression to describe one part of an aggregate variable that
4130 /// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation
4131 /// will be appended to the elements of \c Expr. If \c Expr already contains
4132 /// a \c DW_OP_LLVM_fragment \c OffsetInBits is interpreted as an offset
4133 /// into the existing fragment.
4134 ///
4135 /// \param OffsetInBits Offset of the piece in bits.
4136 /// \param SizeInBits Size of the piece in bits.
4137 /// \return Creating a fragment expression may fail if \c Expr
4138 /// contains arithmetic operations that would be
4139 /// truncated.
4140 LLVM_ABI static std::optional<DIExpression *>
4141 createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits,
4142 unsigned SizeInBits);
4143
4144 /// Determine the relative position of the fragments passed in.
4145 /// Returns -1 if this is entirely before Other, 0 if this and Other overlap,
4146 /// 1 if this is entirely after Other.
4147 static int fragmentCmp(const FragmentInfo &A, const FragmentInfo &B) {
4148 uint64_t l1 = A.OffsetInBits;
4149 uint64_t l2 = B.OffsetInBits;
4150 uint64_t r1 = l1 + A.SizeInBits;
4151 uint64_t r2 = l2 + B.SizeInBits;
4152 if (r1 <= l2)
4153 return -1;
4154 else if (r2 <= l1)
4155 return 1;
4156 else
4157 return 0;
4158 }
4159
4160 /// Computes a fragment, bit-extract operation if needed, and new constant
4161 /// offset to describe a part of a variable covered by some memory.
4162 ///
4163 /// The memory region starts at:
4164 /// \p SliceStart + \p SliceOffsetInBits
4165 /// And is size:
4166 /// \p SliceSizeInBits
4167 ///
4168 /// The location of the existing variable fragment \p VarFrag is:
4169 /// \p DbgPtr + \p DbgPtrOffsetInBits + \p DbgExtractOffsetInBits.
4170 ///
4171 /// It is intended that these arguments are derived from a debug record:
4172 /// - \p DbgPtr is the (single) DIExpression operand.
4173 /// - \p DbgPtrOffsetInBits is the constant offset applied to \p DbgPtr.
4174 /// - \p DbgExtractOffsetInBits is the offset from a
4175 /// DW_OP_LLVM_bit_extract_[sz]ext operation.
4176 ///
4177 /// Results and return value:
4178 /// - Return false if the result can't be calculated for any reason.
4179 /// - \p Result is set to nullopt if the intersect equals \p VarFrag.
4180 /// - \p Result contains a zero-sized fragment if there's no intersect.
4181 /// - \p OffsetFromLocationInBits is set to the difference between the first
4182 /// bit of the variable location and the first bit of the slice. The
4183 /// magnitude of a negative value therefore indicates the number of bits
4184 /// into the variable fragment that the memory region begins.
4185 ///
4186 /// We don't pass in a debug record directly to get the constituent parts
4187 /// and offsets because different debug records store the information in
4188 /// different places (dbg_assign has two DIExpressions - one contains the
4189 /// fragment info for the entire intrinsic).
4191 const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits,
4192 uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits,
4193 int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag,
4194 std::optional<DIExpression::FragmentInfo> &Result,
4195 int64_t &OffsetFromLocationInBits);
4196
4197 using ExtOps = std::array<uint64_t, 6>;
4198
4199 /// Returns the ops for a zero- or sign-extension in a DIExpression.
4200 LLVM_ABI static ExtOps getExtOps(unsigned FromSize, unsigned ToSize,
4201 bool Signed);
4202
4203 /// Append a zero- or sign-extension to \p Expr. Converts the expression to a
4204 /// stack value if it isn't one already.
4205 LLVM_ABI static DIExpression *appendExt(const DIExpression *Expr,
4206 unsigned FromSize, unsigned ToSize,
4207 bool Signed);
4208
4209 /// Check if fragments overlap between a pair of FragmentInfos.
4210 static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B) {
4211 return fragmentCmp(A, B) == 0;
4212 }
4213
4214 /// Determine the relative position of the fragments described by this
4215 /// DIExpression and \p Other. Calls static fragmentCmp implementation.
4216 int fragmentCmp(const DIExpression *Other) const {
4217 auto Fragment1 = *getFragmentInfo();
4218 auto Fragment2 = *Other->getFragmentInfo();
4219 return fragmentCmp(Fragment1, Fragment2);
4220 }
4221
4222 /// Check if fragments overlap between this DIExpression and \p Other.
4223 bool fragmentsOverlap(const DIExpression *Other) const {
4224 if (!isFragment() || !Other->isFragment())
4225 return true;
4226 return fragmentCmp(Other) == 0;
4227 }
4228
4229 /// Check if the expression consists of exactly one entry value operand.
4230 /// (This is the only configuration of entry values that is supported.)
4231 LLVM_ABI bool isEntryValue() const;
4232
4233 /// Try to shorten an expression with an initial constant operand.
4234 /// Returns a new expression and constant on success, or the original
4235 /// expression and constant on failure.
4236 LLVM_ABI std::pair<DIExpression *, const ConstantInt *>
4237 constantFold(const ConstantInt *CI);
4238
4239 /// Try to shorten an expression with constant math operations that can be
4240 /// evaluated at compile time. Returns a new expression on success, or the old
4241 /// expression if there is nothing to be reduced.
4243};
4244
4245template <typename To, typename From>
4247 To, From,
4248 std::enable_if_t<
4249 std::is_same_v<std::remove_const_t<From>, DIExpression::ExprOperand> &&
4250 !std::is_same_v<std::remove_const_t<To>, DIExpression::ExprOperand>>>
4251 : CastIsPossible<To, From>,
4252 DefaultDoCastIfPossible<To, From, CastInfo<To, From>> {
4253 static To doCast(const From &Op) { return To(Op); }
4254 static To castFailed() { return To(DIExpression::ExprOperand()); }
4255};
4256
4257/// Treat a default-constructed expression operand as absent.
4258template <> struct ValueIsPresent<DIExpression::ExprOperand> {
4260
4262 return bool(Op);
4263 }
4264
4268};
4269
4272 return std::tie(A.SizeInBits, A.OffsetInBits) ==
4273 std::tie(B.SizeInBits, B.OffsetInBits);
4274}
4275
4278 return std::tie(A.SizeInBits, A.OffsetInBits) <
4279 std::tie(B.SizeInBits, B.OffsetInBits);
4280}
4281
4282template <> struct DenseMapInfo<DIExpression::FragmentInfo> {
4284 static const uint64_t MaxVal = std::numeric_limits<uint64_t>::max();
4285
4286 static unsigned getHashValue(const FragInfo &Frag) {
4287 return (Frag.SizeInBits & 0xffff) << 16 | (Frag.OffsetInBits & 0xffff);
4288 }
4289
4290 static bool isEqual(const FragInfo &A, const FragInfo &B) { return A == B; }
4291};
4292
4293/// Holds a DIExpression and keeps track of how many operands have been consumed
4294/// so far.
4297
4298public:
4300 if (!Expr) {
4301 assert(Start == End);
4302 return;
4303 }
4304 Start = Expr->expr_op_begin();
4305 End = Expr->expr_op_end();
4306 }
4307
4309 : Start(Expr.begin()), End(Expr.end()) {}
4310
4312
4313 /// Consume one operation.
4314 std::optional<DIExpression::ExprOperand> take() {
4315 if (Start == End)
4316 return std::nullopt;
4317 return *(Start++);
4318 }
4319
4320 /// Consume N operations.
4321 void consume(unsigned N) { std::advance(Start, N); }
4322
4323 /// Return the current operation.
4324 std::optional<DIExpression::ExprOperand> peek() const {
4325 if (Start == End)
4326 return std::nullopt;
4327 return *(Start);
4328 }
4329
4330 /// Return the next operation.
4331 std::optional<DIExpression::ExprOperand> peekNext() const {
4332 if (Start == End)
4333 return std::nullopt;
4334
4335 auto Next = Start.getNext();
4336 if (Next == End)
4337 return std::nullopt;
4338
4339 return *Next;
4340 }
4341
4342 std::optional<DIExpression::ExprOperand> peekNextN(unsigned N) const {
4343 if (Start == End)
4344 return std::nullopt;
4346 for (unsigned I = 0; I < N; I++) {
4347 Nth = Nth.getNext();
4348 if (Nth == End)
4349 return std::nullopt;
4350 }
4351 return *Nth;
4352 }
4353
4355 this->Start = DIExpression::expr_op_iterator(Expr.begin());
4356 this->End = DIExpression::expr_op_iterator(Expr.end());
4357 }
4358
4359 /// Determine whether there are any operations left in this expression.
4360 operator bool() const { return Start != End; }
4361
4362 DIExpression::expr_op_iterator begin() const { return Start; }
4363 DIExpression::expr_op_iterator end() const { return End; }
4364
4365 /// Retrieve the fragment information, if any.
4366 std::optional<DIExpression::FragmentInfo> getFragmentInfo() const {
4367 return DIExpression::getFragmentInfo(Start, End);
4368 }
4369};
4370
4371/// Global variables.
4372///
4373/// TODO: Remove DisplayName. It's always equal to Name.
4374class DIGlobalVariable : public DIVariable {
4375 friend class LLVMContextImpl;
4376 friend class MDNode;
4377
4378 bool IsLocalToUnit;
4379 bool IsDefinition;
4380
4381 DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
4382 bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
4384 : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
4385 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
4386 ~DIGlobalVariable() = default;
4387
4388 static DIGlobalVariable *
4389 getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
4390 StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type,
4391 bool IsLocalToUnit, bool IsDefinition,
4394 bool ShouldCreate = true) {
4395 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
4396 getCanonicalMDString(Context, LinkageName), File, Line, Type,
4399 Annotations.get(), Storage, ShouldCreate);
4400 }
4401 LLVM_ABI static DIGlobalVariable *
4402 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
4403 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
4404 bool IsLocalToUnit, bool IsDefinition,
4407 bool ShouldCreate = true);
4408
4409 TempDIGlobalVariable cloneImpl() const {
4414 getAnnotations());
4415 }
4416
4417public:
4419 DIGlobalVariable,
4421 unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition,
4423 uint32_t AlignInBits, DINodeArray Annotations),
4424 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
4427 DIGlobalVariable,
4429 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
4432 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
4434
4435 TempDIGlobalVariable clone() const { return cloneImpl(); }
4436
4437 bool isLocalToUnit() const { return IsLocalToUnit; }
4438 bool isDefinition() const { return IsDefinition; }
4444 DINodeArray getAnnotations() const {
4446 }
4447
4452 Metadata *getRawAnnotations() const { return getOperand(8); }
4453
4454 static bool classof(const Metadata *MD) {
4455 return MD->getMetadataID() == DIGlobalVariableKind;
4456 }
4457};
4458
4459/// Debug common block.
4460///
4461/// Uses the SubclassData32 Metadata slot.
4462class DICommonBlock : public DIScope {
4463 friend class LLVMContextImpl;
4464 friend class MDNode;
4465
4466 DICommonBlock(LLVMContext &Context, StorageType Storage, unsigned LineNo,
4468
4469 static DICommonBlock *getImpl(LLVMContext &Context, DIScope *Scope,
4471 DIFile *File, unsigned LineNo,
4472 StorageType Storage, bool ShouldCreate = true) {
4473 return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name),
4474 File, LineNo, Storage, ShouldCreate);
4475 }
4476 LLVM_ABI static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope,
4478 Metadata *File, unsigned LineNo,
4480 bool ShouldCreate = true);
4481
4482 TempDICommonBlock cloneImpl() const {
4484 getFile(), getLineNo());
4485 }
4486
4487public:
4488 DEFINE_MDNODE_GET(DICommonBlock,
4490 DIFile *File, unsigned LineNo),
4491 (Scope, Decl, Name, File, LineNo))
4492 DEFINE_MDNODE_GET(DICommonBlock,
4494 Metadata *File, unsigned LineNo),
4496
4497 TempDICommonBlock clone() const { return cloneImpl(); }
4498
4503 StringRef getName() const { return getStringOperand(2); }
4505 unsigned getLineNo() const { return SubclassData32; }
4506
4507 Metadata *getRawScope() const { return getOperand(0); }
4508 Metadata *getRawDecl() const { return getOperand(1); }
4510 Metadata *getRawFile() const { return getOperand(3); }
4511
4512 static bool classof(const Metadata *MD) {
4513 return MD->getMetadataID() == DICommonBlockKind;
4514 }
4515};
4516
4517/// Local variable.
4518///
4519/// TODO: Split up flags.
4520class DILocalVariable : public DIVariable {
4521 friend class LLVMContextImpl;
4522 friend class MDNode;
4523
4524 unsigned Arg : 16;
4525 DIFlags Flags;
4526
4527 DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
4528 unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
4530 : DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
4531 Arg(Arg), Flags(Flags) {
4532 assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range");
4533 }
4534 ~DILocalVariable() = default;
4535
4536 static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
4537 StringRef Name, DIFile *File, unsigned Line,
4538 DIType *Type, unsigned Arg, DIFlags Flags,
4539 uint32_t AlignInBits, DINodeArray Annotations,
4541 bool ShouldCreate = true) {
4542 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
4543 Line, Type, Arg, Flags, AlignInBits, Annotations.get(),
4544 Storage, ShouldCreate);
4545 }
4546 LLVM_ABI static DILocalVariable *
4547 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File,
4548 unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags,
4550 bool ShouldCreate = true);
4551
4552 TempDILocalVariable cloneImpl() const {
4554 getLine(), getType(), getArg(), getFlags(),
4556 }
4557
4558public:
4559 DEFINE_MDNODE_GET(DILocalVariable,
4561 unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags,
4562 uint32_t AlignInBits, DINodeArray Annotations),
4563 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
4564 Annotations))
4565 DEFINE_MDNODE_GET(DILocalVariable,
4567 unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags,
4569 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
4570 Annotations))
4571
4572 TempDILocalVariable clone() const { return cloneImpl(); }
4573
4574 /// Get the local scope for this variable.
4575 ///
4576 /// Variables must be defined in a local scope.
4580
4581 bool isParameter() const { return Arg; }
4582 unsigned getArg() const { return Arg; }
4583 DIFlags getFlags() const { return Flags; }
4584
4585 DINodeArray getAnnotations() const {
4587 }
4588 Metadata *getRawAnnotations() const { return getOperand(4); }
4589
4590 bool isArtificial() const { return getFlags() & FlagArtificial; }
4591 bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
4592
4593 /// Check that a location is valid for this variable.
4594 ///
4595 /// Check that \c DL exists, is in the same subprogram, and has the same
4596 /// inlined-at location as \c this. (Otherwise, it's not a valid attachment
4597 /// to a \a DbgInfoIntrinsic.)
4599 return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
4600 }
4601
4602 static bool classof(const Metadata *MD) {
4603 return MD->getMetadataID() == DILocalVariableKind;
4604 }
4605};
4606
4607/// Label.
4608///
4609/// Uses the SubclassData32 Metadata slot.
4610class DILabel : public DINode {
4611 friend class LLVMContextImpl;
4612 friend class MDNode;
4613
4614 unsigned Column;
4615 std::optional<unsigned> CoroSuspendIdx;
4616 bool IsArtificial;
4617
4618 DILabel(LLVMContext &C, StorageType Storage, unsigned Line, unsigned Column,
4619 bool IsArtificial, std::optional<unsigned> CoroSuspendIdx,
4621 ~DILabel() = default;
4622
4623 static DILabel *getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
4624 DIFile *File, unsigned Line, unsigned Column,
4625 bool IsArtificial,
4626 std::optional<unsigned> CoroSuspendIdx,
4627 StorageType Storage, bool ShouldCreate = true) {
4628 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
4629 Line, Column, IsArtificial, CoroSuspendIdx, Storage,
4630 ShouldCreate);
4631 }
4632 LLVM_ABI static DILabel *
4633 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File,
4634 unsigned Line, unsigned Column, bool IsArtificial,
4635 std::optional<unsigned> CoroSuspendIdx, StorageType Storage,
4636 bool ShouldCreate = true);
4637
4638 TempDILabel cloneImpl() const {
4642 }
4643
4644public:
4647 unsigned Line, unsigned Column, bool IsArtificial,
4648 std::optional<unsigned> CoroSuspendIdx),
4649 (Scope, Name, File, Line, Column, IsArtificial,
4650 CoroSuspendIdx))
4651 DEFINE_MDNODE_GET(DILabel,
4653 unsigned Line, unsigned Column, bool IsArtificial,
4654 std::optional<unsigned> CoroSuspendIdx),
4655 (Scope, Name, File, Line, Column, IsArtificial,
4656 CoroSuspendIdx))
4657
4658 TempDILabel clone() const { return cloneImpl(); }
4659
4660 /// Get the local scope for this label.
4661 ///
4662 /// Labels must be defined in a local scope.
4666 unsigned getLine() const { return SubclassData32; }
4667 unsigned getColumn() const { return Column; }
4668 StringRef getName() const { return getStringOperand(1); }
4670 bool isArtificial() const { return IsArtificial; }
4671 std::optional<unsigned> getCoroSuspendIdx() const { return CoroSuspendIdx; }
4672
4673 Metadata *getRawScope() const { return getOperand(0); }
4675 Metadata *getRawFile() const { return getOperand(2); }
4676
4677 /// Check that a location is valid for this label.
4678 ///
4679 /// Check that \c DL exists, is in the same subprogram, and has the same
4680 /// inlined-at location as \c this. (Otherwise, it's not a valid attachment
4681 /// to a \a DbgInfoIntrinsic.)
4683 return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
4684 }
4685
4686 static bool classof(const Metadata *MD) {
4687 return MD->getMetadataID() == DILabelKind;
4688 }
4689};
4690
4691class DIObjCProperty : public DINode {
4692 friend class LLVMContextImpl;
4693 friend class MDNode;
4694
4695 unsigned Line;
4696 unsigned Attributes;
4697
4698 DIObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
4699 unsigned Attributes, ArrayRef<Metadata *> Ops);
4700 ~DIObjCProperty() = default;
4701
4702 static DIObjCProperty *
4703 getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
4704 StringRef GetterName, StringRef SetterName, unsigned Attributes,
4705 DIType *Type, StorageType Storage, bool ShouldCreate = true) {
4706 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
4708 getCanonicalMDString(Context, SetterName), Attributes, Type,
4709 Storage, ShouldCreate);
4710 }
4711 LLVM_ABI static DIObjCProperty *
4712 getImpl(LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
4713 MDString *GetterName, MDString *SetterName, unsigned Attributes,
4714 Metadata *Type, StorageType Storage, bool ShouldCreate = true);
4715
4716 TempDIObjCProperty cloneImpl() const {
4717 return getTemporary(getContext(), getName(), getFile(), getLine(),
4719 getType());
4720 }
4721
4722public:
4723 DEFINE_MDNODE_GET(DIObjCProperty,
4724 (StringRef Name, DIFile *File, unsigned Line,
4726 unsigned Attributes, DIType *Type),
4727 (Name, File, Line, GetterName, SetterName, Attributes,
4728 Type))
4729 DEFINE_MDNODE_GET(DIObjCProperty,
4730 (MDString * Name, Metadata *File, unsigned Line,
4732 unsigned Attributes, Metadata *Type),
4733 (Name, File, Line, GetterName, SetterName, Attributes,
4734 Type))
4735
4736 TempDIObjCProperty clone() const { return cloneImpl(); }
4737
4738 unsigned getLine() const { return Line; }
4739 unsigned getAttributes() const { return Attributes; }
4740 StringRef getName() const { return getStringOperand(0); }
4745
4747 if (auto *F = getFile())
4748 return F->getFilename();
4749 return "";
4750 }
4751
4753 if (auto *F = getFile())
4754 return F->getDirectory();
4755 return "";
4756 }
4757
4759 Metadata *getRawFile() const { return getOperand(1); }
4762 Metadata *getRawType() const { return getOperand(4); }
4763
4764 static bool classof(const Metadata *MD) {
4765 return MD->getMetadataID() == DIObjCPropertyKind;
4766 }
4767};
4768
4769/// A property of a class or structure.
4770///
4771/// An entity that is syntactically accessed like a data member, but whose
4772/// access is implemented by invoking a user-defined or compiler-generated
4773/// accessor.
4774///
4775/// Currently only the backing storage is modelled, and it must be a data
4776/// member holding the property's storage.
4777class DIProperty : public DINode {
4778 friend class LLVMContextImpl;
4779 friend class MDNode;
4780
4781 unsigned Line;
4782
4783 DIProperty(LLVMContext &C, StorageType Storage, unsigned Line,
4785 ~DIProperty() = default;
4786
4787 static DIProperty *getImpl(LLVMContext &Context, StringRef Name, DIFile *File,
4788 unsigned Line, DIType *Type,
4790 bool ShouldCreate = true) {
4791 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
4792 Type, BackingStorage, Storage, ShouldCreate);
4793 }
4794 LLVM_ABI static DIProperty *getImpl(LLVMContext &Context, MDString *Name,
4795 Metadata *File, unsigned Line,
4798 bool ShouldCreate = true);
4799
4800 TempDIProperty cloneImpl() const {
4801 return getTemporary(getContext(), getName(), getFile(), getLine(),
4803 }
4804
4805public:
4807 (StringRef Name, DIFile *File, unsigned Line, DIType *Type,
4809 (Name, File, Line, Type, BackingStorage))
4810 DEFINE_MDNODE_GET(DIProperty,
4811 (MDString * Name, Metadata *File, unsigned Line,
4814
4815 TempDIProperty clone() const { return cloneImpl(); }
4816
4817 unsigned getLine() const { return Line; }
4818 StringRef getName() const { return getStringOperand(0); }
4821
4822 /// The data member holding the property's backing storage, i.e. the target
4823 /// of \c DW_AT_property_forward on this property's
4824 /// \c DW_TAG_property_getter child.
4828
4830 if (auto *F = getFile())
4831 return F->getFilename();
4832 return "";
4833 }
4834
4836 if (auto *F = getFile())
4837 return F->getDirectory();
4838 return "";
4839 }
4840
4842 Metadata *getRawFile() const { return getOperand(1); }
4843 Metadata *getRawType() const { return getOperand(2); }
4845
4846 static bool classof(const Metadata *MD) {
4847 return MD->getMetadataID() == DIPropertyKind;
4848 }
4849};
4850
4851/// An imported module (C++ using directive or similar).
4852///
4853/// Uses the SubclassData32 Metadata slot.
4854class DIImportedEntity : public DINode {
4855 friend class LLVMContextImpl;
4856 friend class MDNode;
4857
4858 DIImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
4859 unsigned Line, ArrayRef<Metadata *> Ops)
4860 : DINode(C, DIImportedEntityKind, Storage, Tag, Ops) {
4862 }
4863 ~DIImportedEntity() = default;
4864
4865 static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
4866 DIScope *Scope, DINode *Entity, DIFile *File,
4867 unsigned Line, StringRef Name,
4868 DINodeArray Elements, StorageType Storage,
4869 bool ShouldCreate = true) {
4870 return getImpl(Context, Tag, Scope, Entity, File, Line,
4871 getCanonicalMDString(Context, Name), Elements.get(), Storage,
4872 ShouldCreate);
4873 }
4874 LLVM_ABI static DIImportedEntity *
4875 getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, Metadata *Entity,
4876 Metadata *File, unsigned Line, MDString *Name, Metadata *Elements,
4877 StorageType Storage, bool ShouldCreate = true);
4878
4879 TempDIImportedEntity cloneImpl() const {
4880 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
4881 getFile(), getLine(), getName(), getElements());
4882 }
4883
4884public:
4885 DEFINE_MDNODE_GET(DIImportedEntity,
4886 (unsigned Tag, DIScope *Scope, DINode *Entity, DIFile *File,
4887 unsigned Line, StringRef Name = "",
4888 DINodeArray Elements = nullptr),
4889 (Tag, Scope, Entity, File, Line, Name, Elements))
4890 DEFINE_MDNODE_GET(DIImportedEntity,
4893 Metadata *Elements = nullptr),
4894 (Tag, Scope, Entity, File, Line, Name, Elements))
4895
4896 TempDIImportedEntity clone() const { return cloneImpl(); }
4897
4898 unsigned getLine() const { return SubclassData32; }
4899 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
4900 DINode *getEntity() const { return cast_or_null<DINode>(getRawEntity()); }
4901 StringRef getName() const { return getStringOperand(2); }
4902 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
4903 DINodeArray getElements() const {
4904 return cast_or_null<MDTuple>(getRawElements());
4905 }
4906
4907 Metadata *getRawScope() const { return getOperand(0); }
4908 Metadata *getRawEntity() const { return getOperand(1); }
4909 MDString *getRawName() const { return getOperandAs<MDString>(2); }
4910 Metadata *getRawFile() const { return getOperand(3); }
4911 Metadata *getRawElements() const { return getOperand(4); }
4912
4913 static bool classof(const Metadata *MD) {
4914 return MD->getMetadataID() == DIImportedEntityKind;
4915 }
4916};
4917
4918/// A pair of DIGlobalVariable and DIExpression.
4919class DIGlobalVariableExpression : public MDNode {
4920 friend class LLVMContextImpl;
4921 friend class MDNode;
4922
4923 DIGlobalVariableExpression(LLVMContext &C, StorageType Storage,
4925 : MDNode(C, DIGlobalVariableExpressionKind, Storage, Ops) {}
4926 ~DIGlobalVariableExpression() = default;
4927
4929 getImpl(LLVMContext &Context, Metadata *Variable, Metadata *Expression,
4930 StorageType Storage, bool ShouldCreate = true);
4931
4932 TempDIGlobalVariableExpression cloneImpl() const {
4934 }
4935
4936public:
4937 DEFINE_MDNODE_GET(DIGlobalVariableExpression,
4938 (Metadata * Variable, Metadata *Expression),
4939 (Variable, Expression))
4940
4941 TempDIGlobalVariableExpression clone() const { return cloneImpl(); }
4942
4943 Metadata *getRawVariable() const { return getOperand(0); }
4944
4948
4949 Metadata *getRawExpression() const { return getOperand(1); }
4950
4954
4955 static bool classof(const Metadata *MD) {
4956 return MD->getMetadataID() == DIGlobalVariableExpressionKind;
4957 }
4958};
4959
4960/// Macro Info DWARF-like metadata node.
4961///
4962/// A metadata node with a DWARF macro info (i.e., a constant named
4963/// \c DW_MACINFO_*, defined in llvm/BinaryFormat/Dwarf.h). Called \a
4964/// DIMacroNode
4965/// because it's potentially used for non-DWARF output.
4966///
4967/// Uses the SubclassData16 Metadata slot.
4968class DIMacroNode : public MDNode {
4969 friend class LLVMContextImpl;
4970 friend class MDNode;
4971
4972protected:
4973 DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType,
4975 : MDNode(C, ID, Storage, Ops1, Ops2) {
4976 assert(MIType < 1u << 16);
4977 SubclassData16 = MIType;
4978 }
4979 ~DIMacroNode() = default;
4980
4981 template <class Ty> Ty *getOperandAs(unsigned I) const {
4982 return cast_or_null<Ty>(getOperand(I));
4983 }
4984
4985 StringRef getStringOperand(unsigned I) const {
4986 if (auto *S = getOperandAs<MDString>(I))
4987 return S->getString();
4988 return StringRef();
4989 }
4990
4992 if (S.empty())
4993 return nullptr;
4994 return MDString::get(Context, S);
4995 }
4996
4997public:
4998 unsigned getMacinfoType() const { return SubclassData16; }
4999
5000 static bool classof(const Metadata *MD) {
5001 switch (MD->getMetadataID()) {
5002 default:
5003 return false;
5004 case DIMacroKind:
5005 case DIMacroFileKind:
5006 return true;
5007 }
5008 }
5009};
5010
5011/// Macro
5012///
5013/// Uses the SubclassData32 Metadata slot.
5014class DIMacro : public DIMacroNode {
5015 friend class LLVMContextImpl;
5016 friend class MDNode;
5017
5018 DIMacro(LLVMContext &C, StorageType Storage, unsigned MIType, unsigned Line,
5020 : DIMacroNode(C, DIMacroKind, Storage, MIType, Ops) {
5022 }
5023 ~DIMacro() = default;
5024
5025 static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
5027 bool ShouldCreate = true) {
5028 return getImpl(Context, MIType, Line, getCanonicalMDString(Context, Name),
5029 getCanonicalMDString(Context, Value), Storage, ShouldCreate);
5030 }
5031 LLVM_ABI static DIMacro *getImpl(LLVMContext &Context, unsigned MIType,
5032 unsigned Line, MDString *Name,
5033 MDString *Value, StorageType Storage,
5034 bool ShouldCreate = true);
5035
5036 TempDIMacro cloneImpl() const {
5038 getValue());
5039 }
5040
5041public:
5043 (unsigned MIType, unsigned Line, StringRef Name,
5044 StringRef Value = ""),
5045 (MIType, Line, Name, Value))
5046 DEFINE_MDNODE_GET(DIMacro,
5047 (unsigned MIType, unsigned Line, MDString *Name,
5050
5051 TempDIMacro clone() const { return cloneImpl(); }
5052
5053 unsigned getLine() const { return SubclassData32; }
5054
5055 StringRef getName() const { return getStringOperand(0); }
5056 StringRef getValue() const { return getStringOperand(1); }
5057
5060
5061 static bool classof(const Metadata *MD) {
5062 return MD->getMetadataID() == DIMacroKind;
5063 }
5064};
5065
5066/// Macro file
5067///
5068/// Uses the SubclassData32 Metadata slot.
5069class DIMacroFile : public DIMacroNode {
5070 friend class LLVMContextImpl;
5071 friend class MDNode;
5072
5073 DIMacroFile(LLVMContext &C, StorageType Storage, unsigned MIType,
5074 unsigned Line, ArrayRef<Metadata *> Ops)
5075 : DIMacroNode(C, DIMacroFileKind, Storage, MIType, Ops) {
5077 }
5078 ~DIMacroFile() = default;
5079
5080 static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
5081 unsigned Line, DIFile *File,
5082 DIMacroNodeArray Elements, StorageType Storage,
5083 bool ShouldCreate = true) {
5084 return getImpl(Context, MIType, Line, static_cast<Metadata *>(File),
5085 Elements.get(), Storage, ShouldCreate);
5086 }
5087
5088 LLVM_ABI static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
5089 unsigned Line, Metadata *File,
5091 bool ShouldCreate = true);
5092
5093 TempDIMacroFile cloneImpl() const {
5095 getElements());
5096 }
5097
5098public:
5100 (unsigned MIType, unsigned Line, DIFile *File,
5101 DIMacroNodeArray Elements),
5102 (MIType, Line, File, Elements))
5103 DEFINE_MDNODE_GET(DIMacroFile,
5104 (unsigned MIType, unsigned Line, Metadata *File,
5107
5108 TempDIMacroFile clone() const { return cloneImpl(); }
5109
5110 void replaceElements(DIMacroNodeArray Elements) {
5111#ifndef NDEBUG
5112 for (DIMacroNode *Op : getElements())
5113 assert(is_contained(Elements->operands(), Op) &&
5114 "Lost a macro node during macro node list replacement");
5115#endif
5116 replaceOperandWith(1, Elements.get());
5117 }
5118
5119 unsigned getLine() const { return SubclassData32; }
5121
5122 DIMacroNodeArray getElements() const {
5124 }
5125
5126 Metadata *getRawFile() const { return getOperand(0); }
5127 Metadata *getRawElements() const { return getOperand(1); }
5128
5129 static bool classof(const Metadata *MD) {
5130 return MD->getMetadataID() == DIMacroFileKind;
5131 }
5132};
5133
5134/// List of ValueAsMetadata, to be used as an argument to a dbg.value
5135/// intrinsic.
5136class DIArgList : public Metadata, ReplaceableUsesWithContext {
5137 friend class ReplaceableUses;
5138 friend class LLVMContextImpl;
5140
5142
5143 DIArgList(LLVMContext &Context, ArrayRef<ValueAsMetadata *> Args)
5144 : Metadata(DIArgListKind, Uniqued), ReplaceableUsesWithContext(Context),
5145 Args(Args) {
5146 track();
5147 }
5148 ~DIArgList() { untrack(); }
5149
5150 LLVM_ABI void track();
5151 LLVM_ABI void untrack();
5152 void dropAllReferences(bool Untrack);
5153
5154public:
5155 LLVM_ABI static DIArgList *get(LLVMContext &Context,
5157
5158 ArrayRef<ValueAsMetadata *> getArgs() const { return Args; }
5159
5160 iterator args_begin() { return Args.begin(); }
5161 iterator args_end() { return Args.end(); }
5162
5163 static bool classof(const Metadata *MD) {
5164 return MD->getMetadataID() == DIArgListKind;
5165 }
5166
5170
5171 LLVM_ABI void handleChangedOperand(void *Ref, Metadata *New);
5172};
5173
5174/// Identifies a unique instance of a variable.
5175///
5176/// Storage for identifying a potentially inlined instance of a variable,
5177/// or a fragment thereof. This guarantees that exactly one variable instance
5178/// may be identified by this class, even when that variable is a fragment of
5179/// an aggregate variable and/or there is another inlined instance of the same
5180/// source code variable nearby.
5181/// This class does not necessarily uniquely identify that variable: it is
5182/// possible that a DebugVariable with different parameters may point to the
5183/// same variable instance, but not that one DebugVariable points to multiple
5184/// variable instances.
5186 using FragmentInfo = DIExpression::FragmentInfo;
5187
5188 const DILocalVariable *Variable;
5189 std::optional<FragmentInfo> Fragment;
5190 const DILocation *InlinedAt;
5191
5192 /// Fragment that will overlap all other fragments. Used as default when
5193 /// caller demands a fragment.
5194 LLVM_ABI static const FragmentInfo DefaultFragment;
5195
5196public:
5198
5200 std::optional<FragmentInfo> FragmentInfo,
5201 const DILocation *InlinedAt)
5202 : Variable(Var), Fragment(FragmentInfo), InlinedAt(InlinedAt) {}
5203
5204 DebugVariable(const DILocalVariable *Var, const DIExpression *DIExpr,
5205 const DILocation *InlinedAt)
5206 : Variable(Var),
5207 Fragment(DIExpr ? DIExpr->getFragmentInfo() : std::nullopt),
5208 InlinedAt(InlinedAt) {}
5209
5210 const DILocalVariable *getVariable() const { return Variable; }
5211 std::optional<FragmentInfo> getFragment() const { return Fragment; }
5212 const DILocation *getInlinedAt() const { return InlinedAt; }
5213
5214 FragmentInfo getFragmentOrDefault() const {
5215 return Fragment.value_or(DefaultFragment);
5216 }
5217
5218 static bool isDefaultFragment(const FragmentInfo F) {
5219 return F == DefaultFragment;
5220 }
5221
5222 bool operator==(const DebugVariable &Other) const {
5223 return std::tie(Variable, Fragment, InlinedAt) ==
5224 std::tie(Other.Variable, Other.Fragment, Other.InlinedAt);
5225 }
5226
5227 bool operator<(const DebugVariable &Other) const {
5228 return std::tie(Variable, Fragment, InlinedAt) <
5229 std::tie(Other.Variable, Other.Fragment, Other.InlinedAt);
5230 }
5231};
5232
5233template <> struct DenseMapInfo<DebugVariable> {
5235
5236 static unsigned getHashValue(const DebugVariable &D) {
5237 unsigned HV = 0;
5238 const std::optional<FragmentInfo> Fragment = D.getFragment();
5239 if (Fragment)
5241
5242 return hash_combine(D.getVariable(), HV, D.getInlinedAt());
5243 }
5244
5245 static bool isEqual(const DebugVariable &A, const DebugVariable &B) {
5246 return A == B;
5247 }
5248};
5249
5250/// Identifies a unique instance of a whole variable (discards/ignores fragment
5251/// information).
5258
5259template <>
5261 : public DenseMapInfo<DebugVariable> {};
5262
5263template <typename NodeT> static const DIScope *getScope(const NodeT *N) {
5264 return N->getScope();
5265}
5266
5267template <typename NodeT> static DIScope *getScope(NodeT *N) {
5268 return N->getScope();
5269}
5270
5271template <>
5272[[maybe_unused]] const DIScope *
5274 return N->getVariable()->getScope();
5275}
5276template <>
5278 return N->getVariable()->getScope();
5279}
5280} // end namespace llvm
5281
5282#undef DEFINE_MDNODE_GET_UNPACK_IMPL
5283#undef DEFINE_MDNODE_GET_UNPACK
5284#undef DEFINE_MDNODE_GET
5285
5286#endif // LLVM_IR_DEBUGINFOMETADATA_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static std::string getLinkageName(GlobalValue::LinkageTypes LT)
#define X(NUM, ENUM, NAME)
Definition ELF.h:857
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:215
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")
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
static unsigned getNextComponentInDiscriminator(unsigned D)
Returns the next component stored in discriminator.
static unsigned getUnsignedFromPrefixEncoding(unsigned U)
Reverse transformation as getPrefixEncodingFromUnsigned.
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
static constexpr StringLiteral Filename
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
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
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 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:67
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator end() const
Definition ArrayRef.h:130
const_pointer iterator
Definition ArrayRef.h:47
iterator begin() const
Definition ArrayRef.h:129
static ConstantAsMetadata * get(Constant *C)
Definition Metadata.h:548
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 LLVMContextImpl
SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
friend class ReplaceableUses
static bool classof(const Metadata *MD)
ArrayRef< DbgVariableRecord * > getRecords() const
friend class Instruction
Iterator for Instructions in a `BasicBlock.
static TempDIAssignID getTemporary(LLVMContext &Context)
static DIAssignID * getDistinct(LLVMContext &Context)
friend class LLVMContextImpl
friend class DebugValueUser
ArrayRef< Instruction * > getInstructions() const
void replaceOperandWith(unsigned I, Metadata *New)=delete
Basic type, like 'int' or 'float'.
DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag, unsigned LineNo, 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 Encoding
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags
TempDIBasicType cloneImpl() const
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 StringRef DIFile unsigned DIScope uint64_t uint32_t unsigned uint32_t uint32_t DataSizeInBits
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 StringRef DIFile * File
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 StringRef DIFile unsigned DIScope * Scope
~DIBasicType()=default
static bool classof(const Metadata *MD)
static DIBasicType * getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, DIFile *File, unsigned LineNo, DIScope *Scope, 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
DEFINE_MDNODE_GET(DIBasicType,(unsigned Tag, StringRef Name),(Tag, Name, nullptr, 0, nullptr, 0, 0, 0, 0, 0, FlagZero)) DEFINE_MDNODE_GET(DIBasicType
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, unsigned LineNo, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, ArrayRef< Metadata * > Ops)
static DIBasicType * getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File, unsigned LineNo, DIScope *Scope, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags, StorageType Storage, bool ShouldCreate=true)
unsigned StringRef Name
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t AlignInBits
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 StringRef DIFile unsigned LineNo
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
bool isDebugInfoForProfiling() const
Metadata * getRawEnumTypes() const
StringRef getProducer() const
void setDWOId(uint64_t DwoId)
uint16_t getDialect() const
Target-specific language dialect for DWARF.
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)
uint64_t getIndex() const
Return the location operand index.
static LLVM_ABI bool classof(const ExprOperand *Op)
uint64_t getValue() const
Return the unsigned constant value.
static LLVM_ABI bool classof(const ExprOperand *Op)
uint64_t getBitSize() const
Return the destination size in bits.
uint64_t getEncoding() const
Return the raw destination type encoding.
static LLVM_ABI bool classof(const ExprOperand *Op)
static LLVM_ABI bool classof(const ExprOperand *Op)
uint64_t getNumOperations() const
Return the number of operations the entry value covers.
A lightweight wrapper around an expression operand.
LLVM_ABI bool isNonEmitting() const
Return true if CodeGen handles this operand without adding bytes to the DWARF expression.
LLVM_ABI unsigned getSize() const
Return the size of the operand.
uint64_t getArg(unsigned I) const
Get an argument to the operand.
bool is(uint64_t Opcode) const
Return true if this is Opcode.
uint64_t getOp() const
Get the operand code.
void appendToVector(SmallVectorImpl< uint64_t > &V) const
Append the elements of this operand to V.
static LLVM_ABI bool classof(const ExprOperand *Op)
uint64_t getOffsetInBits() const
Return the extract offset in bits.
uint64_t getSizeInBits() const
Return the extract size in bits.
LLVM_ABI bool isSigned() const
Return whether the extracted value is sign-extended.
uint64_t getSizeInBits() const
Return the fragment size in bits.
static LLVM_ABI bool classof(const ExprOperand *Op)
uint64_t getOffsetInBits() const
Return the fragment offset in bits.
static LLVM_ABI bool classof(const ExprOperand *Op)
uint64_t getOffset() const
Return the unsigned offset.
static LLVM_ABI bool classof(const ExprOperand *Op)
uint64_t getTagOffset() const
Return the offset a memory tag is derived from.
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 bool isLitOp(uint64_t Op)
Return true if Op is one of DW_OP_lit0 through DW_OP_lit31.
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...
LLVM_ABI uint64_t getConstantValue() const
Return the value of a constant expression, as recognized by isConstant().
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 bool extractLeadingOffset(ArrayRef< uint64_t > Ops, int64_t &OffsetInBytes, SmallVectorImpl< uint64_t > &RemainingOps)
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 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 expression ends with <DWARF Address Space> DW_OP_swap DW_OP_xderef[_size],...
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
static LLVM_ABI std::optional< FixedPointKind > getFixedPointKind(StringRef Str)
static LLVM_ABI const char * fixedPointKindString(FixedPointKind)
unsigned StringRef DIFile unsigned DIScope uint64_t uint32_t unsigned DIFlags unsigned int APInt Numerator
const APInt & getNumeratorRaw() const
static bool classof(const Metadata *MD)
unsigned StringRef DIFile unsigned LineNo
const APInt & getDenominator() const
unsigned StringRef DIFile unsigned DIScope uint64_t uint32_t unsigned Encoding
unsigned StringRef DIFile unsigned DIScope uint64_t uint32_t unsigned DIFlags unsigned int APInt APInt Denominator
unsigned StringRef DIFile unsigned DIScope uint64_t SizeInBits
unsigned StringRef DIFile unsigned DIScope uint64_t uint32_t AlignInBits
LLVM_ABI bool isSigned() const
unsigned StringRef DIFile unsigned DIScope uint64_t uint32_t unsigned DIFlags unsigned int Factor
@ FixedPointBinary
Scale factor 2^Factor.
@ FixedPointDecimal
Scale factor 10^Factor.
@ FixedPointRational
Arbitrary rational scale factor.
DEFINE_MDNODE_GET(DIFixedPointType,(unsigned Tag, MDString *Name, DIFile *File, unsigned LineNo, DIScope *Scope, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, DIFlags Flags, unsigned Kind, int Factor, APInt Numerator, APInt Denominator),(Tag, Name, File, LineNo, Scope, SizeInBits, AlignInBits, Encoding, Flags, Kind, Factor, Numerator, Denominator)) DEFINE_MDNODE_GET(DIFixedPointType
FixedPointKind getKind() const
unsigned StringRef DIFile unsigned DIScope * Scope
unsigned StringRef DIFile unsigned DIScope uint64_t uint32_t unsigned DIFlags Flags
const APInt & getNumerator() const
unsigned StringRef DIFile * File
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
A sequence of DILayerLoc entries.
static bool classof(const Metadata *MD)
unsigned getHash() const
Get the operand hash (used by the MDNodeOpsKey uniquing key).
DILayerLoc * getLayer(unsigned I) const
unsigned getNumLayers() const
DEFINE_MDNODE_GET(DILayerLocList,(ArrayRef< Metadata * > Layers),(Layers)) TempDILayerLocList clone() const
MDNode::op_iterator layer_iterator
iterator_range< layer_iterator > layers() const
A single intermediate-IR layer location.
MDString * getRawKind() const
DIFile * getFile() const
DEFINE_MDNODE_GET(DILayerLoc,(MDString *Kind, Metadata *File, unsigned Line, unsigned Column),(Kind, File, Line, Column)) TempDILayerLoc clone() const
unsigned getLine() const
unsigned getColumn() const
StringRef getKind() const
friend class LLVMContextImpl
static bool classof(const Metadata *MD)
Metadata * getRawFile() const
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.
DEFINE_MDNODE_GET(DILocation,(unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt=nullptr, bool ImplicitCode=false, uint64_t AtomGroup=0, uint8_t AtomRank=0, Metadata *IRLayers=nullptr),(Line, Column, Scope, InlinedAt, ImplicitCode, AtomGroup, AtomRank, IRLayers)) DEFINE_MDNODE_GET(DILocation
DILayerLocList * getIRLayers() const
unsigned getNumLayers() const
DILayerLoc * getLayer(unsigned I) const
unsigned unsigned DILocalScope DILocation bool uint64_t uint8_t Metadata * IRLayers
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.
Metadata * getRawIRLayers() const
The optional intermediate-IR layer list (DILayerLocList), or null.
uint8_t getAtomRank() const
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
A property of a class or structure.
MDString Metadata unsigned Metadata * Type
MDString Metadata unsigned Metadata Metadata BackingStorage TempDIProperty clone() const
unsigned getLine() const
static bool classof(const Metadata *MD)
Metadata * getRawFile() const
StringRef getFilename() const
DINode * getBackingStorage() const
The data member holding the property's backing storage, i.e.
Metadata * getRawType() const
DIFile * getFile() const
MDString Metadata unsigned Metadata Metadata * BackingStorage
friend class LLVMContextImpl
StringRef getDirectory() const
MDString * getRawName() const
StringRef getName() const
DEFINE_MDNODE_GET(DIProperty,(StringRef Name, DIFile *File, unsigned Line, DIType *Type, DINode *BackingStorage),(Name, File, Line, Type, BackingStorage)) DEFINE_MDNODE_GET(DIProperty
Metadata * getRawBackingStorage() const
DIType * getType() const
MDString Metadata * File
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 source language identity metadata that includes language name,...
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, uint16_t Dialect=0)
DISourceLanguageName(uint16_t Lang, uint32_t Version, uint16_t Dialect=0)
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 MDString Metadata Metadata Metadata uint64_t uint32_t AlignInBits
unsigned MDString Metadata Metadata Metadata * StringLocationExp
DEFINE_MDNODE_GET(DIStringType,(unsigned Tag, StringRef Name, uint64_t SizeInBits, uint32_t AlignInBits),(Tag, Name, nullptr, nullptr, nullptr, SizeInBits, AlignInBits, 0, nullptr)) DEFINE_MDNODE_GET(DIStringType
unsigned MDString Metadata Metadata * StringLengthExp
unsigned MDString Metadata Metadata Metadata uint64_t uint32_t unsigned Encoding
unsigned MDString Metadata * StringLength
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
void forEachRetainedNode(FuncLVT &&FuncLV, FuncLabelT &&FuncLabel, FuncImportedEntityT &&FuncIE, FuncTypeT &&FuncType, FuncGVET &&FuncGVE)
For each retained node, applies one of the given functions depending on the type of a node.
LLVM_ABI void cleanupRetainedNodes()
When IR modules are merged, typically during LTO, the merged module may contain several types having ...
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
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, MDNodeArray 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 DILocalScope * getRetainedNodeScope(MDNode *N)
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata MDString * TargetFuncName
static LLVM_ABI DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
static void cleanupRetainedNodes(const RangeT &NewDistinctSPs)
Calls SP->cleanupRetainedNodes() for a range of DISubprograms.
static LLVM_ABI const DIScope * getRawRetainedNodeScope(const MDNode *N)
void cleanupRetainedNodesIf(T &&Pred)
Metadata MDString * Name
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata * ThrownTypes
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.
DITypeArray getTypeArray() const
TempDISubroutineType cloneWithCC(uint8_t CC) const
DEFINE_MDNODE_GET(DISubroutineType,(DIFlags Flags, uint8_t CC, DITypeArray TypeArray),(Flags, CC, TypeArray)) DEFINE_MDNODE_GET(DISubroutineType
DIFlags uint8_t Metadata * TypeArray
static bool classof(const Metadata *MD)
Metadata * getRawTypeArray() 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
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:64
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:1081
friend class DIAssignID
Definition Metadata.h:1084
LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
const MDOperand & getOperand(unsigned I) const
Definition Metadata.h:1437
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1591
ArrayRef< MDOperand > operands() const
Definition Metadata.h:1435
op_iterator op_end() const
Definition Metadata.h:1431
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1579
bool isUniqued() const
Definition Metadata.h:1263
unsigned getNumOperands() const
Return number of MDNode operands.
Definition Metadata.h:1443
iterator_range< op_iterator > op_range
Definition Metadata.h:1425
LLVM_ABI TempMDNode clone() const
Create a (temporary) clone of this.
Definition Metadata.cpp:670
bool isDistinct() const
Definition Metadata.h:1264
LLVM_ABI void setOperand(unsigned I, Metadata *New)
Set an operand.
op_iterator op_begin() const
Definition Metadata.h:1427
LLVMContext & getContext() const
Definition Metadata.h:1245
LLVM_ABI void dropAllReferences()
Definition Metadata.cpp:913
const MDOperand * op_iterator
Definition Metadata.h:1424
Tracking metadata reference owned by Metadata.
Definition Metadata.h:902
Metadata * get() const
Definition Metadata.h:931
A single uniqued string.
Definition Metadata.h:733
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:597
Tuple of metadata.
Definition Metadata.h:1496
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 bits of the poi...
ReplaceableUsesWithContext(LLVMContext &Context)
Definition Metadata.h:457
LLVM_ABI SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
Returns the list of all DbgVariableRecord users of this.
Definition Metadata.cpp:282
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.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:300
LLVM Value Representation.
Definition Value.h:75
A range adaptor for a pair of iterators.
LLVM_ABI unsigned getVirtuality(StringRef VirtualityString)
Definition Dwarf.cpp:386
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.
template class LLVM_TEMPLATE_ABI opt< bool >
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
bool operator<(int64_t V1, const APSInt &V2)
Definition APSInt.h:360
auto cast_if_present(const Y &Val)
cast_if_present<X> - Functionally identical to cast, except that a null value is accepted.
Definition Casting.h:683
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:2139
auto cast_or_null(const Y &Val)
Definition Casting.h:714
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
static const DIScope * getScope(const NodeT *N)
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
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
@ Other
Any other memory.
Definition ModRef.h:68
static unsigned getN1Bits(int N)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
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:1963
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
Definition InstrProf.h:147
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition Hashing.h:307
@ End
Run the machine verifier once, at the end of the pipeline.
Definition CodeGen.h:267
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
#define N
This struct provides a method for customizing the way a cast is performed.
Definition Casting.h:476
This struct provides a way to check if a given cast is possible.
Definition Casting.h:253
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
This cast trait just provides the default implementation of doCastIfPossible to make CastInfo special...
Definition Casting.h:309
static bool isEqual(const FragInfo &A, const FragInfo &B)
static unsigned getHashValue(const FragInfo &Frag)
static unsigned getHashValue(const DebugVariable &D)
DIExpression::FragmentInfo FragmentInfo
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
static bool isPresent(const DIExpression::ExprOperand &Op)
static DIExpression::ExprOperand & unwrapValue(DIExpression::ExprOperand &Op)
ValueIsPresent provides a way to check if a value is, well, present.
Definition Casting.h:596