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 number of unique location operands referred to (via
3661 /// DW_OP_LLVM_arg) in this expression; this is not necessarily the number of
3662 /// instances of DW_OP_LLVM_arg within the expression.
3663 /// For example, for the expression:
3664 /// (DW_OP_LLVM_arg 0, DW_OP_LLVM_arg 1, DW_OP_plus,
3665 /// DW_OP_LLVM_arg 0, DW_OP_mul)
3666 /// This function would return 2, as there are two unique location operands
3667 /// (0 and 1).
3669
3671
3674
3675 /// A lightweight wrapper around an expression operand.
3676 ///
3677 /// TODO: Store arguments directly and change \a DIExpression to store a
3678 /// range of these.
3680 const uint64_t *Op = nullptr;
3681
3682 public:
3683 ExprOperand() = default;
3684 explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
3685
3686 explicit operator bool() const { return Op != nullptr; }
3687
3688 const uint64_t *get() const { return Op; }
3689
3690 /// Get the operand code.
3691 ///
3692 /// The operand has to be present.
3693 uint64_t getOp() const {
3694 assert(Op && "operand is not present");
3695 return *Op;
3696 }
3697
3698 /// Return true if this is \p Opcode.
3699 bool is(uint64_t Opcode) const { return getOp() == Opcode; }
3700
3701 /// Get an argument to the operand.
3702 ///
3703 /// Never returns the operand itself. The operand has to be present and \p I
3704 /// has to be less than getNumArgs().
3705 uint64_t getArg(unsigned I) const {
3706 assert(Op && "operand is not present");
3707 return Op[I + 1];
3708 }
3709
3710 unsigned getNumArgs() const { return getSize() - 1; }
3711
3712 /// Return the size of the operand.
3713 ///
3714 /// Return the number of elements in the operand (1 + args).
3715 LLVM_ABI unsigned getSize() const;
3716
3717 /// Return true if CodeGen handles this operand without adding bytes to the
3718 /// DWARF expression.
3719 LLVM_ABI bool isNonEmitting() const;
3720
3721 /// Append the elements of this operand to \p V.
3723 V.append(get(), get() + getSize());
3724 }
3725 };
3726
3727 // Typed views name an ExprOperand's arguments. Use cast<FragmentOp>(Op) for a
3728 // known opcode and dyn_cast<ArgOp>(Op) for a conditional match. A failed
3729 // dyn_cast returns an empty view, which tests false and holds no operand to
3730 // read, so check it before calling an accessor. Keep using ExprOperand for
3731 // operations without a typed view.
3732 //
3733 // A view takes an operand rather than an optional one. A cursor hands back
3734 // std::optional<ExprOperand>, so check it and then dereference it.
3735 // dyn_cast_if_present does not compile on std::optional<ExprOperand>, because
3736 // an operand is constructible from a null pointer, which leaves
3737 // ValueIsPresent ambiguous between its optional and its nullable
3738 // specialization.
3739
3740 /// A view of a DW_OP_LLVM_arg operation.
3741 class ArgOp : public ExprOperand {
3742 template <typename To, typename From, typename Enable>
3743 friend struct llvm::CastInfo;
3744
3745 explicit ArgOp(ExprOperand Op) : ExprOperand(Op) {}
3746
3747 public:
3748 /// Return the location operand index.
3749 uint64_t getIndex() const { return getArg(0); }
3750
3751 LLVM_ABI static bool classof(const ExprOperand *Op);
3752 };
3753
3754 /// A view of a DW_OP_LLVM_fragment operation.
3755 class FragmentOp : public ExprOperand {
3756 template <typename To, typename From, typename Enable>
3757 friend struct llvm::CastInfo;
3758
3759 explicit FragmentOp(ExprOperand Op) : ExprOperand(Op) {}
3760
3761 public:
3762 /// Return the fragment offset in bits.
3763 uint64_t getOffsetInBits() const { return getArg(0); }
3764
3765 /// Return the fragment size in bits.
3766 uint64_t getSizeInBits() const { return getArg(1); }
3767
3768 LLVM_ABI static bool classof(const ExprOperand *Op);
3769 };
3770
3771 /// A view of the DW_OP_LLVM_extract_bits_[sz]ext operations.
3772 class ExtractBitsOp : public ExprOperand {
3773 template <typename To, typename From, typename Enable>
3774 friend struct llvm::CastInfo;
3775
3776 explicit ExtractBitsOp(ExprOperand Op) : ExprOperand(Op) {}
3777
3778 public:
3779 /// Return the extract offset in bits.
3780 uint64_t getOffsetInBits() const { return getArg(0); }
3781
3782 /// Return the extract size in bits.
3783 uint64_t getSizeInBits() const { return getArg(1); }
3784
3785 /// Return whether the extracted value is sign-extended.
3786 LLVM_ABI bool isSigned() const;
3787
3788 LLVM_ABI static bool classof(const ExprOperand *Op);
3789 };
3790
3791 /// A view of a DW_OP_LLVM_convert operation.
3792 class ConvertOp : public ExprOperand {
3793 template <typename To, typename From, typename Enable>
3794 friend struct llvm::CastInfo;
3795
3796 explicit ConvertOp(ExprOperand Op) : ExprOperand(Op) {}
3797
3798 public:
3799 /// Return the destination size in bits.
3800 uint64_t getBitSize() const { return getArg(0); }
3801
3802 /// Return the raw destination type encoding.
3803 uint64_t getEncoding() const { return getArg(1); }
3804
3805 LLVM_ABI static bool classof(const ExprOperand *Op);
3806 };
3807
3808 /// A view of a DW_OP_LLVM_entry_value operation.
3809 class EntryValueOp : public ExprOperand {
3810 template <typename To, typename From, typename Enable>
3811 friend struct llvm::CastInfo;
3812
3813 explicit EntryValueOp(ExprOperand Op) : ExprOperand(Op) {}
3814
3815 public:
3816 /// Return the number of operations the entry value covers. The count
3817 /// includes the operation that precedes it, so the operations that follow
3818 /// are one fewer than this.
3819 uint64_t getNumOperations() const { return getArg(0); }
3820
3821 LLVM_ABI static bool classof(const ExprOperand *Op);
3822 };
3823
3824 /// A view of a DW_OP_LLVM_tag_offset operation.
3825 class TagOffsetOp : public ExprOperand {
3826 template <typename To, typename From, typename Enable>
3827 friend struct llvm::CastInfo;
3828
3829 explicit TagOffsetOp(ExprOperand Op) : ExprOperand(Op) {}
3830
3831 public:
3832 /// Return the offset a memory tag is derived from. How a target derives
3833 /// the tag from it is implementation defined.
3834 uint64_t getTagOffset() const { return getArg(0); }
3835
3836 LLVM_ABI static bool classof(const ExprOperand *Op);
3837 };
3838
3839 /// A view of a DW_OP_constu operation.
3840 class ConstuOp : public ExprOperand {
3841 template <typename To, typename From, typename Enable>
3842 friend struct llvm::CastInfo;
3843
3844 explicit ConstuOp(ExprOperand Op) : ExprOperand(Op) {}
3845
3846 public:
3847 /// Return the unsigned constant value.
3848 uint64_t getValue() const { return getArg(0); }
3849
3850 LLVM_ABI static bool classof(const ExprOperand *Op);
3851 };
3852
3853 /// A view of a DW_OP_plus_uconst operation.
3854 class PlusUconstOp : public ExprOperand {
3855 template <typename To, typename From, typename Enable>
3856 friend struct llvm::CastInfo;
3857
3858 explicit PlusUconstOp(ExprOperand Op) : ExprOperand(Op) {}
3859
3860 public:
3861 /// Return the unsigned offset.
3862 uint64_t getOffset() const { return getArg(0); }
3863
3864 LLVM_ABI static bool classof(const ExprOperand *Op);
3865 };
3866
3867 /// An iterator for expression operands.
3869 ExprOperand Op;
3870
3871 public:
3872 using iterator_category = std::input_iterator_tag;
3874 using difference_type = std::ptrdiff_t;
3877
3878 expr_op_iterator() = default;
3880
3881 element_iterator getBase() const { return Op.get(); }
3882 const ExprOperand &operator*() const { return Op; }
3883 const ExprOperand *operator->() const { return &Op; }
3884
3886 increment();
3887 return *this;
3888 }
3890 expr_op_iterator T(*this);
3891 increment();
3892 return T;
3893 }
3894
3895 /// Get the next iterator.
3896 ///
3897 /// \a std::next() doesn't work because this is technically an
3898 /// input_iterator, but it's a perfectly valid operation. This is an
3899 /// accessor to provide the same functionality.
3900 expr_op_iterator getNext() const { return ++expr_op_iterator(*this); }
3901
3902 bool operator==(const expr_op_iterator &X) const {
3903 return getBase() == X.getBase();
3904 }
3905 bool operator!=(const expr_op_iterator &X) const {
3906 return getBase() != X.getBase();
3907 }
3908
3909 private:
3910 void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
3911 };
3912
3913 /// Visit the elements via ExprOperand wrappers.
3914 ///
3915 /// These range iterators visit elements through \a ExprOperand wrappers.
3916 /// This is not guaranteed to be a valid range unless \a isValid() gives \c
3917 /// true.
3918 ///
3919 /// \pre \a isValid() gives \c true.
3920 /// @{
3930 /// @}
3931
3932 LLVM_ABI bool isValid() const;
3933
3934 static bool classof(const Metadata *MD) {
3935 return MD->getMetadataID() == DIExpressionKind;
3936 }
3937
3938 /// Return whether the first element a DW_OP_deref.
3939 LLVM_ABI bool startsWithDeref() const;
3940
3941 /// Return whether there is exactly one operator and it is a DW_OP_deref;
3942 LLVM_ABI bool isDeref() const;
3943
3945
3946 /// Return the number of bits that have an active value, i.e. those that
3947 /// aren't known to be zero/sign (depending on the type of Var) and which
3948 /// are within the size of this fragment (if it is one). If we can't deduce
3949 /// anything from the expression this will return the size of Var.
3950 LLVM_ABI std::optional<uint64_t> getActiveBits(DIVariable *Var);
3951
3952 /// Retrieve the details of this fragment expression.
3953 LLVM_ABI static std::optional<FragmentInfo>
3955
3956 /// Retrieve the details of this fragment expression.
3957 std::optional<FragmentInfo> getFragmentInfo() const {
3959 }
3960
3961 /// Return whether this is a piece of an aggregate variable.
3962 bool isFragment() const { return getFragmentInfo().has_value(); }
3963
3964 /// Return whether this is an implicit location description.
3965 LLVM_ABI bool isImplicit() const;
3966
3967 /// Return whether the location is computed on the expression stack, meaning
3968 /// it cannot be a simple register location.
3969 LLVM_ABI bool isComplex() const;
3970
3971 /// Return whether the evaluated expression makes use of a single location at
3972 /// the start of the expression, i.e. if it contains only a single
3973 /// DW_OP_LLVM_arg op as its first operand, or if it contains none.
3975
3976 /// Returns a reference to the elements contained in this expression, skipping
3977 /// past the leading `DW_OP_LLVM_arg, 0` if one is present.
3978 /// Similar to `convertToNonVariadicExpression`, but faster and cheaper - it
3979 /// does not check whether the expression is a single-location expression, and
3980 /// it returns elements rather than creating a new DIExpression.
3981 LLVM_ABI std::optional<ArrayRef<uint64_t>>
3983
3984 /// Removes all elements from \p Expr that do not apply to an undef debug
3985 /// value, which includes every operator that computes the value/location on
3986 /// the DWARF stack, including any DW_OP_LLVM_arg elements (making the result
3987 /// of this function always a single-location expression) while leaving
3988 /// everything that defines what the computed value applies to, i.e. the
3989 /// fragment information.
3990 LLVM_ABI static const DIExpression *
3992
3993 /// If \p Expr is a non-variadic expression (i.e. one that does not contain
3994 /// DW_OP_LLVM_arg), returns \p Expr converted to variadic form by adding a
3995 /// leading [DW_OP_LLVM_arg, 0] to the expression; otherwise returns \p Expr.
3996 LLVM_ABI static const DIExpression *
3998
3999 /// If \p Expr is a valid single-location expression, i.e. it refers to only a
4000 /// single debug operand at the start of the expression, then return that
4001 /// expression in a non-variadic form by removing DW_OP_LLVM_arg from the
4002 /// expression if it is present; otherwise returns std::nullopt.
4003 /// See also `getSingleLocationExpressionElements` above, which skips
4004 /// checking `isSingleLocationExpression` and returns a list of elements
4005 /// rather than a DIExpression.
4006 LLVM_ABI static std::optional<const DIExpression *>
4008
4009 /// Inserts the elements of \p Expr into \p Ops modified to a canonical form,
4010 /// which uses DW_OP_LLVM_arg (i.e. is a variadic expression) and folds the
4011 /// implied derefence from the \p IsIndirect flag into the expression. This
4012 /// allows us to check equivalence between expressions with differing
4013 /// directness or variadicness.
4015 const DIExpression *Expr,
4016 bool IsIndirect);
4017
4018 /// Determines whether two debug values should produce equivalent DWARF
4019 /// expressions, using their DIExpressions and directness, ignoring the
4020 /// differences between otherwise identical expressions in variadic and
4021 /// non-variadic form and not considering the debug operands.
4022 /// \p FirstExpr is the DIExpression for the first debug value.
4023 /// \p FirstIndirect should be true if the first debug value is indirect; in
4024 /// IR this should be true for dbg.declare intrinsics and false for
4025 /// dbg.values, and in MIR this should be true only for DBG_VALUE instructions
4026 /// whose second operand is an immediate value.
4027 /// \p SecondExpr and \p SecondIndirect have the same meaning as the prior
4028 /// arguments, but apply to the second debug value.
4029 LLVM_ABI static bool isEqualExpression(const DIExpression *FirstExpr,
4030 bool FirstIndirect,
4031 const DIExpression *SecondExpr,
4032 bool SecondIndirect);
4033
4034 /// Append \p Ops with operations to apply the \p Offset.
4036 int64_t Offset);
4037
4038 LLVM_ABI static bool
4039 extractLeadingOffset(ArrayRef<uint64_t> Ops, int64_t &OffsetInBytes,
4040 SmallVectorImpl<uint64_t> &RemainingOps);
4041
4042 /// If this is a constant offset, extract it. If there is no expression,
4043 /// return true with an offset of zero.
4044 LLVM_ABI bool extractIfOffset(int64_t &Offset) const;
4045
4046 /// Assuming that the expression operates on an address, extract a constant
4047 /// offset and the successive ops. Return false if the expression contains
4048 /// any incompatible ops (including non-zero DW_OP_LLVM_args - only a single
4049 /// address operand to the expression is permitted).
4050 ///
4051 /// We don't try very hard to interpret the expression because we assume that
4052 /// foldConstantMath has canonicalized the expression.
4053 LLVM_ABI bool
4054 extractLeadingOffset(int64_t &OffsetInBytes,
4055 SmallVectorImpl<uint64_t> &RemainingOps) const;
4056
4057 /// Returns true iff this DIExpression contains at least one instance of
4058 /// `DW_OP_LLVM_arg, n` for all n in [0, N).
4059 LLVM_ABI bool hasAllLocationOps(unsigned N) const;
4060
4061 /// Checks if the last 4 elements of the expression are DW_OP_constu <DWARF
4062 /// Address Space> DW_OP_swap DW_OP_xderef and extracts the <DWARF Address
4063 /// Space>.
4064 LLVM_ABI static const DIExpression *
4065 extractAddressClass(const DIExpression *Expr, unsigned &AddrClass);
4066
4067 /// Used for DIExpression::prepend.
4070 DerefBefore = 1 << 0,
4071 DerefAfter = 1 << 1,
4072 StackValue = 1 << 2,
4073 EntryValue = 1 << 3
4074 };
4075
4076 /// Prepend \p DIExpr with a deref and offset operation and optionally turn it
4077 /// into a stack value or/and an entry value.
4078 LLVM_ABI static DIExpression *prepend(const DIExpression *Expr, uint8_t Flags,
4079 int64_t Offset = 0);
4080
4081 /// Prepend \p DIExpr with the given opcodes and optionally turn it into a
4082 /// stack value.
4085 bool StackValue = false,
4086 bool EntryValue = false);
4087
4088 /// Append the opcodes \p Ops to \p DIExpr. Unlike \ref appendToStack, the
4089 /// returned expression is a stack value only if \p DIExpr is a stack value.
4090 /// If \p DIExpr describes a fragment, the returned expression will describe
4091 /// the same fragment.
4092 LLVM_ABI static DIExpression *append(const DIExpression *Expr,
4094
4095 /// Convert \p DIExpr into a stack value if it isn't one already by appending
4096 /// DW_OP_deref if needed, and appending \p Ops to the resulting expression.
4097 /// If \p DIExpr describes a fragment, the returned expression will describe
4098 /// the same fragment.
4099 LLVM_ABI static DIExpression *appendToStack(const DIExpression *Expr,
4101
4102 /// Create a copy of \p Expr by appending the given list of \p Ops to each
4103 /// instance of the operand `DW_OP_LLVM_arg, \p ArgNo`. This is used to
4104 /// modify a specific location used by \p Expr, such as when salvaging that
4105 /// location.
4108 unsigned ArgNo,
4109 bool StackValue = false);
4110
4111 /// Create a copy of \p Expr with each instance of
4112 /// `DW_OP_LLVM_arg, \p OldArg` replaced with `DW_OP_LLVM_arg, \p NewArg`,
4113 /// and each instance of `DW_OP_LLVM_arg, Arg` with `DW_OP_LLVM_arg, Arg - 1`
4114 /// for all Arg > \p OldArg.
4115 /// This is used when replacing one of the operands of a debug value list
4116 /// with another operand in the same list and deleting the old operand.
4117 LLVM_ABI static DIExpression *replaceArg(const DIExpression *Expr,
4118 uint64_t OldArg, uint64_t NewArg);
4119
4120 /// Create a DIExpression to describe one part of an aggregate variable that
4121 /// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation
4122 /// will be appended to the elements of \c Expr. If \c Expr already contains
4123 /// a \c DW_OP_LLVM_fragment \c OffsetInBits is interpreted as an offset
4124 /// into the existing fragment.
4125 ///
4126 /// \param OffsetInBits Offset of the piece in bits.
4127 /// \param SizeInBits Size of the piece in bits.
4128 /// \return Creating a fragment expression may fail if \c Expr
4129 /// contains arithmetic operations that would be
4130 /// truncated.
4131 LLVM_ABI static std::optional<DIExpression *>
4132 createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits,
4133 unsigned SizeInBits);
4134
4135 /// Determine the relative position of the fragments passed in.
4136 /// Returns -1 if this is entirely before Other, 0 if this and Other overlap,
4137 /// 1 if this is entirely after Other.
4138 static int fragmentCmp(const FragmentInfo &A, const FragmentInfo &B) {
4139 uint64_t l1 = A.OffsetInBits;
4140 uint64_t l2 = B.OffsetInBits;
4141 uint64_t r1 = l1 + A.SizeInBits;
4142 uint64_t r2 = l2 + B.SizeInBits;
4143 if (r1 <= l2)
4144 return -1;
4145 else if (r2 <= l1)
4146 return 1;
4147 else
4148 return 0;
4149 }
4150
4151 /// Computes a fragment, bit-extract operation if needed, and new constant
4152 /// offset to describe a part of a variable covered by some memory.
4153 ///
4154 /// The memory region starts at:
4155 /// \p SliceStart + \p SliceOffsetInBits
4156 /// And is size:
4157 /// \p SliceSizeInBits
4158 ///
4159 /// The location of the existing variable fragment \p VarFrag is:
4160 /// \p DbgPtr + \p DbgPtrOffsetInBits + \p DbgExtractOffsetInBits.
4161 ///
4162 /// It is intended that these arguments are derived from a debug record:
4163 /// - \p DbgPtr is the (single) DIExpression operand.
4164 /// - \p DbgPtrOffsetInBits is the constant offset applied to \p DbgPtr.
4165 /// - \p DbgExtractOffsetInBits is the offset from a
4166 /// DW_OP_LLVM_bit_extract_[sz]ext operation.
4167 ///
4168 /// Results and return value:
4169 /// - Return false if the result can't be calculated for any reason.
4170 /// - \p Result is set to nullopt if the intersect equals \p VarFrag.
4171 /// - \p Result contains a zero-sized fragment if there's no intersect.
4172 /// - \p OffsetFromLocationInBits is set to the difference between the first
4173 /// bit of the variable location and the first bit of the slice. The
4174 /// magnitude of a negative value therefore indicates the number of bits
4175 /// into the variable fragment that the memory region begins.
4176 ///
4177 /// We don't pass in a debug record directly to get the constituent parts
4178 /// and offsets because different debug records store the information in
4179 /// different places (dbg_assign has two DIExpressions - one contains the
4180 /// fragment info for the entire intrinsic).
4182 const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits,
4183 uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits,
4184 int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag,
4185 std::optional<DIExpression::FragmentInfo> &Result,
4186 int64_t &OffsetFromLocationInBits);
4187
4188 using ExtOps = std::array<uint64_t, 6>;
4189
4190 /// Returns the ops for a zero- or sign-extension in a DIExpression.
4191 LLVM_ABI static ExtOps getExtOps(unsigned FromSize, unsigned ToSize,
4192 bool Signed);
4193
4194 /// Append a zero- or sign-extension to \p Expr. Converts the expression to a
4195 /// stack value if it isn't one already.
4196 LLVM_ABI static DIExpression *appendExt(const DIExpression *Expr,
4197 unsigned FromSize, unsigned ToSize,
4198 bool Signed);
4199
4200 /// Check if fragments overlap between a pair of FragmentInfos.
4201 static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B) {
4202 return fragmentCmp(A, B) == 0;
4203 }
4204
4205 /// Determine the relative position of the fragments described by this
4206 /// DIExpression and \p Other. Calls static fragmentCmp implementation.
4207 int fragmentCmp(const DIExpression *Other) const {
4208 auto Fragment1 = *getFragmentInfo();
4209 auto Fragment2 = *Other->getFragmentInfo();
4210 return fragmentCmp(Fragment1, Fragment2);
4211 }
4212
4213 /// Check if fragments overlap between this DIExpression and \p Other.
4214 bool fragmentsOverlap(const DIExpression *Other) const {
4215 if (!isFragment() || !Other->isFragment())
4216 return true;
4217 return fragmentCmp(Other) == 0;
4218 }
4219
4220 /// Check if the expression consists of exactly one entry value operand.
4221 /// (This is the only configuration of entry values that is supported.)
4222 LLVM_ABI bool isEntryValue() const;
4223
4224 /// Try to shorten an expression with an initial constant operand.
4225 /// Returns a new expression and constant on success, or the original
4226 /// expression and constant on failure.
4227 LLVM_ABI std::pair<DIExpression *, const ConstantInt *>
4228 constantFold(const ConstantInt *CI);
4229
4230 /// Try to shorten an expression with constant math operations that can be
4231 /// evaluated at compile time. Returns a new expression on success, or the old
4232 /// expression if there is nothing to be reduced.
4234};
4235
4236template <typename To, typename From>
4238 To, From,
4239 std::enable_if_t<
4240 std::is_same_v<std::remove_const_t<From>, DIExpression::ExprOperand> &&
4241 !std::is_same_v<std::remove_const_t<To>, DIExpression::ExprOperand>>>
4242 : CastIsPossible<To, From>,
4243 DefaultDoCastIfPossible<To, From, CastInfo<To, From>> {
4244 static To doCast(const From &Op) { return To(Op); }
4245 static To castFailed() { return To(DIExpression::ExprOperand()); }
4246};
4247
4248/// Treat a default-constructed expression operand as absent.
4249template <> struct ValueIsPresent<DIExpression::ExprOperand> {
4251
4253 return bool(Op);
4254 }
4255
4259};
4260
4263 return std::tie(A.SizeInBits, A.OffsetInBits) ==
4264 std::tie(B.SizeInBits, B.OffsetInBits);
4265}
4266
4269 return std::tie(A.SizeInBits, A.OffsetInBits) <
4270 std::tie(B.SizeInBits, B.OffsetInBits);
4271}
4272
4273template <> struct DenseMapInfo<DIExpression::FragmentInfo> {
4275 static const uint64_t MaxVal = std::numeric_limits<uint64_t>::max();
4276
4277 static unsigned getHashValue(const FragInfo &Frag) {
4278 return (Frag.SizeInBits & 0xffff) << 16 | (Frag.OffsetInBits & 0xffff);
4279 }
4280
4281 static bool isEqual(const FragInfo &A, const FragInfo &B) { return A == B; }
4282};
4283
4284/// Holds a DIExpression and keeps track of how many operands have been consumed
4285/// so far.
4288
4289public:
4291 if (!Expr) {
4292 assert(Start == End);
4293 return;
4294 }
4295 Start = Expr->expr_op_begin();
4296 End = Expr->expr_op_end();
4297 }
4298
4300 : Start(Expr.begin()), End(Expr.end()) {}
4301
4303
4304 /// Consume one operation.
4305 std::optional<DIExpression::ExprOperand> take() {
4306 if (Start == End)
4307 return std::nullopt;
4308 return *(Start++);
4309 }
4310
4311 /// Consume N operations.
4312 void consume(unsigned N) { std::advance(Start, N); }
4313
4314 /// Return the current operation.
4315 std::optional<DIExpression::ExprOperand> peek() const {
4316 if (Start == End)
4317 return std::nullopt;
4318 return *(Start);
4319 }
4320
4321 /// Return the next operation.
4322 std::optional<DIExpression::ExprOperand> peekNext() const {
4323 if (Start == End)
4324 return std::nullopt;
4325
4326 auto Next = Start.getNext();
4327 if (Next == End)
4328 return std::nullopt;
4329
4330 return *Next;
4331 }
4332
4333 std::optional<DIExpression::ExprOperand> peekNextN(unsigned N) const {
4334 if (Start == End)
4335 return std::nullopt;
4337 for (unsigned I = 0; I < N; I++) {
4338 Nth = Nth.getNext();
4339 if (Nth == End)
4340 return std::nullopt;
4341 }
4342 return *Nth;
4343 }
4344
4346 this->Start = DIExpression::expr_op_iterator(Expr.begin());
4347 this->End = DIExpression::expr_op_iterator(Expr.end());
4348 }
4349
4350 /// Determine whether there are any operations left in this expression.
4351 operator bool() const { return Start != End; }
4352
4353 DIExpression::expr_op_iterator begin() const { return Start; }
4354 DIExpression::expr_op_iterator end() const { return End; }
4355
4356 /// Retrieve the fragment information, if any.
4357 std::optional<DIExpression::FragmentInfo> getFragmentInfo() const {
4358 return DIExpression::getFragmentInfo(Start, End);
4359 }
4360};
4361
4362/// Global variables.
4363///
4364/// TODO: Remove DisplayName. It's always equal to Name.
4365class DIGlobalVariable : public DIVariable {
4366 friend class LLVMContextImpl;
4367 friend class MDNode;
4368
4369 bool IsLocalToUnit;
4370 bool IsDefinition;
4371
4372 DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
4373 bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
4375 : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
4376 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
4377 ~DIGlobalVariable() = default;
4378
4379 static DIGlobalVariable *
4380 getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
4381 StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type,
4382 bool IsLocalToUnit, bool IsDefinition,
4385 bool ShouldCreate = true) {
4386 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
4387 getCanonicalMDString(Context, LinkageName), File, Line, Type,
4390 Annotations.get(), Storage, ShouldCreate);
4391 }
4392 LLVM_ABI static DIGlobalVariable *
4393 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
4394 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
4395 bool IsLocalToUnit, bool IsDefinition,
4398 bool ShouldCreate = true);
4399
4400 TempDIGlobalVariable cloneImpl() const {
4405 getAnnotations());
4406 }
4407
4408public:
4410 DIGlobalVariable,
4412 unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition,
4414 uint32_t AlignInBits, DINodeArray Annotations),
4415 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
4418 DIGlobalVariable,
4420 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
4423 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
4425
4426 TempDIGlobalVariable clone() const { return cloneImpl(); }
4427
4428 bool isLocalToUnit() const { return IsLocalToUnit; }
4429 bool isDefinition() const { return IsDefinition; }
4435 DINodeArray getAnnotations() const {
4437 }
4438
4443 Metadata *getRawAnnotations() const { return getOperand(8); }
4444
4445 static bool classof(const Metadata *MD) {
4446 return MD->getMetadataID() == DIGlobalVariableKind;
4447 }
4448};
4449
4450/// Debug common block.
4451///
4452/// Uses the SubclassData32 Metadata slot.
4453class DICommonBlock : public DIScope {
4454 friend class LLVMContextImpl;
4455 friend class MDNode;
4456
4457 DICommonBlock(LLVMContext &Context, StorageType Storage, unsigned LineNo,
4459
4460 static DICommonBlock *getImpl(LLVMContext &Context, DIScope *Scope,
4462 DIFile *File, unsigned LineNo,
4463 StorageType Storage, bool ShouldCreate = true) {
4464 return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name),
4465 File, LineNo, Storage, ShouldCreate);
4466 }
4467 LLVM_ABI static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope,
4469 Metadata *File, unsigned LineNo,
4471 bool ShouldCreate = true);
4472
4473 TempDICommonBlock cloneImpl() const {
4475 getFile(), getLineNo());
4476 }
4477
4478public:
4479 DEFINE_MDNODE_GET(DICommonBlock,
4481 DIFile *File, unsigned LineNo),
4482 (Scope, Decl, Name, File, LineNo))
4483 DEFINE_MDNODE_GET(DICommonBlock,
4485 Metadata *File, unsigned LineNo),
4487
4488 TempDICommonBlock clone() const { return cloneImpl(); }
4489
4494 StringRef getName() const { return getStringOperand(2); }
4496 unsigned getLineNo() const { return SubclassData32; }
4497
4498 Metadata *getRawScope() const { return getOperand(0); }
4499 Metadata *getRawDecl() const { return getOperand(1); }
4501 Metadata *getRawFile() const { return getOperand(3); }
4502
4503 static bool classof(const Metadata *MD) {
4504 return MD->getMetadataID() == DICommonBlockKind;
4505 }
4506};
4507
4508/// Local variable.
4509///
4510/// TODO: Split up flags.
4511class DILocalVariable : public DIVariable {
4512 friend class LLVMContextImpl;
4513 friend class MDNode;
4514
4515 unsigned Arg : 16;
4516 DIFlags Flags;
4517
4518 DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
4519 unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
4521 : DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
4522 Arg(Arg), Flags(Flags) {
4523 assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range");
4524 }
4525 ~DILocalVariable() = default;
4526
4527 static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
4528 StringRef Name, DIFile *File, unsigned Line,
4529 DIType *Type, unsigned Arg, DIFlags Flags,
4530 uint32_t AlignInBits, DINodeArray Annotations,
4532 bool ShouldCreate = true) {
4533 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
4534 Line, Type, Arg, Flags, AlignInBits, Annotations.get(),
4535 Storage, ShouldCreate);
4536 }
4537 LLVM_ABI static DILocalVariable *
4538 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File,
4539 unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags,
4541 bool ShouldCreate = true);
4542
4543 TempDILocalVariable cloneImpl() const {
4545 getLine(), getType(), getArg(), getFlags(),
4547 }
4548
4549public:
4550 DEFINE_MDNODE_GET(DILocalVariable,
4552 unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags,
4553 uint32_t AlignInBits, DINodeArray Annotations),
4554 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
4555 Annotations))
4556 DEFINE_MDNODE_GET(DILocalVariable,
4558 unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags,
4560 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
4561 Annotations))
4562
4563 TempDILocalVariable clone() const { return cloneImpl(); }
4564
4565 /// Get the local scope for this variable.
4566 ///
4567 /// Variables must be defined in a local scope.
4571
4572 bool isParameter() const { return Arg; }
4573 unsigned getArg() const { return Arg; }
4574 DIFlags getFlags() const { return Flags; }
4575
4576 DINodeArray getAnnotations() const {
4578 }
4579 Metadata *getRawAnnotations() const { return getOperand(4); }
4580
4581 bool isArtificial() const { return getFlags() & FlagArtificial; }
4582 bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
4583
4584 /// Check that a location is valid for this variable.
4585 ///
4586 /// Check that \c DL exists, is in the same subprogram, and has the same
4587 /// inlined-at location as \c this. (Otherwise, it's not a valid attachment
4588 /// to a \a DbgInfoIntrinsic.)
4590 return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
4591 }
4592
4593 static bool classof(const Metadata *MD) {
4594 return MD->getMetadataID() == DILocalVariableKind;
4595 }
4596};
4597
4598/// Label.
4599///
4600/// Uses the SubclassData32 Metadata slot.
4601class DILabel : public DINode {
4602 friend class LLVMContextImpl;
4603 friend class MDNode;
4604
4605 unsigned Column;
4606 std::optional<unsigned> CoroSuspendIdx;
4607 bool IsArtificial;
4608
4609 DILabel(LLVMContext &C, StorageType Storage, unsigned Line, unsigned Column,
4610 bool IsArtificial, std::optional<unsigned> CoroSuspendIdx,
4612 ~DILabel() = default;
4613
4614 static DILabel *getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
4615 DIFile *File, unsigned Line, unsigned Column,
4616 bool IsArtificial,
4617 std::optional<unsigned> CoroSuspendIdx,
4618 StorageType Storage, bool ShouldCreate = true) {
4619 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
4620 Line, Column, IsArtificial, CoroSuspendIdx, Storage,
4621 ShouldCreate);
4622 }
4623 LLVM_ABI static DILabel *
4624 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File,
4625 unsigned Line, unsigned Column, bool IsArtificial,
4626 std::optional<unsigned> CoroSuspendIdx, StorageType Storage,
4627 bool ShouldCreate = true);
4628
4629 TempDILabel cloneImpl() const {
4633 }
4634
4635public:
4638 unsigned Line, unsigned Column, bool IsArtificial,
4639 std::optional<unsigned> CoroSuspendIdx),
4640 (Scope, Name, File, Line, Column, IsArtificial,
4641 CoroSuspendIdx))
4642 DEFINE_MDNODE_GET(DILabel,
4644 unsigned Line, unsigned Column, bool IsArtificial,
4645 std::optional<unsigned> CoroSuspendIdx),
4646 (Scope, Name, File, Line, Column, IsArtificial,
4647 CoroSuspendIdx))
4648
4649 TempDILabel clone() const { return cloneImpl(); }
4650
4651 /// Get the local scope for this label.
4652 ///
4653 /// Labels must be defined in a local scope.
4657 unsigned getLine() const { return SubclassData32; }
4658 unsigned getColumn() const { return Column; }
4659 StringRef getName() const { return getStringOperand(1); }
4661 bool isArtificial() const { return IsArtificial; }
4662 std::optional<unsigned> getCoroSuspendIdx() const { return CoroSuspendIdx; }
4663
4664 Metadata *getRawScope() const { return getOperand(0); }
4666 Metadata *getRawFile() const { return getOperand(2); }
4667
4668 /// Check that a location is valid for this label.
4669 ///
4670 /// Check that \c DL exists, is in the same subprogram, and has the same
4671 /// inlined-at location as \c this. (Otherwise, it's not a valid attachment
4672 /// to a \a DbgInfoIntrinsic.)
4674 return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
4675 }
4676
4677 static bool classof(const Metadata *MD) {
4678 return MD->getMetadataID() == DILabelKind;
4679 }
4680};
4681
4682class DIObjCProperty : public DINode {
4683 friend class LLVMContextImpl;
4684 friend class MDNode;
4685
4686 unsigned Line;
4687 unsigned Attributes;
4688
4689 DIObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
4690 unsigned Attributes, ArrayRef<Metadata *> Ops);
4691 ~DIObjCProperty() = default;
4692
4693 static DIObjCProperty *
4694 getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
4695 StringRef GetterName, StringRef SetterName, unsigned Attributes,
4696 DIType *Type, StorageType Storage, bool ShouldCreate = true) {
4697 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
4699 getCanonicalMDString(Context, SetterName), Attributes, Type,
4700 Storage, ShouldCreate);
4701 }
4702 LLVM_ABI static DIObjCProperty *
4703 getImpl(LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
4704 MDString *GetterName, MDString *SetterName, unsigned Attributes,
4705 Metadata *Type, StorageType Storage, bool ShouldCreate = true);
4706
4707 TempDIObjCProperty cloneImpl() const {
4708 return getTemporary(getContext(), getName(), getFile(), getLine(),
4710 getType());
4711 }
4712
4713public:
4714 DEFINE_MDNODE_GET(DIObjCProperty,
4715 (StringRef Name, DIFile *File, unsigned Line,
4717 unsigned Attributes, DIType *Type),
4718 (Name, File, Line, GetterName, SetterName, Attributes,
4719 Type))
4720 DEFINE_MDNODE_GET(DIObjCProperty,
4721 (MDString * Name, Metadata *File, unsigned Line,
4723 unsigned Attributes, Metadata *Type),
4724 (Name, File, Line, GetterName, SetterName, Attributes,
4725 Type))
4726
4727 TempDIObjCProperty clone() const { return cloneImpl(); }
4728
4729 unsigned getLine() const { return Line; }
4730 unsigned getAttributes() const { return Attributes; }
4731 StringRef getName() const { return getStringOperand(0); }
4736
4738 if (auto *F = getFile())
4739 return F->getFilename();
4740 return "";
4741 }
4742
4744 if (auto *F = getFile())
4745 return F->getDirectory();
4746 return "";
4747 }
4748
4750 Metadata *getRawFile() const { return getOperand(1); }
4753 Metadata *getRawType() const { return getOperand(4); }
4754
4755 static bool classof(const Metadata *MD) {
4756 return MD->getMetadataID() == DIObjCPropertyKind;
4757 }
4758};
4759
4760/// A property of a class or structure.
4761///
4762/// An entity that is syntactically accessed like a data member, but whose
4763/// access is implemented by invoking a user-defined or compiler-generated
4764/// accessor.
4765///
4766/// Currently only the backing storage is modelled, and it must be a data
4767/// member holding the property's storage.
4768class DIProperty : public DINode {
4769 friend class LLVMContextImpl;
4770 friend class MDNode;
4771
4772 unsigned Line;
4773
4774 DIProperty(LLVMContext &C, StorageType Storage, unsigned Line,
4776 ~DIProperty() = default;
4777
4778 static DIProperty *getImpl(LLVMContext &Context, StringRef Name, DIFile *File,
4779 unsigned Line, DIType *Type,
4781 bool ShouldCreate = true) {
4782 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
4783 Type, BackingStorage, Storage, ShouldCreate);
4784 }
4785 LLVM_ABI static DIProperty *getImpl(LLVMContext &Context, MDString *Name,
4786 Metadata *File, unsigned Line,
4789 bool ShouldCreate = true);
4790
4791 TempDIProperty cloneImpl() const {
4792 return getTemporary(getContext(), getName(), getFile(), getLine(),
4794 }
4795
4796public:
4798 (StringRef Name, DIFile *File, unsigned Line, DIType *Type,
4800 (Name, File, Line, Type, BackingStorage))
4801 DEFINE_MDNODE_GET(DIProperty,
4802 (MDString * Name, Metadata *File, unsigned Line,
4805
4806 TempDIProperty clone() const { return cloneImpl(); }
4807
4808 unsigned getLine() const { return Line; }
4809 StringRef getName() const { return getStringOperand(0); }
4812
4813 /// The data member holding the property's backing storage, i.e. the target
4814 /// of \c DW_AT_property_forward on this property's
4815 /// \c DW_TAG_property_getter child.
4819
4821 if (auto *F = getFile())
4822 return F->getFilename();
4823 return "";
4824 }
4825
4827 if (auto *F = getFile())
4828 return F->getDirectory();
4829 return "";
4830 }
4831
4833 Metadata *getRawFile() const { return getOperand(1); }
4834 Metadata *getRawType() const { return getOperand(2); }
4836
4837 static bool classof(const Metadata *MD) {
4838 return MD->getMetadataID() == DIPropertyKind;
4839 }
4840};
4841
4842/// An imported module (C++ using directive or similar).
4843///
4844/// Uses the SubclassData32 Metadata slot.
4845class DIImportedEntity : public DINode {
4846 friend class LLVMContextImpl;
4847 friend class MDNode;
4848
4849 DIImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
4850 unsigned Line, ArrayRef<Metadata *> Ops)
4851 : DINode(C, DIImportedEntityKind, Storage, Tag, Ops) {
4853 }
4854 ~DIImportedEntity() = default;
4855
4856 static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
4857 DIScope *Scope, DINode *Entity, DIFile *File,
4858 unsigned Line, StringRef Name,
4859 DINodeArray Elements, StorageType Storage,
4860 bool ShouldCreate = true) {
4861 return getImpl(Context, Tag, Scope, Entity, File, Line,
4862 getCanonicalMDString(Context, Name), Elements.get(), Storage,
4863 ShouldCreate);
4864 }
4865 LLVM_ABI static DIImportedEntity *
4866 getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, Metadata *Entity,
4867 Metadata *File, unsigned Line, MDString *Name, Metadata *Elements,
4868 StorageType Storage, bool ShouldCreate = true);
4869
4870 TempDIImportedEntity cloneImpl() const {
4871 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
4872 getFile(), getLine(), getName(), getElements());
4873 }
4874
4875public:
4876 DEFINE_MDNODE_GET(DIImportedEntity,
4877 (unsigned Tag, DIScope *Scope, DINode *Entity, DIFile *File,
4878 unsigned Line, StringRef Name = "",
4879 DINodeArray Elements = nullptr),
4880 (Tag, Scope, Entity, File, Line, Name, Elements))
4881 DEFINE_MDNODE_GET(DIImportedEntity,
4884 Metadata *Elements = nullptr),
4885 (Tag, Scope, Entity, File, Line, Name, Elements))
4886
4887 TempDIImportedEntity clone() const { return cloneImpl(); }
4888
4889 unsigned getLine() const { return SubclassData32; }
4890 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
4891 DINode *getEntity() const { return cast_or_null<DINode>(getRawEntity()); }
4892 StringRef getName() const { return getStringOperand(2); }
4893 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
4894 DINodeArray getElements() const {
4895 return cast_or_null<MDTuple>(getRawElements());
4896 }
4897
4898 Metadata *getRawScope() const { return getOperand(0); }
4899 Metadata *getRawEntity() const { return getOperand(1); }
4900 MDString *getRawName() const { return getOperandAs<MDString>(2); }
4901 Metadata *getRawFile() const { return getOperand(3); }
4902 Metadata *getRawElements() const { return getOperand(4); }
4903
4904 static bool classof(const Metadata *MD) {
4905 return MD->getMetadataID() == DIImportedEntityKind;
4906 }
4907};
4908
4909/// A pair of DIGlobalVariable and DIExpression.
4910class DIGlobalVariableExpression : public MDNode {
4911 friend class LLVMContextImpl;
4912 friend class MDNode;
4913
4914 DIGlobalVariableExpression(LLVMContext &C, StorageType Storage,
4916 : MDNode(C, DIGlobalVariableExpressionKind, Storage, Ops) {}
4917 ~DIGlobalVariableExpression() = default;
4918
4920 getImpl(LLVMContext &Context, Metadata *Variable, Metadata *Expression,
4921 StorageType Storage, bool ShouldCreate = true);
4922
4923 TempDIGlobalVariableExpression cloneImpl() const {
4925 }
4926
4927public:
4928 DEFINE_MDNODE_GET(DIGlobalVariableExpression,
4929 (Metadata * Variable, Metadata *Expression),
4930 (Variable, Expression))
4931
4932 TempDIGlobalVariableExpression clone() const { return cloneImpl(); }
4933
4934 Metadata *getRawVariable() const { return getOperand(0); }
4935
4939
4940 Metadata *getRawExpression() const { return getOperand(1); }
4941
4945
4946 static bool classof(const Metadata *MD) {
4947 return MD->getMetadataID() == DIGlobalVariableExpressionKind;
4948 }
4949};
4950
4951/// Macro Info DWARF-like metadata node.
4952///
4953/// A metadata node with a DWARF macro info (i.e., a constant named
4954/// \c DW_MACINFO_*, defined in llvm/BinaryFormat/Dwarf.h). Called \a
4955/// DIMacroNode
4956/// because it's potentially used for non-DWARF output.
4957///
4958/// Uses the SubclassData16 Metadata slot.
4959class DIMacroNode : public MDNode {
4960 friend class LLVMContextImpl;
4961 friend class MDNode;
4962
4963protected:
4964 DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType,
4966 : MDNode(C, ID, Storage, Ops1, Ops2) {
4967 assert(MIType < 1u << 16);
4968 SubclassData16 = MIType;
4969 }
4970 ~DIMacroNode() = default;
4971
4972 template <class Ty> Ty *getOperandAs(unsigned I) const {
4973 return cast_or_null<Ty>(getOperand(I));
4974 }
4975
4976 StringRef getStringOperand(unsigned I) const {
4977 if (auto *S = getOperandAs<MDString>(I))
4978 return S->getString();
4979 return StringRef();
4980 }
4981
4983 if (S.empty())
4984 return nullptr;
4985 return MDString::get(Context, S);
4986 }
4987
4988public:
4989 unsigned getMacinfoType() const { return SubclassData16; }
4990
4991 static bool classof(const Metadata *MD) {
4992 switch (MD->getMetadataID()) {
4993 default:
4994 return false;
4995 case DIMacroKind:
4996 case DIMacroFileKind:
4997 return true;
4998 }
4999 }
5000};
5001
5002/// Macro
5003///
5004/// Uses the SubclassData32 Metadata slot.
5005class DIMacro : public DIMacroNode {
5006 friend class LLVMContextImpl;
5007 friend class MDNode;
5008
5009 DIMacro(LLVMContext &C, StorageType Storage, unsigned MIType, unsigned Line,
5011 : DIMacroNode(C, DIMacroKind, Storage, MIType, Ops) {
5013 }
5014 ~DIMacro() = default;
5015
5016 static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
5018 bool ShouldCreate = true) {
5019 return getImpl(Context, MIType, Line, getCanonicalMDString(Context, Name),
5020 getCanonicalMDString(Context, Value), Storage, ShouldCreate);
5021 }
5022 LLVM_ABI static DIMacro *getImpl(LLVMContext &Context, unsigned MIType,
5023 unsigned Line, MDString *Name,
5024 MDString *Value, StorageType Storage,
5025 bool ShouldCreate = true);
5026
5027 TempDIMacro cloneImpl() const {
5029 getValue());
5030 }
5031
5032public:
5034 (unsigned MIType, unsigned Line, StringRef Name,
5035 StringRef Value = ""),
5036 (MIType, Line, Name, Value))
5037 DEFINE_MDNODE_GET(DIMacro,
5038 (unsigned MIType, unsigned Line, MDString *Name,
5041
5042 TempDIMacro clone() const { return cloneImpl(); }
5043
5044 unsigned getLine() const { return SubclassData32; }
5045
5046 StringRef getName() const { return getStringOperand(0); }
5047 StringRef getValue() const { return getStringOperand(1); }
5048
5051
5052 static bool classof(const Metadata *MD) {
5053 return MD->getMetadataID() == DIMacroKind;
5054 }
5055};
5056
5057/// Macro file
5058///
5059/// Uses the SubclassData32 Metadata slot.
5060class DIMacroFile : public DIMacroNode {
5061 friend class LLVMContextImpl;
5062 friend class MDNode;
5063
5064 DIMacroFile(LLVMContext &C, StorageType Storage, unsigned MIType,
5065 unsigned Line, ArrayRef<Metadata *> Ops)
5066 : DIMacroNode(C, DIMacroFileKind, Storage, MIType, Ops) {
5068 }
5069 ~DIMacroFile() = default;
5070
5071 static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
5072 unsigned Line, DIFile *File,
5073 DIMacroNodeArray Elements, StorageType Storage,
5074 bool ShouldCreate = true) {
5075 return getImpl(Context, MIType, Line, static_cast<Metadata *>(File),
5076 Elements.get(), Storage, ShouldCreate);
5077 }
5078
5079 LLVM_ABI static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
5080 unsigned Line, Metadata *File,
5082 bool ShouldCreate = true);
5083
5084 TempDIMacroFile cloneImpl() const {
5086 getElements());
5087 }
5088
5089public:
5091 (unsigned MIType, unsigned Line, DIFile *File,
5092 DIMacroNodeArray Elements),
5093 (MIType, Line, File, Elements))
5094 DEFINE_MDNODE_GET(DIMacroFile,
5095 (unsigned MIType, unsigned Line, Metadata *File,
5098
5099 TempDIMacroFile clone() const { return cloneImpl(); }
5100
5101 void replaceElements(DIMacroNodeArray Elements) {
5102#ifndef NDEBUG
5103 for (DIMacroNode *Op : getElements())
5104 assert(is_contained(Elements->operands(), Op) &&
5105 "Lost a macro node during macro node list replacement");
5106#endif
5107 replaceOperandWith(1, Elements.get());
5108 }
5109
5110 unsigned getLine() const { return SubclassData32; }
5112
5113 DIMacroNodeArray getElements() const {
5115 }
5116
5117 Metadata *getRawFile() const { return getOperand(0); }
5118 Metadata *getRawElements() const { return getOperand(1); }
5119
5120 static bool classof(const Metadata *MD) {
5121 return MD->getMetadataID() == DIMacroFileKind;
5122 }
5123};
5124
5125/// List of ValueAsMetadata, to be used as an argument to a dbg.value
5126/// intrinsic.
5127class DIArgList : public Metadata, ReplaceableUsesWithContext {
5128 friend class ReplaceableUses;
5129 friend class LLVMContextImpl;
5131
5133
5134 DIArgList(LLVMContext &Context, ArrayRef<ValueAsMetadata *> Args)
5135 : Metadata(DIArgListKind, Uniqued), ReplaceableUsesWithContext(Context),
5136 Args(Args) {
5137 track();
5138 }
5139 ~DIArgList() { untrack(); }
5140
5141 LLVM_ABI void track();
5142 LLVM_ABI void untrack();
5143 void dropAllReferences(bool Untrack);
5144
5145public:
5146 LLVM_ABI static DIArgList *get(LLVMContext &Context,
5148
5149 ArrayRef<ValueAsMetadata *> getArgs() const { return Args; }
5150
5151 iterator args_begin() { return Args.begin(); }
5152 iterator args_end() { return Args.end(); }
5153
5154 static bool classof(const Metadata *MD) {
5155 return MD->getMetadataID() == DIArgListKind;
5156 }
5157
5161
5162 LLVM_ABI void handleChangedOperand(void *Ref, Metadata *New);
5163};
5164
5165/// Identifies a unique instance of a variable.
5166///
5167/// Storage for identifying a potentially inlined instance of a variable,
5168/// or a fragment thereof. This guarantees that exactly one variable instance
5169/// may be identified by this class, even when that variable is a fragment of
5170/// an aggregate variable and/or there is another inlined instance of the same
5171/// source code variable nearby.
5172/// This class does not necessarily uniquely identify that variable: it is
5173/// possible that a DebugVariable with different parameters may point to the
5174/// same variable instance, but not that one DebugVariable points to multiple
5175/// variable instances.
5177 using FragmentInfo = DIExpression::FragmentInfo;
5178
5179 const DILocalVariable *Variable;
5180 std::optional<FragmentInfo> Fragment;
5181 const DILocation *InlinedAt;
5182
5183 /// Fragment that will overlap all other fragments. Used as default when
5184 /// caller demands a fragment.
5185 LLVM_ABI static const FragmentInfo DefaultFragment;
5186
5187public:
5189
5191 std::optional<FragmentInfo> FragmentInfo,
5192 const DILocation *InlinedAt)
5193 : Variable(Var), Fragment(FragmentInfo), InlinedAt(InlinedAt) {}
5194
5195 DebugVariable(const DILocalVariable *Var, const DIExpression *DIExpr,
5196 const DILocation *InlinedAt)
5197 : Variable(Var),
5198 Fragment(DIExpr ? DIExpr->getFragmentInfo() : std::nullopt),
5199 InlinedAt(InlinedAt) {}
5200
5201 const DILocalVariable *getVariable() const { return Variable; }
5202 std::optional<FragmentInfo> getFragment() const { return Fragment; }
5203 const DILocation *getInlinedAt() const { return InlinedAt; }
5204
5205 FragmentInfo getFragmentOrDefault() const {
5206 return Fragment.value_or(DefaultFragment);
5207 }
5208
5209 static bool isDefaultFragment(const FragmentInfo F) {
5210 return F == DefaultFragment;
5211 }
5212
5213 bool operator==(const DebugVariable &Other) const {
5214 return std::tie(Variable, Fragment, InlinedAt) ==
5215 std::tie(Other.Variable, Other.Fragment, Other.InlinedAt);
5216 }
5217
5218 bool operator<(const DebugVariable &Other) const {
5219 return std::tie(Variable, Fragment, InlinedAt) <
5220 std::tie(Other.Variable, Other.Fragment, Other.InlinedAt);
5221 }
5222};
5223
5224template <> struct DenseMapInfo<DebugVariable> {
5226
5227 static unsigned getHashValue(const DebugVariable &D) {
5228 unsigned HV = 0;
5229 const std::optional<FragmentInfo> Fragment = D.getFragment();
5230 if (Fragment)
5232
5233 return hash_combine(D.getVariable(), HV, D.getInlinedAt());
5234 }
5235
5236 static bool isEqual(const DebugVariable &A, const DebugVariable &B) {
5237 return A == B;
5238 }
5239};
5240
5241/// Identifies a unique instance of a whole variable (discards/ignores fragment
5242/// information).
5249
5250template <>
5252 : public DenseMapInfo<DebugVariable> {};
5253
5254template <typename NodeT> static const DIScope *getScope(const NodeT *N) {
5255 return N->getScope();
5256}
5257
5258template <typename NodeT> static DIScope *getScope(NodeT *N) {
5259 return N->getScope();
5260}
5261
5262template <>
5263[[maybe_unused]] const DIScope *
5265 return N->getVariable()->getScope();
5266}
5267template <>
5269 return N->getVariable()->getScope();
5270}
5271} // end namespace llvm
5272
5273#undef DEFINE_MDNODE_GET_UNPACK_IMPL
5274#undef DEFINE_MDNODE_GET_UNPACK
5275#undef DEFINE_MDNODE_GET
5276
5277#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 ExtOps getExtOps(unsigned FromSize, unsigned ToSize, bool Signed)
Returns the ops for a zero- or sign-extension in a DIExpression.
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
LLVM_ABI bool extractIfOffset(int64_t &Offset) const
If this is a constant offset, extract it.
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
DbgVariableFragmentInfo FragmentInfo
int fragmentCmp(const DIExpression *Other) const
Determine the relative position of the fragments described by this DIExpression and Other.
LLVM_ABI bool startsWithDeref() const
Return whether the first element a DW_OP_deref.
static LLVM_ABI bool isEqualExpression(const DIExpression *FirstExpr, bool FirstIndirect, const DIExpression *SecondExpr, bool SecondIndirect)
Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpres...
expr_op_iterator expr_op_end() const
LLVM_ABI bool isImplicit() const
Return whether this is an implicit location description.
DEFINE_MDNODE_GET(DIExpression,(ArrayRef< uint64_t > Elements),(Elements)) TempDIExpression clone() const
static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B)
Check if fragments overlap between a pair of FragmentInfos.
static LLVM_ABI bool calculateFragmentIntersect(const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits, int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag, std::optional< DIExpression::FragmentInfo > &Result, int64_t &OffsetFromLocationInBits)
Computes a fragment, bit-extract operation if needed, and new constant offset to describe a part of a...
element_iterator elements_begin() const
LLVM_ABI bool hasAllLocationOps(unsigned N) const
Returns true iff this DIExpression contains at least one instance of DW_OP_LLVM_arg,...
std::optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
static LLVM_ABI DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
PrependOps
Used for DIExpression::prepend.
static int fragmentCmp(const FragmentInfo &A, const FragmentInfo &B)
Determine the relative position of the fragments passed in.
LLVM_ABI bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
bool fragmentsOverlap(const DIExpression *Other) const
Check if fragments overlap between this DIExpression and Other.
LLVM_ABI DIExpression * foldConstantMath()
Try to shorten an expression with constant math operations that can be evaluated at compile time.
static LLVM_ABI std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
LLVM_ABI std::pair< DIExpression *, const ConstantInt * > constantFold(const ConstantInt *CI)
Try to shorten an expression with an initial constant operand.
LLVM_ABI bool isDeref() const
Return whether there is exactly one operator and it is a DW_OP_deref;.
static LLVM_ABI const DIExpression * convertToVariadicExpression(const DIExpression *Expr)
If Expr is a non-variadic expression (i.e.
LLVM_ABI uint64_t getNumLocationOperands() const
Return the number of unique location operands referred to (via DW_OP_LLVM_arg) in this expression; th...
ArrayRef< uint64_t > getElements() const
static LLVM_ABI DIExpression * replaceArg(const DIExpression *Expr, uint64_t OldArg, uint64_t NewArg)
Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg,...
static bool classof(const Metadata *MD)
LLVM_ABI std::optional< uint64_t > getActiveBits(DIVariable *Var)
Return the number of bits that have an active value, i.e.
static LLVM_ABI void canonicalizeExpressionOps(SmallVectorImpl< uint64_t > &Ops, const DIExpression *Expr, bool IsIndirect)
Inserts the elements of Expr into Ops modified to a canonical form, which uses DW_OP_LLVM_arg (i....
uint64_t getElement(unsigned I) const
static LLVM_ABI 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 last 4 elements of the expression are DW_OP_constu <DWARFAddress Space> DW_OP_swap DW_O...
static LLVM_ABI DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
static bool classof(const Metadata *MD)
MDString MDString * Directory
MDString MDString std::optional< ChecksumInfo< MDString * > > MDString * Source
DEFINE_MDNODE_GET(DIFile,(StringRef Filename, StringRef Directory, std::optional< ChecksumInfo< StringRef > > CS=std::nullopt, std::optional< StringRef > Source=std::nullopt),(Filename, Directory, CS, Source)) DEFINE_MDNODE_GET(DIFile
MDString * Filename
static LLVM_ABI std::optional< ChecksumKind > getChecksumKind(StringRef CSKindStr)
ChecksumKind
Which algorithm (e.g.
friend class LLVMContextImpl
friend class MDNode
MDString MDString std::optional< ChecksumInfo< MDString * > > CS
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
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