LLVM 24.0.0git
LLVMContextImpl.h
Go to the documentation of this file.
1//===- LLVMContextImpl.h - The LLVMContextImpl opaque class -----*- 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// This file declares LLVMContextImpl, the opaque implementation
10// of LLVMContext.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_IR_LLVMCONTEXTIMPL_H
15#define LLVM_LIB_IR_LLVMCONTEXTIMPL_H
16
17#include "AttributeImpl.h"
18#include "ConstantsContext.h"
19#include "llvm/ADT/APFloat.h"
20#include "llvm/ADT/APInt.h"
21#include "llvm/ADT/ArrayRef.h"
22#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/DenseSet.h"
25#include "llvm/ADT/FoldingSet.h"
26#include "llvm/ADT/Hashing.h"
27#include "llvm/ADT/STLExtras.h"
30#include "llvm/ADT/StringMap.h"
32#include "llvm/IR/Constants.h"
35#include "llvm/IR/LLVMContext.h"
36#include "llvm/IR/Metadata.h"
37#include "llvm/IR/Module.h"
39#include "llvm/IR/Type.h"
40#include "llvm/IR/Value.h"
44#include <algorithm>
45#include <cassert>
46#include <cstddef>
47#include <cstdint>
48#include <memory>
49#include <optional>
50#include <string>
51#include <utility>
52#include <vector>
53
54namespace llvm {
55
56class BasicBlock;
58class DbgMarker;
59class ElementCount;
60class Function;
61class GlobalObject;
62class GlobalValue;
63class InlineAsm;
65class OptPassGate;
66namespace remarks {
67class RemarkStreamer;
68}
69template <typename T> class StringMapEntry;
70class StringRef;
72class ValueHandleBase;
73
74template <> struct DenseMapInfo<APFloat> {
75 static unsigned getHashValue(const APFloat &Key) {
76 return static_cast<unsigned>(hash_value(Key));
77 }
78
79 static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
80 return LHS.bitwiseIsEqual(RHS);
81 }
82};
83
85 struct KeyTy {
88
89 KeyTy(const ArrayRef<Type *> &E, bool P) : ETypes(E), isPacked(P) {}
90
91 KeyTy(const StructType *ST)
92 : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
93
94 bool operator==(const KeyTy &that) const {
95 if (isPacked != that.isPacked)
96 return false;
97 if (ETypes != that.ETypes)
98 return false;
99 return true;
100 }
101 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
102 };
103
104 static unsigned getHashValue(const KeyTy &Key) {
105 return hash_combine(hash_combine_range(Key.ETypes), Key.isPacked);
106 }
107
108 static unsigned getHashValue(const StructType *ST) {
109 return getHashValue(KeyTy(ST));
110 }
111
112 static bool isEqual(const KeyTy &LHS, const StructType *RHS) {
113 return LHS == KeyTy(RHS);
114 }
115
116 static bool isEqual(const StructType *LHS, const StructType *RHS) {
117 return LHS == RHS;
118 }
119};
120
122 struct KeyTy {
126
127 KeyTy(const Type *R, const ArrayRef<Type *> &P, bool V)
128 : ReturnType(R), Params(P), isVarArg(V) {}
130 : ReturnType(FT->getReturnType()), Params(FT->params()),
131 isVarArg(FT->isVarArg()) {}
132
133 bool operator==(const KeyTy &that) const {
134 if (ReturnType != that.ReturnType)
135 return false;
136 if (isVarArg != that.isVarArg)
137 return false;
138 if (Params != that.Params)
139 return false;
140 return true;
141 }
142 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
143 };
144
145 static unsigned getHashValue(const KeyTy &Key) {
146 return hash_combine(Key.ReturnType, hash_combine_range(Key.Params),
147 Key.isVarArg);
148 }
149
150 static unsigned getHashValue(const FunctionType *FT) {
151 return getHashValue(KeyTy(FT));
152 }
153
154 static bool isEqual(const KeyTy &LHS, const FunctionType *RHS) {
155 return LHS == KeyTy(RHS);
156 }
157
158 static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
159 return LHS == RHS;
160 }
161};
162
164 struct KeyTy {
168
170 : Name(N), TypeParams(TP), IntParams(IP) {}
172 : Name(TT->getName()), TypeParams(TT->type_params()),
173 IntParams(TT->int_params()) {}
174
175 bool operator==(const KeyTy &that) const {
176 return Name == that.Name && TypeParams == that.TypeParams &&
177 IntParams == that.IntParams;
178 }
179 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
180 };
181
182 static unsigned getHashValue(const KeyTy &Key) {
183 return hash_combine(Key.Name, hash_combine_range(Key.TypeParams),
184 hash_combine_range(Key.IntParams));
185 }
186
187 static unsigned getHashValue(const TargetExtType *FT) {
188 return getHashValue(KeyTy(FT));
189 }
190
191 static bool isEqual(const KeyTy &LHS, const TargetExtType *RHS) {
192 return LHS == KeyTy(RHS);
193 }
194
195 static bool isEqual(const TargetExtType *LHS, const TargetExtType *RHS) {
196 return LHS == RHS;
197 }
198};
199
200/// Structure for hashing arbitrary MDNode operands.
204 unsigned Hash;
205
206protected:
208 : RawOps(Ops), Hash(calculateHash(Ops)) {}
209
210 template <class NodeTy>
211 MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
212 : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
213
214 template <class NodeTy>
215 bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
216 if (getHash() != RHS->getHash())
217 return false;
218
219 assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
220 return RawOps.empty() ? compareOps(Ops, RHS, Offset)
221 : compareOps(RawOps, RHS, Offset);
222 }
223
224 static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
225
226private:
227 template <class T>
228 static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
229 if (Ops.size() != RHS->getNumOperands() - Offset)
230 return false;
231 return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
232 }
233
234 static unsigned calculateHash(ArrayRef<Metadata *> Ops);
235
236public:
237 unsigned getHash() const { return Hash; }
238};
239
240template <class NodeTy> struct MDNodeKeyImpl;
241
242/// Configuration point for MDNodeInfo::isEqual().
243template <class NodeTy> struct MDNodeSubsetEqualImpl {
245
246 static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) {
247 return false;
248 }
249
250 static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) {
251 return false;
252 }
253};
254
255/// DenseMapInfo for MDTuple.
256///
257/// Note that we don't need the is-function-local bit, since that's implicit in
258/// the operands.
259template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
262
263 bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
264
265 unsigned getHashValue() const { return getHash(); }
266
267 static unsigned calculateHash(MDTuple *N) {
269 }
270};
271
272/// DenseMapInfo for DILocation.
273template <> struct MDNodeKeyImpl<DILocation> {
278 unsigned Line;
281
288
290 : Scope(L->getRawScope()), InlinedAt(L->getRawInlinedAt()),
291 AtomGroup(L->getAtomGroup()), AtomRank(L->getAtomRank()),
292 Line(L->getLine()), Column(L->getColumn()),
293 ImplicitCode(L->isImplicitCode()) {}
294
295 bool isKeyOf(const DILocation *RHS) const {
296 return Line == RHS->getLine() && Column == RHS->getColumn() &&
297 Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt() &&
298 ImplicitCode == RHS->isImplicitCode() &&
299 AtomGroup == RHS->getAtomGroup() && AtomRank == RHS->getAtomRank();
300 }
301
302 unsigned getHashValue() const {
303 uint64_t LineColumnAndImplicitCode =
304 Line | (uint64_t(Column) << 32) | (uint64_t(ImplicitCode) << 48);
305 // Hashing AtomGroup and AtomRank substantially impacts performance whether
306 // Key Instructions is enabled or not. We can't detect whether it's enabled
307 // here cheaply; avoiding hashing zero values is a good approximation. This
308 // affects Key Instruction builds too, but any potential costs incurred by
309 // messing with the hash distribution* appear to still be massively
310 // outweighed by the overall compile time savings by performing this check.
311 // * (hash_combine(x) != hash_combine(x, 0))
312 if (AtomGroup || AtomRank)
313 return hash_combine(LineColumnAndImplicitCode, Scope, InlinedAt,
314 AtomGroup | (uint64_t(AtomRank) << 61));
315 return hash_combine(LineColumnAndImplicitCode, Scope, InlinedAt);
316 }
317};
318
319/// DenseMapInfo for GenericDINode.
321 unsigned Tag;
323
325 : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
327 : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {}
328
329 bool isKeyOf(const GenericDINode *RHS) const {
330 return Tag == RHS->getTag() && Header == RHS->getRawHeader() &&
331 compareOps(RHS, 1);
332 }
333
334 unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
335
336 static unsigned calculateHash(GenericDINode *N) {
338 }
339};
340
341template <> struct MDNodeKeyImpl<DISubrange> {
346
352 : CountNode(N->getRawCountNode()), LowerBound(N->getRawLowerBound()),
353 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()) {}
354
355 bool isKeyOf(const DISubrange *RHS) const {
356 auto BoundsEqual = [=](Metadata *Node1, Metadata *Node2) -> bool {
357 if (Node1 == Node2)
358 return true;
359
362 if (MD1 && MD2) {
365 if (CV1->getSExtValue() == CV2->getSExtValue())
366 return true;
367 }
368 return false;
369 };
370
371 return BoundsEqual(CountNode, RHS->getRawCountNode()) &&
372 BoundsEqual(LowerBound, RHS->getRawLowerBound()) &&
373 BoundsEqual(UpperBound, RHS->getRawUpperBound()) &&
374 BoundsEqual(Stride, RHS->getRawStride());
375 }
376
377 unsigned getHashValue() const {
378 if (CountNode)
380 return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
383 }
384};
385
386template <> struct MDNodeKeyImpl<DIGenericSubrange> {
391
397 : CountNode(N->getRawCountNode()), LowerBound(N->getRawLowerBound()),
398 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()) {}
399
400 bool isKeyOf(const DIGenericSubrange *RHS) const {
401 return (CountNode == RHS->getRawCountNode()) &&
402 (LowerBound == RHS->getRawLowerBound()) &&
403 (UpperBound == RHS->getRawUpperBound()) &&
404 (Stride == RHS->getRawStride());
405 }
406
407 unsigned getHashValue() const {
409 if (CountNode && MD)
410 return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
413 }
414};
415
416template <> struct MDNodeKeyImpl<DIEnumerator> {
420
427 : Value(N->getValue()), Name(N->getRawName()),
428 IsUnsigned(N->isUnsigned()) {}
429
430 bool isKeyOf(const DIEnumerator *RHS) const {
431 return Value.getBitWidth() == RHS->getValue().getBitWidth() &&
432 Value == RHS->getValue() && IsUnsigned == RHS->isUnsigned() &&
433 Name == RHS->getRawName();
434 }
435
436 unsigned getHashValue() const { return hash_combine(Value, Name); }
437};
438
439template <> struct MDNodeKeyImpl<DIBasicType> {
440 unsigned Tag;
443 unsigned LineNo;
447 unsigned Encoding;
450 unsigned Flags;
451
461 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
462 LineNo(N->getLine()), Scope(N->getRawScope()),
463 SizeInBits(N->getRawSizeInBits()), AlignInBits(N->getAlignInBits()),
464 Encoding(N->getEncoding()),
465 NumExtraInhabitants(N->getNumExtraInhabitants()),
466 DataSizeInBits(N->getDataSizeInBits()), Flags(N->getFlags()) {}
467
468 bool isKeyOf(const DIBasicType *RHS) const {
469 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
470 File == RHS->getRawFile() && LineNo == RHS->getLine() &&
471 Scope == RHS->getRawScope() &&
472 SizeInBits == RHS->getRawSizeInBits() &&
473 AlignInBits == RHS->getAlignInBits() &&
474 Encoding == RHS->getEncoding() &&
475 NumExtraInhabitants == RHS->getNumExtraInhabitants() &&
476 DataSizeInBits == RHS->getDataSizeInBits() &&
477 Flags == RHS->getFlags();
478 }
479
480 unsigned getHashValue() const {
482 Encoding);
483 }
484};
485
486template <> struct MDNodeKeyImpl<DIFixedPointType> {
487 unsigned Tag;
490 unsigned LineNo;
494 unsigned Encoding;
495 unsigned Flags;
496 unsigned Kind;
500
510 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
511 LineNo(N->getLine()), Scope(N->getRawScope()),
512 SizeInBits(N->getRawSizeInBits()), AlignInBits(N->getAlignInBits()),
513 Encoding(N->getEncoding()), Flags(N->getFlags()), Kind(N->getKind()),
514 Factor(N->getFactorRaw()), Numerator(N->getNumeratorRaw()),
515 Denominator(N->getDenominatorRaw()) {}
516
517 bool isKeyOf(const DIFixedPointType *RHS) const {
518 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
519 LineNo == RHS->getLine() && Scope == RHS->getRawScope() &&
520 SizeInBits == RHS->getRawSizeInBits() &&
521 AlignInBits == RHS->getAlignInBits() && Kind == RHS->getKind() &&
522 (RHS->isRational() ? (Numerator == RHS->getNumerator() &&
523 Denominator == RHS->getDenominator())
524 : Factor == RHS->getFactor());
525 }
526
527 unsigned getHashValue() const {
530 }
531};
532
533template <> struct MDNodeKeyImpl<DIStringType> {
534 unsigned Tag;
541 unsigned Encoding;
542
550 : Tag(N->getTag()), Name(N->getRawName()),
551 StringLength(N->getRawStringLength()),
552 StringLengthExp(N->getRawStringLengthExp()),
553 StringLocationExp(N->getRawStringLocationExp()),
554 SizeInBits(N->getRawSizeInBits()), AlignInBits(N->getAlignInBits()),
555 Encoding(N->getEncoding()) {}
556
557 bool isKeyOf(const DIStringType *RHS) const {
558 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
559 StringLength == RHS->getRawStringLength() &&
560 StringLengthExp == RHS->getRawStringLengthExp() &&
561 StringLocationExp == RHS->getRawStringLocationExp() &&
562 SizeInBits == RHS->getRawSizeInBits() &&
563 AlignInBits == RHS->getAlignInBits() &&
564 Encoding == RHS->getEncoding();
565 }
566 unsigned getHashValue() const {
567 // Intentionally computes the hash on a subset of the operands for
568 // performance reason. The subset has to be significant enough to avoid
569 // collision "most of the time". There is no correctness issue in case of
570 // collision because of the full check above.
572 }
573};
574
575template <> struct MDNodeKeyImpl<DIDerivedType> {
576 unsigned Tag;
577 MDString *Name;
578 Metadata *File;
579 unsigned Line;
580 Metadata *Scope;
582 Metadata *SizeInBits;
583 Metadata *OffsetInBits;
584 uint32_t AlignInBits;
585 std::optional<unsigned> DWARFAddressSpace;
586 std::optional<DIDerivedType::PtrAuthData> PtrAuthData;
587 unsigned Flags;
589 Metadata *Annotations;
590
591 MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
592 Metadata *Scope, Metadata *BaseType, Metadata *SizeInBits,
593 uint32_t AlignInBits, Metadata *OffsetInBits,
594 std::optional<unsigned> DWARFAddressSpace,
595 std::optional<DIDerivedType::PtrAuthData> PtrAuthData,
596 unsigned Flags, Metadata *ExtraData, Metadata *Annotations)
597 : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
598 BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
599 AlignInBits(AlignInBits), DWARFAddressSpace(DWARFAddressSpace),
600 PtrAuthData(PtrAuthData), Flags(Flags), ExtraData(ExtraData),
601 Annotations(Annotations) {}
602 MDNodeKeyImpl(const DIDerivedType *N)
603 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
604 Line(N->getLine()), Scope(N->getRawScope()),
605 BaseType(N->getRawBaseType()), SizeInBits(N->getRawSizeInBits()),
606 OffsetInBits(N->getRawOffsetInBits()), AlignInBits(N->getAlignInBits()),
607 DWARFAddressSpace(N->getDWARFAddressSpace()),
608 PtrAuthData(N->getPtrAuthData()), Flags(N->getFlags()),
609 ExtraData(N->getRawExtraData()), Annotations(N->getRawAnnotations()) {}
610
611 bool isKeyOf(const DIDerivedType *RHS) const {
612 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
613 File == RHS->getRawFile() && Line == RHS->getLine() &&
614 Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
615 SizeInBits == RHS->getRawSizeInBits() &&
616 AlignInBits == RHS->getAlignInBits() &&
617 OffsetInBits == RHS->getRawOffsetInBits() &&
618 DWARFAddressSpace == RHS->getDWARFAddressSpace() &&
619 PtrAuthData == RHS->getPtrAuthData() && Flags == RHS->getFlags() &&
620 ExtraData == RHS->getRawExtraData() &&
621 Annotations == RHS->getRawAnnotations();
622 }
623
624 unsigned getHashValue() const {
625 // If this is a member inside an ODR type, only hash the type and the name.
626 // Otherwise the hash will be stronger than
627 // MDNodeSubsetEqualImpl::isODRMember().
628 if (Tag == dwarf::DW_TAG_member && Name)
629 if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
630 if (CT->getRawIdentifier())
631 return hash_combine(Name, Scope);
632
633 // Intentionally computes the hash on a subset of the operands for
634 // performance reason. The subset has to be significant enough to avoid
635 // collision "most of the time". There is no correctness issue in case of
636 // collision because of the full check above.
637 return hash_combine(Tag, Name, File, Line, Scope, BaseType, Flags);
638 }
639};
640
641template <> struct MDNodeKeyImpl<DISubrangeType> {
644 unsigned Line;
648 unsigned Flags;
654
664 : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
665 Scope(N->getRawScope()), SizeInBits(N->getRawSizeInBits()),
666 AlignInBits(N->getAlignInBits()), Flags(N->getFlags()),
667 BaseType(N->getRawBaseType()), LowerBound(N->getRawLowerBound()),
668 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()),
669 Bias(N->getRawBias()) {}
670
671 bool isKeyOf(const DISubrangeType *RHS) const {
672 auto BoundsEqual = [=](Metadata *Node1, Metadata *Node2) -> bool {
673 if (Node1 == Node2)
674 return true;
675
678 if (MD1 && MD2) {
681 if (CV1->getSExtValue() == CV2->getSExtValue())
682 return true;
683 }
684 return false;
685 };
686
687 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
688 Line == RHS->getLine() && Scope == RHS->getRawScope() &&
689 SizeInBits == RHS->getRawSizeInBits() &&
690 AlignInBits == RHS->getAlignInBits() && Flags == RHS->getFlags() &&
691 BaseType == RHS->getRawBaseType() &&
692 BoundsEqual(LowerBound, RHS->getRawLowerBound()) &&
693 BoundsEqual(UpperBound, RHS->getRawUpperBound()) &&
694 BoundsEqual(Stride, RHS->getRawStride()) &&
695 BoundsEqual(Bias, RHS->getRawBias());
696 }
697
698 unsigned getHashValue() const {
699 unsigned val = 0;
700 auto HashBound = [&](Metadata *Node) -> void {
702 if (MD) {
704 val = hash_combine(val, CV->getSExtValue());
705 } else {
706 val = hash_combine(val, Node);
707 }
708 };
709
710 HashBound(LowerBound);
711 HashBound(UpperBound);
712 HashBound(Stride);
713 HashBound(Bias);
714
715 return hash_combine(val, Name, File, Line, Scope, BaseType, Flags);
716 }
717};
718
721
722 static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS) {
723 return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
724 }
725
726 static bool isSubsetEqual(const DIDerivedType *LHS,
727 const DIDerivedType *RHS) {
728 return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
729 RHS);
730 }
731
732 /// Subprograms compare equal if they declare the same function in an ODR
733 /// type.
734 static bool isODRMember(unsigned Tag, const Metadata *Scope,
735 const MDString *Name, const DIDerivedType *RHS) {
736 // Check whether the LHS is eligible.
737 if (Tag != dwarf::DW_TAG_member || !Name)
738 return false;
739
740 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
741 if (!CT || !CT->getRawIdentifier())
742 return false;
743
744 // Compare to the RHS.
745 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
746 Scope == RHS->getRawScope();
747 }
748};
749
750template <> struct MDNodeKeyImpl<DICompositeType> {
751 unsigned Tag;
754 unsigned Line;
760 unsigned Flags;
762 unsigned RuntimeLang;
775
796 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
797 Line(N->getLine()), Scope(N->getRawScope()),
798 BaseType(N->getRawBaseType()), SizeInBits(N->getRawSizeInBits()),
799 OffsetInBits(N->getRawOffsetInBits()), AlignInBits(N->getAlignInBits()),
800 Flags(N->getFlags()), Elements(N->getRawElements()),
801 RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()),
802 TemplateParams(N->getRawTemplateParams()),
803 Identifier(N->getRawIdentifier()),
804 Discriminator(N->getRawDiscriminator()),
805 DataLocation(N->getRawDataLocation()),
806 Associated(N->getRawAssociated()), Allocated(N->getRawAllocated()),
807 Rank(N->getRawRank()), Annotations(N->getRawAnnotations()),
808 Specification(N->getSpecification()),
809 NumExtraInhabitants(N->getNumExtraInhabitants()),
810 BitStride(N->getRawBitStride()) {}
811
812 bool isKeyOf(const DICompositeType *RHS) const {
813 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
814 File == RHS->getRawFile() && Line == RHS->getLine() &&
815 Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
816 SizeInBits == RHS->getRawSizeInBits() &&
817 AlignInBits == RHS->getAlignInBits() &&
818 OffsetInBits == RHS->getRawOffsetInBits() &&
819 Flags == RHS->getFlags() && Elements == RHS->getRawElements() &&
820 RuntimeLang == RHS->getRuntimeLang() &&
821 VTableHolder == RHS->getRawVTableHolder() &&
822 TemplateParams == RHS->getRawTemplateParams() &&
823 Identifier == RHS->getRawIdentifier() &&
824 Discriminator == RHS->getRawDiscriminator() &&
825 DataLocation == RHS->getRawDataLocation() &&
826 Associated == RHS->getRawAssociated() &&
827 Allocated == RHS->getRawAllocated() && Rank == RHS->getRawRank() &&
828 Annotations == RHS->getRawAnnotations() &&
829 Specification == RHS->getSpecification() &&
830 NumExtraInhabitants == RHS->getNumExtraInhabitants() &&
831 BitStride == RHS->getRawBitStride();
832 }
833
834 unsigned getHashValue() const {
835 // Intentionally computes the hash on a subset of the operands for
836 // performance reason. The subset has to be significant enough to avoid
837 // collision "most of the time". There is no correctness issue in case of
838 // collision because of the full check above.
841 }
842};
843
844template <> struct MDNodeKeyImpl<DISubroutineType> {
845 unsigned Flags;
848
852 : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {}
853
854 bool isKeyOf(const DISubroutineType *RHS) const {
855 return Flags == RHS->getFlags() && CC == RHS->getCC() &&
856 TypeArray == RHS->getRawTypeArray();
857 }
858
859 unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); }
860};
861
862template <> struct MDNodeKeyImpl<DIFile> {
865 std::optional<DIFile::ChecksumInfo<MDString *>> Checksum;
867
874 : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
875 Checksum(N->getRawChecksum()), Source(N->getRawSource()) {}
876
877 bool isKeyOf(const DIFile *RHS) const {
878 return Filename == RHS->getRawFilename() &&
879 Directory == RHS->getRawDirectory() &&
880 Checksum == RHS->getRawChecksum() && Source == RHS->getRawSource();
881 }
882
883 unsigned getHashValue() const {
884 return hash_combine(Filename, Directory, Checksum ? Checksum->Kind : 0,
885 Checksum ? Checksum->Value : nullptr, Source);
886 }
887};
888
889template <> struct MDNodeKeyImpl<DISubprogram> {
890 Metadata *Scope;
891 MDString *Name;
892 MDString *LinkageName;
893 Metadata *File;
894 unsigned Line;
895 unsigned ScopeLine;
896 Metadata *Type;
897 Metadata *ContainingType;
898 unsigned VirtualIndex;
899 int ThisAdjustment;
900 unsigned Flags;
901 unsigned SPFlags;
902 Metadata *Unit;
903 Metadata *TemplateParams;
904 Metadata *Declaration;
905 Metadata *RetainedNodes;
906 Metadata *ThrownTypes;
907 Metadata *Annotations;
908 MDString *TargetFuncName;
909 bool UsesKeyInstructions;
910
911 MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
912 Metadata *File, unsigned Line, Metadata *Type,
913 unsigned ScopeLine, Metadata *ContainingType,
914 unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
915 unsigned SPFlags, Metadata *Unit, Metadata *TemplateParams,
916 Metadata *Declaration, Metadata *RetainedNodes,
917 Metadata *ThrownTypes, Metadata *Annotations,
918 MDString *TargetFuncName, bool UsesKeyInstructions)
919 : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
920 Line(Line), ScopeLine(ScopeLine), Type(Type),
921 ContainingType(ContainingType), VirtualIndex(VirtualIndex),
922 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags),
923 Unit(Unit), TemplateParams(TemplateParams), Declaration(Declaration),
924 RetainedNodes(RetainedNodes), ThrownTypes(ThrownTypes),
925 Annotations(Annotations), TargetFuncName(TargetFuncName),
926 UsesKeyInstructions(UsesKeyInstructions) {}
927 MDNodeKeyImpl(const DISubprogram *N)
928 : Scope(N->getRawScope()), Name(N->getRawName()),
929 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
930 Line(N->getLine()), ScopeLine(N->getScopeLine()), Type(N->getRawType()),
931 ContainingType(N->getRawContainingType()),
932 VirtualIndex(N->getVirtualIndex()),
933 ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()),
934 SPFlags(N->getSPFlags()), Unit(N->getRawUnit()),
935 TemplateParams(N->getRawTemplateParams()),
936 Declaration(N->getRawDeclaration()),
937 RetainedNodes(N->getRawRetainedNodes()),
938 ThrownTypes(N->getRawThrownTypes()),
939 Annotations(N->getRawAnnotations()),
940 TargetFuncName(N->getRawTargetFuncName()),
941 UsesKeyInstructions(N->getKeyInstructionsEnabled()) {}
942
943 bool isKeyOf(const DISubprogram *RHS) const {
944 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
945 LinkageName == RHS->getRawLinkageName() &&
946 File == RHS->getRawFile() && Line == RHS->getLine() &&
947 Type == RHS->getRawType() && ScopeLine == RHS->getScopeLine() &&
948 ContainingType == RHS->getRawContainingType() &&
949 VirtualIndex == RHS->getVirtualIndex() &&
950 ThisAdjustment == RHS->getThisAdjustment() &&
951 Flags == RHS->getFlags() && SPFlags == RHS->getSPFlags() &&
952 Unit == RHS->getUnit() &&
953 TemplateParams == RHS->getRawTemplateParams() &&
954 Declaration == RHS->getRawDeclaration() &&
955 RetainedNodes == RHS->getRawRetainedNodes() &&
956 ThrownTypes == RHS->getRawThrownTypes() &&
957 Annotations == RHS->getRawAnnotations() &&
958 TargetFuncName == RHS->getRawTargetFuncName() &&
959 UsesKeyInstructions == RHS->getKeyInstructionsEnabled();
960 }
961
962 bool isDefinition() const { return SPFlags & DISubprogram::SPFlagDefinition; }
963
964 unsigned getHashValue() const {
965 // Use the Scope's linkage name instead of using the scope directly, as the
966 // scope may be a temporary one which can replaced, which would produce a
967 // different hash for the same DISubprogram.
968 llvm::StringRef ScopeLinkageName;
969 if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
970 if (auto *ID = CT->getRawIdentifier())
971 ScopeLinkageName = ID->getString();
972
973 // If this is a declaration inside an ODR type, only hash the type and the
974 // name. Otherwise the hash will be stronger than
975 // MDNodeSubsetEqualImpl::isDeclarationOfODRMember().
976 if (!isDefinition() && LinkageName &&
978 return hash_combine(LinkageName, ScopeLinkageName);
979
980 // Intentionally computes the hash on a subset of the operands for
981 // performance reason. The subset has to be significant enough to avoid
982 // collision "most of the time". There is no correctness issue in case of
983 // collision because of the full check above.
984 return hash_combine(Name, ScopeLinkageName, File, Type, Line);
985 }
986};
987
990
991 static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
992 return isDeclarationOfODRMember(LHS.isDefinition(), LHS.Scope,
993 LHS.LinkageName, LHS.TemplateParams, RHS);
994 }
995
996 static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) {
997 return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(),
998 LHS->getRawLinkageName(),
999 LHS->getRawTemplateParams(), RHS);
1000 }
1001
1002 /// Subprograms compare equal if they declare the same function in an ODR
1003 /// type.
1004 static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope,
1005 const MDString *LinkageName,
1006 const Metadata *TemplateParams,
1007 const DISubprogram *RHS) {
1008 // Check whether the LHS is eligible.
1009 if (IsDefinition || !Scope || !LinkageName)
1010 return false;
1011
1012 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
1013 if (!CT || !CT->getRawIdentifier())
1014 return false;
1015
1016 // Compare to the RHS.
1017 // FIXME: We need to compare template parameters here to avoid incorrect
1018 // collisions in mapMetadata when RF_ReuseAndMutateDistinctMDs and a
1019 // ODR-DISubprogram has a non-ODR template parameter (i.e., a
1020 // DICompositeType that does not have an identifier). Eventually we should
1021 // decouple ODR logic from uniquing logic.
1022 return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() &&
1023 LinkageName == RHS->getRawLinkageName() &&
1024 TemplateParams == RHS->getRawTemplateParams();
1025 }
1026};
1027
1028template <> struct MDNodeKeyImpl<DILexicalBlock> {
1031 unsigned Line;
1032 unsigned Column;
1033
1037 : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
1038 Column(N->getColumn()) {}
1039
1040 bool isKeyOf(const DILexicalBlock *RHS) const {
1041 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
1042 Line == RHS->getLine() && Column == RHS->getColumn();
1043 }
1044
1045 unsigned getHashValue() const {
1046 return hash_combine(Scope, File, Line, Column);
1047 }
1048};
1049
1054
1058 : Scope(N->getRawScope()), File(N->getRawFile()),
1059 Discriminator(N->getDiscriminator()) {}
1060
1061 bool isKeyOf(const DILexicalBlockFile *RHS) const {
1062 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
1063 Discriminator == RHS->getDiscriminator();
1064 }
1065
1066 unsigned getHashValue() const {
1068 }
1069};
1070
1071template <> struct MDNodeKeyImpl<DINamespace> {
1075
1079 : Scope(N->getRawScope()), Name(N->getRawName()),
1080 ExportSymbols(N->getExportSymbols()) {}
1081
1082 bool isKeyOf(const DINamespace *RHS) const {
1083 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1084 ExportSymbols == RHS->getExportSymbols();
1085 }
1086
1087 unsigned getHashValue() const { return hash_combine(Scope, Name); }
1088};
1089
1090template <> struct MDNodeKeyImpl<DICommonBlock> {
1095 unsigned LineNo;
1096
1101 : Scope(N->getRawScope()), Decl(N->getRawDecl()), Name(N->getRawName()),
1102 File(N->getRawFile()), LineNo(N->getLineNo()) {}
1103
1104 bool isKeyOf(const DICommonBlock *RHS) const {
1105 return Scope == RHS->getRawScope() && Decl == RHS->getRawDecl() &&
1106 Name == RHS->getRawName() && File == RHS->getRawFile() &&
1107 LineNo == RHS->getLineNo();
1108 }
1109
1110 unsigned getHashValue() const {
1111 return hash_combine(Scope, Decl, Name, File, LineNo);
1112 }
1113};
1114
1115template <> struct MDNodeKeyImpl<DIModule> {
1122 unsigned LineNo;
1124
1132 : File(N->getRawFile()), Scope(N->getRawScope()), Name(N->getRawName()),
1133 ConfigurationMacros(N->getRawConfigurationMacros()),
1134 IncludePath(N->getRawIncludePath()),
1135 APINotesFile(N->getRawAPINotesFile()), LineNo(N->getLineNo()),
1136 IsDecl(N->getIsDecl()) {}
1137
1138 bool isKeyOf(const DIModule *RHS) const {
1139 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1140 ConfigurationMacros == RHS->getRawConfigurationMacros() &&
1141 IncludePath == RHS->getRawIncludePath() &&
1142 APINotesFile == RHS->getRawAPINotesFile() &&
1143 File == RHS->getRawFile() && LineNo == RHS->getLineNo() &&
1144 IsDecl == RHS->getIsDecl();
1145 }
1146
1147 unsigned getHashValue() const {
1149 }
1150};
1151
1156
1160 : Name(N->getRawName()), Type(N->getRawType()),
1161 IsDefault(N->isDefault()) {}
1162
1164 return Name == RHS->getRawName() && Type == RHS->getRawType() &&
1165 IsDefault == RHS->isDefault();
1166 }
1167
1168 unsigned getHashValue() const { return hash_combine(Name, Type, IsDefault); }
1169};
1170
1172 unsigned Tag;
1177
1182 : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
1183 IsDefault(N->isDefault()), Value(N->getValue()) {}
1184
1186 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
1187 Type == RHS->getRawType() && IsDefault == RHS->isDefault() &&
1188 Value == RHS->getValue();
1189 }
1190
1191 unsigned getHashValue() const {
1193 }
1194};
1195
1196template <> struct MDNodeKeyImpl<DIGlobalVariable> {
1201 unsigned Line;
1209
1222 : Scope(N->getRawScope()), Name(N->getRawName()),
1223 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
1224 Line(N->getLine()), Type(N->getRawType()),
1225 IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
1226 StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
1227 TemplateParams(N->getRawTemplateParams()),
1228 AlignInBits(N->getAlignInBits()), Annotations(N->getRawAnnotations()) {}
1229
1230 bool isKeyOf(const DIGlobalVariable *RHS) const {
1231 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1232 LinkageName == RHS->getRawLinkageName() &&
1233 File == RHS->getRawFile() && Line == RHS->getLine() &&
1234 Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
1235 IsDefinition == RHS->isDefinition() &&
1237 RHS->getRawStaticDataMemberDeclaration() &&
1238 TemplateParams == RHS->getRawTemplateParams() &&
1239 AlignInBits == RHS->getAlignInBits() &&
1240 Annotations == RHS->getRawAnnotations();
1241 }
1242
1243 unsigned getHashValue() const {
1244 // We do not use AlignInBits in hashing function here on purpose:
1245 // in most cases this param for local variable is zero (for function param
1246 // it is always zero). This leads to lots of hash collisions and errors on
1247 // cases with lots of similar variables.
1248 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
1249 // generated IR is random for each run and test fails with Align included.
1250 // TODO: make hashing work fine with such situations
1252 IsLocalToUnit, IsDefinition, /* AlignInBits, */
1254 }
1255};
1256
1257template <> struct MDNodeKeyImpl<DILocalVariable> {
1261 unsigned Line;
1263 unsigned Arg;
1264 unsigned Flags;
1267
1274 : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
1275 Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
1276 Flags(N->getFlags()), AlignInBits(N->getAlignInBits()),
1277 Annotations(N->getRawAnnotations()) {}
1278
1279 bool isKeyOf(const DILocalVariable *RHS) const {
1280 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1281 File == RHS->getRawFile() && Line == RHS->getLine() &&
1282 Type == RHS->getRawType() && Arg == RHS->getArg() &&
1283 Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits() &&
1284 Annotations == RHS->getRawAnnotations();
1285 }
1286
1287 unsigned getHashValue() const {
1288 // We do not use AlignInBits in hashing function here on purpose:
1289 // in most cases this param for local variable is zero (for function param
1290 // it is always zero). This leads to lots of hash collisions and errors on
1291 // cases with lots of similar variables.
1292 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
1293 // generated IR is random for each run and test fails with Align included.
1294 // TODO: make hashing work fine with such situations
1296 }
1297};
1298
1299template <> struct MDNodeKeyImpl<DILabel> {
1303 unsigned Line;
1304 unsigned Column;
1306 std::optional<unsigned> CoroSuspendIdx;
1307
1314 : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
1315 Line(N->getLine()), Column(N->getColumn()),
1316 IsArtificial(N->isArtificial()),
1317 CoroSuspendIdx(N->getCoroSuspendIdx()) {}
1318
1319 bool isKeyOf(const DILabel *RHS) const {
1320 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1321 File == RHS->getRawFile() && Line == RHS->getLine() &&
1322 Column == RHS->getColumn() && IsArtificial == RHS->isArtificial() &&
1323 CoroSuspendIdx == RHS->getCoroSuspendIdx();
1324 }
1325
1326 /// Using name and line to get hash value. It should already be mostly unique.
1327 unsigned getHashValue() const {
1330 }
1331};
1332
1333template <> struct MDNodeKeyImpl<DIExpression> {
1335
1337 MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
1338
1339 bool isKeyOf(const DIExpression *RHS) const {
1340 return Elements == RHS->getElements();
1341 }
1342
1343 unsigned getHashValue() const { return hash_combine_range(Elements); }
1344};
1345
1349
1353 : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {}
1354
1356 return Variable == RHS->getRawVariable() &&
1357 Expression == RHS->getRawExpression();
1358 }
1359
1360 unsigned getHashValue() const { return hash_combine(Variable, Expression); }
1361};
1362
1363template <> struct MDNodeKeyImpl<DIObjCProperty> {
1366 unsigned Line;
1369 unsigned Attributes;
1371
1378 : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
1379 GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()),
1380 Attributes(N->getAttributes()), Type(N->getRawType()) {}
1381
1382 bool isKeyOf(const DIObjCProperty *RHS) const {
1383 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
1384 Line == RHS->getLine() && GetterName == RHS->getRawGetterName() &&
1385 SetterName == RHS->getRawSetterName() &&
1386 Attributes == RHS->getAttributes() && Type == RHS->getRawType();
1387 }
1388
1389 unsigned getHashValue() const {
1391 Type);
1392 }
1393};
1394
1395template <> struct MDNodeKeyImpl<DIProperty> {
1398 unsigned Line;
1401
1407 : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
1408 Type(N->getRawType()), BackingStorage(N->getRawBackingStorage()) {}
1409
1410 bool isKeyOf(const DIProperty *RHS) const {
1411 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
1412 Line == RHS->getLine() && Type == RHS->getRawType() &&
1413 BackingStorage == RHS->getRawBackingStorage();
1414 }
1415
1416 unsigned getHashValue() const {
1418 }
1419};
1420
1421template <> struct MDNodeKeyImpl<DIImportedEntity> {
1422 unsigned Tag;
1426 unsigned Line;
1429
1435 : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
1436 File(N->getRawFile()), Line(N->getLine()), Name(N->getRawName()),
1437 Elements(N->getRawElements()) {}
1438
1439 bool isKeyOf(const DIImportedEntity *RHS) const {
1440 return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
1441 Entity == RHS->getRawEntity() && File == RHS->getFile() &&
1442 Line == RHS->getLine() && Name == RHS->getRawName() &&
1443 Elements == RHS->getRawElements();
1444 }
1445
1446 unsigned getHashValue() const {
1448 }
1449};
1450
1451template <> struct MDNodeKeyImpl<DIMacro> {
1452 unsigned MIType;
1453 unsigned Line;
1456
1460 : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()),
1461 Value(N->getRawValue()) {}
1462
1463 bool isKeyOf(const DIMacro *RHS) const {
1464 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
1465 Name == RHS->getRawName() && Value == RHS->getRawValue();
1466 }
1467
1468 unsigned getHashValue() const {
1469 return hash_combine(MIType, Line, Name, Value);
1470 }
1471};
1472
1473template <> struct MDNodeKeyImpl<DIMacroFile> {
1474 unsigned MIType;
1475 unsigned Line;
1478
1483 : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()),
1484 Elements(N->getRawElements()) {}
1485
1486 bool isKeyOf(const DIMacroFile *RHS) const {
1487 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
1488 File == RHS->getRawFile() && Elements == RHS->getRawElements();
1489 }
1490
1491 unsigned getHashValue() const {
1493 }
1494};
1495
1496// DIArgLists are not MDNodes, but we still want to unique them in a DenseSet
1497// based on a hash of their arguments.
1500
1502 DIArgListKeyInfo(const DIArgList *N) : Args(N->getArgs()) {}
1503
1504 bool isKeyOf(const DIArgList *RHS) const { return Args == RHS->getArgs(); }
1505
1506 unsigned getHashValue() const { return hash_combine_range(Args); }
1507};
1508
1509/// DenseMapInfo for DIArgList.
1512
1513 static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
1514
1515 static unsigned getHashValue(const DIArgList *N) {
1516 return KeyTy(N).getHashValue();
1517 }
1518
1519 static bool isEqual(const KeyTy &LHS, const DIArgList *RHS) {
1520 return LHS.isKeyOf(RHS);
1521 }
1522
1523 static bool isEqual(const DIArgList *LHS, const DIArgList *RHS) {
1524 return LHS == RHS;
1525 }
1526};
1527
1528/// DenseMapInfo for MDNode subclasses.
1529template <class NodeTy> struct MDNodeInfo {
1532
1533 static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
1534
1535 static unsigned getHashValue(const NodeTy *N) {
1536 return KeyTy(N).getHashValue();
1537 }
1538
1539 static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
1540 return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS);
1541 }
1542
1543 static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
1544 if (LHS == RHS)
1545 return true;
1547 }
1548};
1549
1550#define HANDLE_MDNODE_LEAF(CLASS) using CLASS##Info = MDNodeInfo<CLASS>;
1551#include "llvm/IR/Metadata.def"
1552
1553/// Single metadata attachment, forms linked list ended by index 0.
1555 unsigned Next = 0;
1556 unsigned MDKind;
1558};
1559
1561public:
1562 /// OwnedModules - The set of modules instantiated in this context, and which
1563 /// will be automatically deleted if this context is deleted.
1565
1566 /// MachineFunctionNums - Keep the next available unique number available for
1567 /// a MachineFunction in given module. Module must in OwnedModules.
1569
1570 /// The main remark streamer used by all the other streamers (e.g. IR, MIR,
1571 /// frontends, etc.). This should only be used by the specific streamers, and
1572 /// never directly.
1573 std::unique_ptr<remarks::RemarkStreamer> MainRemarkStreamer;
1574
1575 std::unique_ptr<DiagnosticHandler> DiagHandler;
1578 /// The minimum hotness value a diagnostic needs in order to be included in
1579 /// optimization diagnostics.
1580 ///
1581 /// The threshold is an Optional value, which maps to one of the 3 states:
1582 /// 1). 0 => threshold disabled. All emarks will be printed.
1583 /// 2). positive int => manual threshold by user. Remarks with hotness exceed
1584 /// threshold will be printed.
1585 /// 3). None => 'auto' threshold by user. The actual value is not
1586 /// available at command line, but will be synced with
1587 /// hotness threhold from profile summary during
1588 /// compilation.
1589 ///
1590 /// State 1 and 2 are considered as terminal states. State transition is
1591 /// only allowed from 3 to 2, when the threshold is first synced with profile
1592 /// summary. This ensures that the threshold is set only once and stays
1593 /// constant.
1594 ///
1595 /// If threshold option is not specified, it is disabled (0) by default.
1596 std::optional<uint64_t> DiagnosticsHotnessThreshold = 0;
1597
1598 /// The percentage of difference between profiling branch weights and
1599 /// llvm.expect branch weights to tolerate when emiting MisExpect diagnostics
1600 std::optional<uint32_t> DiagnosticsMisExpectTolerance = 0;
1602
1603 /// The specialized remark streamer used by LLVM's OptimizationRemarkEmitter.
1604 std::unique_ptr<LLVMRemarkStreamer> LLVMRS;
1605
1607 void *YieldOpaqueHandle = nullptr;
1608
1610
1614 DenseMap<std::pair<ElementCount, APInt>, std::unique_ptr<ConstantInt>>
1616
1620 DenseMap<std::pair<ElementCount, APInt>, std::unique_ptr<ConstantByte>>
1622
1624 DenseMap<std::pair<ElementCount, APFloat>, std::unique_ptr<ConstantFP>>
1626
1630
1635
1637
1639
1641
1643 return N->getHeader().MetadataPrintID;
1644 }
1645
1647 N->getHeader().MetadataPrintID = ID;
1648 }
1649
1650#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
1651 DenseSet<CLASS *, CLASS##Info> CLASS##s;
1652#include "llvm/IR/Metadata.def"
1653
1654 // Optional map for looking up composite types by identifier.
1655 std::optional<DenseMap<const MDString *, DICompositeType *>> DITypeMap;
1656
1657 // MDNodes may be uniqued or not uniqued. When they're not uniqued, they
1658 // aren't in the MDNodeSet, but they're still shared between objects, so no
1659 // one object can destroy them. Keep track of them here so we can delete
1660 // them on context teardown.
1661 std::vector<MDNode *> DistinctMDNodes;
1662
1663 // Temporary nodes are caller-owned, but track live ones for persistent
1664 // metadata print IDs.
1666
1667 // ConstantRangeListAttributeImpl is a TrailingObjects/ArrayRef of
1668 // ConstantRange. Since this is a dynamically sized class, it's not
1669 // possible to use SpecificBumpPtrAllocator. Instead, we use normal Alloc
1670 // for allocation and record all allocated pointers in this vector. In the
1671 // LLVMContext destructor, call the destuctors of everything in the vector.
1672 std::vector<ConstantRangeListAttributeImpl *> ConstantRangeListAttributes;
1673
1675
1678
1681
1684
1686
1688
1690
1692
1694
1696
1698
1700
1702
1704
1706
1709
1712
1713 // Basic type instances.
1719
1720 std::unique_ptr<ConstantTokenNone> TheNoneToken;
1721
1726
1729
1736
1739
1742 PointerType *AS0PointerType = nullptr; // AddrSpace = 0
1745
1746 /// ValueHandles - This map keeps track of all of the value handles that are
1747 /// watching a Value*. The Value::HasValueHandle bit is used to know
1748 /// whether or not a value has an entry in this map.
1751
1752 /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
1754
1755 /// Collection of metadata attachments in this context.
1757 /// Index of first free Metadatas entry, linked list via MDAttachment::Next.
1759 /// Number of currently unused metadata entries. Only used/updated in debug
1760 /// builds to ensure that all metadata attachments are properly freed.
1762
1763 /// Map DIAssignID -> Instructions with that attachment.
1764 /// Managed by Instruction via Instruction::updateDIAssignIDMapping.
1765 /// Query using the at:: functions defined in DebugInfo.h.
1767
1768 /// Collection of per-GlobalObject sections used in this context.
1770
1771 /// Collection of per-GlobalValue partitions used in this context.
1773
1776
1777 /// DiscriminatorTable - This table maps file:line locations to an
1778 /// integer representing the next DWARF path discriminator to assign to
1779 /// instructions in different blocks at the same location.
1781
1782 /// A set of interned tags for operand bundles. The StringMap maps
1783 /// bundle tags to their IDs.
1784 ///
1785 /// \see LLVMContext::getOperandBundleTagID
1787
1791
1792 /// A set of interned synchronization scopes. The StringMap maps
1793 /// synchronization scope names to their respective synchronization scope IDs.
1795
1796 /// getOrInsertSyncScopeID - Maps synchronization scope name to
1797 /// synchronization scope ID. Every synchronization scope registered with
1798 /// LLVMContext has unique ID except pre-defined ones.
1800
1801 /// getSyncScopeNames - Populates client supplied SmallVector with
1802 /// synchronization scope names registered with LLVMContext. Synchronization
1803 /// scope names are ordered by increasing synchronization scope IDs.
1805
1806 /// getSyncScopeName - Returns the name of a SyncScope::ID
1807 /// registered with LLVMContext, if any.
1808 std::optional<StringRef> getSyncScopeName(SyncScope::ID Id) const;
1809
1810 /// Maintain the GC name for each function.
1811 ///
1812 /// This saves allocating an additional word in Function for programs which
1813 /// do not use GC (i.e., most programs) at the cost of increased overhead for
1814 /// clients which do use GC.
1816
1817 /// Flag to indicate if Value (other than GlobalValue) retains their name or
1818 /// not.
1819 bool DiscardValueNames = false;
1820
1823
1824 mutable OptPassGate *OPG = nullptr;
1825
1826 /// Access the object which can disable optional passes and individual
1827 /// optimizations at compile time.
1828 OptPassGate &getOptPassGate() const;
1829
1830 /// Set the object which can disable optional passes and individual
1831 /// optimizations at compile time.
1832 ///
1833 /// The lifetime of the object must be guaranteed to extend as long as the
1834 /// LLVMContext is used by compilation.
1836
1837 /// Mapping of blocks to collections of "trailing" DbgVariableRecords. As part
1838 /// of the "RemoveDIs" project, debug-info variable location records are going
1839 /// to cease being instructions... which raises the problem of where should
1840 /// they be recorded when we remove the terminator of a blocks, such as:
1841 ///
1842 /// %foo = add i32 0, 0
1843 /// br label %bar
1844 ///
1845 /// If the branch is removed, a legitimate transient state while editing a
1846 /// block, any debug-records between those two instructions will not have a
1847 /// location. Each block thus records any DbgVariableRecord records that
1848 /// "trail" in such a way. These are stored in LLVMContext because typically
1849 /// LLVM only edits a small number of blocks at a time, so there's no need to
1850 /// bloat BasicBlock with such a data structure.
1852
1853 // Set, get and delete operations for TrailingDbgRecords.
1858
1862
1864
1865 std::string DefaultTargetCPU;
1867
1868 /// The next available source atom group number. The front end is responsible
1869 /// for assigning source atom numbers, but certain optimisations need to
1870 /// assign new group numbers to a set of instructions. Most often code
1871 /// duplication optimisations like loop unroll. Tracking a global maximum
1872 /// value means we can know (cheaply) we're never using a group number that's
1873 /// already used within this function.
1874 ///
1875 /// Start a 1 because 0 means the source location isn't part of an atom group.
1877};
1878
1879} // end namespace llvm
1880
1881#endif // LLVM_LIB_IR_LLVMCONTEXTIMPL_H
static std::optional< unsigned > getTag(const TargetRegisterInfo *TRI, const MachineInstr &MI, const LoadInfo &LI)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
unsigned uint64_t
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
This file defines the BumpPtrAllocator interface.
This file defines various helper methods and classes used by LLVMContextImpl for creating and managin...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
dxil translate DXIL Translate Metadata
This file defines DenseMapInfo traits for DenseMap.
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file contains constants used for implementing Dwarf debug support.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
Module.h This file contains the declarations for the Module class.
static constexpr Value * getValue(Ty &ValueOrUse)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
This file contains the declarations for metadata subclasses.
#define P(N)
static StringRef getName(Value *V)
This file contains some templates that are useful if you are working with the STL at all.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static uint32_t getFlags(const Symbol *Sym)
Definition TapiFile.cpp:26
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Class to represent array types.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
Class to represent byte types.
Constant * getValue() const
Definition Metadata.h:545
Class for constant bytes.
Definition Constants.h:281
This is the shared class of boolean and integer constants.
Definition Constants.h:87
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
Definition Constants.h:174
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
Basic type, like 'int' or 'float'.
Debug common block.
Enumeration value.
DWARF expression.
A pair of DIGlobalVariable and DIExpression.
An imported module (C++ using directive or similar).
Debug lexical block.
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Debug lexical block.
A property of a class or structure.
String type, Fortran CHARACTER(n)
Subprogram description. Uses SubclassData1.
Array subrange.
Type array for a subprogram.
Per-instruction record of debug-info.
Implements a dense probed hash-table based set.
Definition DenseSet.h:281
Class to represent function types.
Generic tagged DWARF-like metadata node.
Class to represent integer types.
DenseMap< const GlobalValue *, StringRef > GlobalValuePartitions
Collection of per-GlobalValue partitions used in this context.
DenseMap< const GlobalValue *, GlobalValue::SanitizerMetadata > GlobalValueSanitizerMetadata
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntOneConstants
void getSyncScopeNames(SmallVectorImpl< StringRef > &SSNs) const
getSyncScopeNames - Populates client supplied SmallVector with synchronization scope names registered...
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntZeroConstants
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
DenseMap< unsigned, ByteType * > ByteTypes
ConstantUniqueMap< ConstantArray > ArrayConstantsTy
SmallVector< MDAttachment, 0 > Metadatas
Collection of metadata attachments in this context.
DenseMap< Type *, std::unique_ptr< ConstantPointerNull > > CPNConstants
DenseMap< std::pair< ElementCount, APInt >, std::unique_ptr< ConstantByte > > ByteSplatConstants
DenseMap< APFloat, std::unique_ptr< ConstantFP > > FPConstants
SmallPtrSet< Module *, 4 > OwnedModules
OwnedModules - The set of modules instantiated in this context, and which will be automatically delet...
DenseMap< Type *, std::unique_ptr< ConstantAggregateZero > > CAZConstants
StringMap< MDString, BumpPtrAllocator > MDStringCache
DenseSet< FunctionType *, FunctionTypeKeyInfo > FunctionTypeSet
TargetExtTypeSet TargetExtTypes
void setMetadataPrintID(MDNode *N, uint32_t ID)
DenseMap< DIAssignID *, SmallVector< Instruction *, 1 > > AssignmentIDToInstrs
Map DIAssignID -> Instructions with that attachment.
DenseMap< Type *, std::unique_ptr< PoisonValue > > PVConstants
DenseMap< APInt, std::unique_ptr< ConstantInt > > IntConstants
DenseMap< Value *, ValueHandleBase * > ValueHandlesTy
ValueHandles - This map keeps track of all of the value handles that are watching a Value*.
ConstantByte * TheFalseByteVal
std::vector< MDNode * > DistinctMDNodes
std::optional< uint32_t > DiagnosticsMisExpectTolerance
The percentage of difference between profiling branch weights and llvm.expect branch weights to toler...
FoldingSet< AttributeImpl > AttrsSet
StructTypeSet AnonStructTypes
std::unique_ptr< ConstantTokenNone > TheNoneToken
DenseMap< const Value *, ValueName * > ValueNames
SyncScope::ID getOrInsertSyncScopeID(StringRef SSN)
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID.
void setOptPassGate(OptPassGate &)
Set the object which can disable optional passes and individual optimizations at compile time.
VectorConstantsTy VectorConstants
std::unique_ptr< LLVMRemarkStreamer > LLVMRS
The specialized remark streamer used by LLVM's OptimizationRemarkEmitter.
bool DiscardValueNames
Flag to indicate if Value (other than GlobalValue) retains their name or not.
DenseMap< const GlobalValue *, NoCFIValue * > NoCFIValues
DenseMap< const Function *, std::string > GCNames
Maintain the GC name for each function.
DenseMap< const BasicBlock *, BlockAddress * > BlockAddresses
ConstantByte * TheTrueByteVal
DenseMap< Type *, std::unique_ptr< UndefValue > > UVConstants
OptPassGate & getOptPassGate() const
Access the object which can disable optional passes and individual optimizations at compile time.
DenseMap< std::pair< Type *, unsigned >, TypedPointerType * > ASTypedPointerTypes
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
std::string DefaultTargetFeatures
DenseMap< Module *, unsigned > MachineFunctionNums
MachineFunctionNums - Keep the next available unique number available for a MachineFunction in given ...
StringMap< unsigned > CustomMDKindNames
CustomMDKindNames - Map to hold the metadata string to ID mapping.
ConstantUniqueMap< ConstantStruct > StructConstantsTy
StringMapEntry< uint32_t > * getOrInsertBundleTag(StringRef Tag)
std::unique_ptr< DiagnosticHandler > DiagHandler
StringMap< uint32_t > BundleTagCache
A set of interned tags for operand bundles.
DbgMarker * getTrailingDbgRecords(BasicBlock *B)
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
StringMap< std::unique_ptr< ConstantDataSequential > > CDSConstants
StructConstantsTy StructConstants
UniquingSet< AttributeSetNode > AttrsSetNodes
DenseMap< std::pair< Type *, ElementCount >, VectorType * > VectorTypes
std::unique_ptr< remarks::RemarkStreamer > MainRemarkStreamer
The main remark streamer used by all the other streamers (e.g.
void getOperandBundleTags(SmallVectorImpl< StringRef > &Tags) const
DenseSet< TargetExtType *, TargetExtTypeKeyInfo > TargetExtTypeSet
void getAllMetadataNodes(SmallVectorImpl< MDNode * > &Nodes) const
void deleteTrailingDbgRecords(BasicBlock *B)
ConstantUniqueMap< ConstantPtrAuth > ConstantPtrAuths
DenseMap< TargetExtType *, std::unique_ptr< ConstantTargetNone > > CTNConstants
SpecificBumpPtrAllocator< ConstantRangeAttributeImpl > ConstantRangeAttributeAlloc
std::optional< uint64_t > DiagnosticsHotnessThreshold
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
ConstantUniqueMap< ConstantVector > VectorConstantsTy
ConstantUniqueMap< ConstantExpr > ExprConstants
uint32_t getOperandBundleTagID(StringRef Tag) const
StringMap< SyncScope::ID > SSC
A set of interned synchronization scopes.
DenseMap< unsigned, PointerType * > PointerTypes
void setTrailingDbgRecords(BasicBlock *B, DbgMarker *M)
DenseSet< StructType *, AnonStructTypeKeyInfo > StructTypeSet
DenseMap< std::pair< ElementCount, APInt >, std::unique_ptr< ConstantInt > > IntSplatConstants
UniqueStringSaver Saver
unsigned MetadataRecycleHead
Index of first free Metadatas entry, linked list via MDAttachment::Next.
LLVMContext::YieldCallbackTy YieldCallback
DenseMap< unsigned, std::unique_ptr< ConstantByte > > ByteOneConstants
DenseMap< unsigned, IntegerType * > IntegerTypes
uint32_t getMetadataPrintID(const MDNode *N) const
StringMap< StructType * > NamedStructTypes
std::vector< ConstantRangeListAttributeImpl * > ConstantRangeListAttributes
DenseSet< DIArgList *, DIArgListInfo > DIArgLists
ValueHandlesTy ValueHandles
std::optional< StringRef > getSyncScopeName(SyncScope::ID Id) const
getSyncScopeName - Returns the name of a SyncScope::ID registered with LLVMContext,...
ArrayConstantsTy ArrayConstants
DenseMap< Value *, ValueAsMetadata * > ValuesAsMetadata
ConstantUniqueMap< InlineAsm > InlineAsms
DenseMap< std::pair< const char *, unsigned >, unsigned > DiscriminatorTable
DiscriminatorTable - This table maps file:line locations to an integer representing the next DWARF pa...
DenseSet< MDNode * > TemporaryMDNodes
uint64_t NextAtomGroup
The next available source atom group number.
LLVMContextImpl(LLVMContext &C)
DenseMap< const GlobalValue *, DSOLocalEquivalent * > DSOLocalEquivalents
UniquingSet< AttributeListImpl > AttrsLists
DenseMap< unsigned, std::unique_ptr< ConstantByte > > ByteZeroConstants
DenseMap< APInt, std::unique_ptr< ConstantByte > > ByteConstants
SmallDenseMap< BasicBlock *, DbgMarker * > TrailingDbgRecords
Mapping of blocks to collections of "trailing" DbgVariableRecords.
FunctionTypeSet FunctionTypes
std::optional< DenseMap< const MDString *, DICompositeType * > > DITypeMap
DenseMap< std::pair< ElementCount, APFloat >, std::unique_ptr< ConstantFP > > FPSplatConstants
unsigned MetadataRecycleSize
Number of currently unused metadata entries.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
void(*)(LLVMContext *Context, void *OpaqueHandle) YieldCallbackTy
Defines the type of a yield callback.
Streamer for LLVM remarks which has logic for dealing with DiagnosticInfo objects.
MDNodeOpsKey(const NodeTy *N, unsigned Offset=0)
bool compareOps(const NodeTy *RHS, unsigned Offset=0) const
unsigned getHash() const
MDNodeOpsKey(ArrayRef< Metadata * > Ops)
static unsigned calculateHash(MDNode *N, unsigned Offset=0)
Metadata node.
Definition Metadata.h:1069
A single uniqued string.
Definition Metadata.h:722
Tuple of metadata.
Definition Metadata.h:1484
Root of the metadata hierarchy.
Definition Metadata.h:64
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
Definition OptBisect.h:26
Class to represent pointers.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
Definition Allocator.h:397
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Class to represent struct types.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition StringSaver.h:45
A uniquing set that compares nodes against a typed key rather than a serialized FoldingSetNodeID.
Definition FoldingSet.h:696
This is the common base class of value handles.
Definition ValueHandle.h:30
Base class of all SIMD vector types.
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
hash_code hash_value(const FixedPointSemantics &Val)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
bool isa_and_nonnull(const Y &Val)
Definition Casting.h:676
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition Hashing.h:307
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:390
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition Hashing.h:287
FoldingSetImpl< T, Trait > FoldingSet
This template class is used to instantiate a specialized implementation of the folding set to the nod...
Definition FoldingSet.h:558
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
#define N
KeyTy(const ArrayRef< Type * > &E, bool P)
bool operator==(const KeyTy &that) const
bool operator!=(const KeyTy &that) const
static bool isEqual(const StructType *LHS, const StructType *RHS)
static unsigned getHashValue(const StructType *ST)
static unsigned getHashValue(const KeyTy &Key)
static bool isEqual(const KeyTy &LHS, const StructType *RHS)
DenseMapInfo for DIArgList.
static unsigned getHashValue(const KeyTy &Key)
static unsigned getHashValue(const DIArgList *N)
static bool isEqual(const DIArgList *LHS, const DIArgList *RHS)
DIArgListKeyInfo KeyTy
static bool isEqual(const KeyTy &LHS, const DIArgList *RHS)
ArrayRef< ValueAsMetadata * > Args
DIArgListKeyInfo(const DIArgList *N)
DIArgListKeyInfo(ArrayRef< ValueAsMetadata * > Args)
unsigned getHashValue() const
bool isKeyOf(const DIArgList *RHS) const
A single checksum, represented by a Kind and a Value (a string).
static bool isEqual(const APFloat &LHS, const APFloat &RHS)
static unsigned getHashValue(const APFloat &Key)
An information struct used to provide DenseMap with the various necessary components for a given valu...
This is the base class for diagnostic handling in LLVM.
bool operator==(const KeyTy &that) const
bool operator!=(const KeyTy &that) const
KeyTy(const Type *R, const ArrayRef< Type * > &P, bool V)
KeyTy(const FunctionType *FT)
static unsigned getHashValue(const FunctionType *FT)
static bool isEqual(const KeyTy &LHS, const FunctionType *RHS)
static unsigned getHashValue(const KeyTy &Key)
static bool isEqual(const FunctionType *LHS, const FunctionType *RHS)
Single metadata attachment, forms linked list ended by index 0.
TrackingMDNodeRef Node
DenseMapInfo for MDNode subclasses.
static unsigned getHashValue(const KeyTy &Key)
static bool isEqual(const NodeTy *LHS, const NodeTy *RHS)
static bool isEqual(const KeyTy &LHS, const NodeTy *RHS)
static unsigned getHashValue(const NodeTy *N)
MDNodeSubsetEqualImpl< NodeTy > SubsetEqualTy
MDNodeKeyImpl< NodeTy > KeyTy
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned LineNo, Metadata *Scope, Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding, uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, unsigned Flags)
bool isKeyOf(const DIBasicType *RHS) const
bool isKeyOf(const DICommonBlock *RHS) const
MDNodeKeyImpl(Metadata *Scope, Metadata *Decl, MDString *Name, Metadata *File, unsigned LineNo)
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, Metadata *SizeInBits, uint32_t AlignInBits, Metadata *OffsetInBits, unsigned Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator, Metadata *DataLocation, Metadata *Associated, Metadata *Allocated, Metadata *Rank, Metadata *Annotations, Metadata *Specification, uint32_t NumExtraInhabitants, Metadata *BitStride)
MDNodeKeyImpl(const DICompositeType *N)
bool isKeyOf(const DICompositeType *RHS) const
MDNodeKeyImpl(APInt Value, bool IsUnsigned, MDString *Name)
MDNodeKeyImpl(int64_t Value, bool IsUnsigned, MDString *Name)
bool isKeyOf(const DIEnumerator *RHS) const
bool isKeyOf(const DIExpression *RHS) const
MDNodeKeyImpl(ArrayRef< uint64_t > Elements)
std::optional< DIFile::ChecksumInfo< MDString * > > Checksum
bool isKeyOf(const DIFile *RHS) const
MDNodeKeyImpl(MDString *Filename, MDString *Directory, std::optional< DIFile::ChecksumInfo< MDString * > > Checksum, MDString *Source)
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned LineNo, Metadata *Scope, Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding, unsigned Flags, unsigned Kind, int Factor, APInt Numerator, APInt Denominator)
MDNodeKeyImpl(const DIFixedPointType *N)
bool isKeyOf(const DIFixedPointType *RHS) const
bool isKeyOf(const DIGenericSubrange *RHS) const
MDNodeKeyImpl(const DIGenericSubrange *N)
MDNodeKeyImpl(Metadata *CountNode, Metadata *LowerBound, Metadata *UpperBound, Metadata *Stride)
MDNodeKeyImpl(Metadata *Variable, Metadata *Expression)
bool isKeyOf(const DIGlobalVariableExpression *RHS) const
MDNodeKeyImpl(const DIGlobalVariableExpression *N)
bool isKeyOf(const DIGlobalVariable *RHS) const
MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams, uint32_t AlignInBits, Metadata *Annotations)
MDNodeKeyImpl(const DIGlobalVariable *N)
bool isKeyOf(const DIImportedEntity *RHS) const
MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, Metadata *File, unsigned Line, MDString *Name, Metadata *Elements)
MDNodeKeyImpl(const DIImportedEntity *N)
unsigned getHashValue() const
Using name and line to get hash value. It should already be mostly unique.
bool isKeyOf(const DILabel *RHS) const
std::optional< unsigned > CoroSuspendIdx
MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line, unsigned Column, bool IsArtificial, std::optional< unsigned > CoroSuspendIdx)
MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
MDNodeKeyImpl(const DILexicalBlockFile *N)
bool isKeyOf(const DILexicalBlockFile *RHS) const
bool isKeyOf(const DILexicalBlock *RHS) const
MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
bool isKeyOf(const DILocalVariable *RHS) const
MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line, Metadata *Type, unsigned Arg, unsigned Flags, uint32_t AlignInBits, Metadata *Annotations)
MDNodeKeyImpl(const DILocalVariable *N)
MDNodeKeyImpl(unsigned Line, uint16_t Column, Metadata *Scope, Metadata *InlinedAt, bool ImplicitCode, uint64_t AtomGroup, uint8_t AtomRank)
bool isKeyOf(const DILocation *RHS) const
MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File, Metadata *Elements)
bool isKeyOf(const DIMacroFile *RHS) const
MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value)
bool isKeyOf(const DIMacro *RHS) const
MDNodeKeyImpl(Metadata *File, Metadata *Scope, MDString *Name, MDString *ConfigurationMacros, MDString *IncludePath, MDString *APINotesFile, unsigned LineNo, bool IsDecl)
bool isKeyOf(const DIModule *RHS) const
MDNodeKeyImpl(Metadata *Scope, MDString *Name, bool ExportSymbols)
bool isKeyOf(const DINamespace *RHS) const
bool isKeyOf(const DIObjCProperty *RHS) const
MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line, MDString *GetterName, MDString *SetterName, unsigned Attributes, Metadata *Type)
MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line, Metadata *Type, Metadata *BackingStorage)
bool isKeyOf(const DIProperty *RHS) const
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *StringLength, Metadata *StringLengthExp, Metadata *StringLocationExp, Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding)
bool isKeyOf(const DIStringType *RHS) const
MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *SizeInBits, uint32_t AlignInBits, unsigned Flags, Metadata *BaseType, Metadata *LowerBound, Metadata *UpperBound, Metadata *Stride, Metadata *Bias)
bool isKeyOf(const DISubrangeType *RHS) const
MDNodeKeyImpl(const DISubrangeType *N)
MDNodeKeyImpl(Metadata *CountNode, Metadata *LowerBound, Metadata *UpperBound, Metadata *Stride)
bool isKeyOf(const DISubrange *RHS) const
bool isKeyOf(const DISubroutineType *RHS) const
MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray)
MDNodeKeyImpl(const DISubroutineType *N)
MDNodeKeyImpl(const DITemplateTypeParameter *N)
bool isKeyOf(const DITemplateTypeParameter *RHS) const
MDNodeKeyImpl(MDString *Name, Metadata *Type, bool IsDefault)
MDNodeKeyImpl(const DITemplateValueParameter *N)
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, bool IsDefault, Metadata *Value)
bool isKeyOf(const DITemplateValueParameter *RHS) const
static unsigned calculateHash(GenericDINode *N)
MDNodeKeyImpl(const GenericDINode *N)
MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef< Metadata * > DwarfOps)
bool isKeyOf(const GenericDINode *RHS) const
bool isKeyOf(const MDTuple *RHS) const
MDNodeKeyImpl(ArrayRef< Metadata * > Ops)
static unsigned calculateHash(MDTuple *N)
static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS)
static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS)
static bool isODRMember(unsigned Tag, const Metadata *Scope, const MDString *Name, const DIDerivedType *RHS)
Subprograms compare equal if they declare the same function in an ODR type.
static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS)
static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS)
static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope, const MDString *LinkageName, const Metadata *TemplateParams, const DISubprogram *RHS)
Subprograms compare equal if they declare the same function in an ODR type.
Configuration point for MDNodeInfo::isEqual().
static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS)
MDNodeKeyImpl< NodeTy > KeyTy
static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS)
KeyTy(StringRef N, const ArrayRef< Type * > &TP, const ArrayRef< unsigned > &IP)
bool operator==(const KeyTy &that) const
KeyTy(const TargetExtType *TT)
bool operator!=(const KeyTy &that) const
static unsigned getHashValue(const TargetExtType *FT)
static bool isEqual(const TargetExtType *LHS, const TargetExtType *RHS)
static bool isEqual(const KeyTy &LHS, const TargetExtType *RHS)
static unsigned getHashValue(const KeyTy &Key)