LLVM 23.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 "ConstantsContext.h"
18#include "llvm/ADT/APFloat.h"
19#include "llvm/ADT/APInt.h"
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/DenseSet.h"
24#include "llvm/ADT/FoldingSet.h"
25#include "llvm/ADT/Hashing.h"
26#include "llvm/ADT/STLExtras.h"
29#include "llvm/ADT/StringMap.h"
31#include "llvm/IR/Constants.h"
34#include "llvm/IR/LLVMContext.h"
35#include "llvm/IR/Metadata.h"
36#include "llvm/IR/Module.h"
38#include "llvm/IR/Type.h"
39#include "llvm/IR/Value.h"
43#include <algorithm>
44#include <cassert>
45#include <cstddef>
46#include <cstdint>
47#include <memory>
48#include <optional>
49#include <string>
50#include <utility>
51#include <vector>
52
53namespace llvm {
54
55class AttributeImpl;
58class BasicBlock;
62class DbgMarker;
63class ElementCount;
64class Function;
65class GlobalObject;
66class GlobalValue;
67class InlineAsm;
69class OptPassGate;
70namespace remarks {
71class RemarkStreamer;
72}
73template <typename T> class StringMapEntry;
74class StringRef;
76class ValueHandleBase;
77
78template <> struct DenseMapInfo<APFloat> {
79 static unsigned getHashValue(const APFloat &Key) {
80 return static_cast<unsigned>(hash_value(Key));
81 }
82
83 static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
84 return LHS.bitwiseIsEqual(RHS);
85 }
86};
87
89 struct KeyTy {
92
93 KeyTy(const ArrayRef<Type *> &E, bool P) : ETypes(E), isPacked(P) {}
94
95 KeyTy(const StructType *ST)
96 : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
97
98 bool operator==(const KeyTy &that) const {
99 if (isPacked != that.isPacked)
100 return false;
101 if (ETypes != that.ETypes)
102 return false;
103 return true;
104 }
105 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
106 };
107
108 static unsigned getHashValue(const KeyTy &Key) {
109 return hash_combine(hash_combine_range(Key.ETypes), Key.isPacked);
110 }
111
112 static unsigned getHashValue(const StructType *ST) {
113 return getHashValue(KeyTy(ST));
114 }
115
116 static bool isEqual(const KeyTy &LHS, const StructType *RHS) {
117 return LHS == KeyTy(RHS);
118 }
119
120 static bool isEqual(const StructType *LHS, const StructType *RHS) {
121 return LHS == RHS;
122 }
123};
124
126 struct KeyTy {
130
131 KeyTy(const Type *R, const ArrayRef<Type *> &P, bool V)
132 : ReturnType(R), Params(P), isVarArg(V) {}
134 : ReturnType(FT->getReturnType()), Params(FT->params()),
135 isVarArg(FT->isVarArg()) {}
136
137 bool operator==(const KeyTy &that) const {
138 if (ReturnType != that.ReturnType)
139 return false;
140 if (isVarArg != that.isVarArg)
141 return false;
142 if (Params != that.Params)
143 return false;
144 return true;
145 }
146 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
147 };
148
149 static unsigned getHashValue(const KeyTy &Key) {
150 return hash_combine(Key.ReturnType, hash_combine_range(Key.Params),
151 Key.isVarArg);
152 }
153
154 static unsigned getHashValue(const FunctionType *FT) {
155 return getHashValue(KeyTy(FT));
156 }
157
158 static bool isEqual(const KeyTy &LHS, const FunctionType *RHS) {
159 return LHS == KeyTy(RHS);
160 }
161
162 static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
163 return LHS == RHS;
164 }
165};
166
168 struct KeyTy {
172
174 : Name(N), TypeParams(TP), IntParams(IP) {}
176 : Name(TT->getName()), TypeParams(TT->type_params()),
177 IntParams(TT->int_params()) {}
178
179 bool operator==(const KeyTy &that) const {
180 return Name == that.Name && TypeParams == that.TypeParams &&
181 IntParams == that.IntParams;
182 }
183 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
184 };
185
186 static unsigned getHashValue(const KeyTy &Key) {
187 return hash_combine(Key.Name, hash_combine_range(Key.TypeParams),
188 hash_combine_range(Key.IntParams));
189 }
190
191 static unsigned getHashValue(const TargetExtType *FT) {
192 return getHashValue(KeyTy(FT));
193 }
194
195 static bool isEqual(const KeyTy &LHS, const TargetExtType *RHS) {
196 return LHS == KeyTy(RHS);
197 }
198
199 static bool isEqual(const TargetExtType *LHS, const TargetExtType *RHS) {
200 return LHS == RHS;
201 }
202};
203
204/// Structure for hashing arbitrary MDNode operands.
208 unsigned Hash;
209
210protected:
212 : RawOps(Ops), Hash(calculateHash(Ops)) {}
213
214 template <class NodeTy>
215 MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
216 : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
217
218 template <class NodeTy>
219 bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
220 if (getHash() != RHS->getHash())
221 return false;
222
223 assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
224 return RawOps.empty() ? compareOps(Ops, RHS, Offset)
225 : compareOps(RawOps, RHS, Offset);
226 }
227
228 static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
229
230private:
231 template <class T>
232 static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
233 if (Ops.size() != RHS->getNumOperands() - Offset)
234 return false;
235 return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
236 }
237
238 static unsigned calculateHash(ArrayRef<Metadata *> Ops);
239
240public:
241 unsigned getHash() const { return Hash; }
242};
243
244template <class NodeTy> struct MDNodeKeyImpl;
245
246/// Configuration point for MDNodeInfo::isEqual().
247template <class NodeTy> struct MDNodeSubsetEqualImpl {
249
250 static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) {
251 return false;
252 }
253
254 static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) {
255 return false;
256 }
257};
258
259/// DenseMapInfo for MDTuple.
260///
261/// Note that we don't need the is-function-local bit, since that's implicit in
262/// the operands.
263template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
266
267 bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
268
269 unsigned getHashValue() const { return getHash(); }
270
271 static unsigned calculateHash(MDTuple *N) {
273 }
274};
275
276/// DenseMapInfo for DILocation.
277template <> struct MDNodeKeyImpl<DILocation> {
282 unsigned Line;
285
292
294 : Scope(L->getRawScope()), InlinedAt(L->getRawInlinedAt()),
295 AtomGroup(L->getAtomGroup()), AtomRank(L->getAtomRank()),
296 Line(L->getLine()), Column(L->getColumn()),
297 ImplicitCode(L->isImplicitCode()) {}
298
299 bool isKeyOf(const DILocation *RHS) const {
300 return Line == RHS->getLine() && Column == RHS->getColumn() &&
301 Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt() &&
302 ImplicitCode == RHS->isImplicitCode() &&
303 AtomGroup == RHS->getAtomGroup() && AtomRank == RHS->getAtomRank();
304 }
305
306 unsigned getHashValue() const {
307 uint64_t LineColumnAndImplicitCode =
308 Line | (uint64_t(Column) << 32) | (uint64_t(ImplicitCode) << 48);
309 // Hashing AtomGroup and AtomRank substantially impacts performance whether
310 // Key Instructions is enabled or not. We can't detect whether it's enabled
311 // here cheaply; avoiding hashing zero values is a good approximation. This
312 // affects Key Instruction builds too, but any potential costs incurred by
313 // messing with the hash distribution* appear to still be massively
314 // outweighed by the overall compile time savings by performing this check.
315 // * (hash_combine(x) != hash_combine(x, 0))
316 if (AtomGroup || AtomRank)
317 return hash_combine(LineColumnAndImplicitCode, Scope, InlinedAt,
318 AtomGroup | (uint64_t(AtomRank) << 61));
319 return hash_combine(LineColumnAndImplicitCode, Scope, InlinedAt);
320 }
321};
322
323/// DenseMapInfo for GenericDINode.
325 unsigned Tag;
327
329 : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
331 : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {}
332
333 bool isKeyOf(const GenericDINode *RHS) const {
334 return Tag == RHS->getTag() && Header == RHS->getRawHeader() &&
335 compareOps(RHS, 1);
336 }
337
338 unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
339
340 static unsigned calculateHash(GenericDINode *N) {
342 }
343};
344
345template <> struct MDNodeKeyImpl<DISubrange> {
350
356 : CountNode(N->getRawCountNode()), LowerBound(N->getRawLowerBound()),
357 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()) {}
358
359 bool isKeyOf(const DISubrange *RHS) const {
360 auto BoundsEqual = [=](Metadata *Node1, Metadata *Node2) -> bool {
361 if (Node1 == Node2)
362 return true;
363
366 if (MD1 && MD2) {
369 if (CV1->getSExtValue() == CV2->getSExtValue())
370 return true;
371 }
372 return false;
373 };
374
375 return BoundsEqual(CountNode, RHS->getRawCountNode()) &&
376 BoundsEqual(LowerBound, RHS->getRawLowerBound()) &&
377 BoundsEqual(UpperBound, RHS->getRawUpperBound()) &&
378 BoundsEqual(Stride, RHS->getRawStride());
379 }
380
381 unsigned getHashValue() const {
382 if (CountNode)
384 return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
387 }
388};
389
390template <> struct MDNodeKeyImpl<DIGenericSubrange> {
395
401 : CountNode(N->getRawCountNode()), LowerBound(N->getRawLowerBound()),
402 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()) {}
403
404 bool isKeyOf(const DIGenericSubrange *RHS) const {
405 return (CountNode == RHS->getRawCountNode()) &&
406 (LowerBound == RHS->getRawLowerBound()) &&
407 (UpperBound == RHS->getRawUpperBound()) &&
408 (Stride == RHS->getRawStride());
409 }
410
411 unsigned getHashValue() const {
413 if (CountNode && MD)
414 return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
417 }
418};
419
420template <> struct MDNodeKeyImpl<DIEnumerator> {
424
431 : Value(N->getValue()), Name(N->getRawName()),
432 IsUnsigned(N->isUnsigned()) {}
433
434 bool isKeyOf(const DIEnumerator *RHS) const {
435 return Value.getBitWidth() == RHS->getValue().getBitWidth() &&
436 Value == RHS->getValue() && IsUnsigned == RHS->isUnsigned() &&
437 Name == RHS->getRawName();
438 }
439
440 unsigned getHashValue() const { return hash_combine(Value, Name); }
441};
442
443template <> struct MDNodeKeyImpl<DIBasicType> {
444 unsigned Tag;
447 unsigned LineNo;
451 unsigned Encoding;
454 unsigned Flags;
455
465 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
466 LineNo(N->getLine()), Scope(N->getRawScope()),
467 SizeInBits(N->getRawSizeInBits()), AlignInBits(N->getAlignInBits()),
468 Encoding(N->getEncoding()),
469 NumExtraInhabitants(N->getNumExtraInhabitants()),
470 DataSizeInBits(N->getDataSizeInBits()), Flags(N->getFlags()) {}
471
472 bool isKeyOf(const DIBasicType *RHS) const {
473 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
474 File == RHS->getRawFile() && LineNo == RHS->getLine() &&
475 Scope == RHS->getRawScope() &&
476 SizeInBits == RHS->getRawSizeInBits() &&
477 AlignInBits == RHS->getAlignInBits() &&
478 Encoding == RHS->getEncoding() &&
479 NumExtraInhabitants == RHS->getNumExtraInhabitants() &&
480 DataSizeInBits == RHS->getDataSizeInBits() &&
481 Flags == RHS->getFlags();
482 }
483
484 unsigned getHashValue() const {
486 Encoding);
487 }
488};
489
490template <> struct MDNodeKeyImpl<DIFixedPointType> {
491 unsigned Tag;
494 unsigned LineNo;
498 unsigned Encoding;
499 unsigned Flags;
500 unsigned Kind;
504
514 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
515 LineNo(N->getLine()), Scope(N->getRawScope()),
516 SizeInBits(N->getRawSizeInBits()), AlignInBits(N->getAlignInBits()),
517 Encoding(N->getEncoding()), Flags(N->getFlags()), Kind(N->getKind()),
518 Factor(N->getFactorRaw()), Numerator(N->getNumeratorRaw()),
519 Denominator(N->getDenominatorRaw()) {}
520
521 bool isKeyOf(const DIFixedPointType *RHS) const {
522 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
523 LineNo == RHS->getLine() && Scope == RHS->getRawScope() &&
524 SizeInBits == RHS->getRawSizeInBits() &&
525 AlignInBits == RHS->getAlignInBits() && Kind == RHS->getKind() &&
526 (RHS->isRational() ? (Numerator == RHS->getNumerator() &&
527 Denominator == RHS->getDenominator())
528 : Factor == RHS->getFactor());
529 }
530
531 unsigned getHashValue() const {
534 }
535};
536
537template <> struct MDNodeKeyImpl<DIStringType> {
538 unsigned Tag;
545 unsigned Encoding;
546
554 : Tag(N->getTag()), Name(N->getRawName()),
555 StringLength(N->getRawStringLength()),
556 StringLengthExp(N->getRawStringLengthExp()),
557 StringLocationExp(N->getRawStringLocationExp()),
558 SizeInBits(N->getRawSizeInBits()), AlignInBits(N->getAlignInBits()),
559 Encoding(N->getEncoding()) {}
560
561 bool isKeyOf(const DIStringType *RHS) const {
562 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
563 StringLength == RHS->getRawStringLength() &&
564 StringLengthExp == RHS->getRawStringLengthExp() &&
565 StringLocationExp == RHS->getRawStringLocationExp() &&
566 SizeInBits == RHS->getRawSizeInBits() &&
567 AlignInBits == RHS->getAlignInBits() &&
568 Encoding == RHS->getEncoding();
569 }
570 unsigned getHashValue() const {
571 // Intentionally computes the hash on a subset of the operands for
572 // performance reason. The subset has to be significant enough to avoid
573 // collision "most of the time". There is no correctness issue in case of
574 // collision because of the full check above.
576 }
577};
578
579template <> struct MDNodeKeyImpl<DIDerivedType> {
580 unsigned Tag;
581 MDString *Name;
582 Metadata *File;
583 unsigned Line;
584 Metadata *Scope;
586 Metadata *SizeInBits;
587 Metadata *OffsetInBits;
588 uint32_t AlignInBits;
589 std::optional<unsigned> DWARFAddressSpace;
590 std::optional<DIDerivedType::PtrAuthData> PtrAuthData;
591 unsigned Flags;
593 Metadata *Annotations;
594
595 MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
596 Metadata *Scope, Metadata *BaseType, Metadata *SizeInBits,
597 uint32_t AlignInBits, Metadata *OffsetInBits,
598 std::optional<unsigned> DWARFAddressSpace,
599 std::optional<DIDerivedType::PtrAuthData> PtrAuthData,
600 unsigned Flags, Metadata *ExtraData, Metadata *Annotations)
601 : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
602 BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
603 AlignInBits(AlignInBits), DWARFAddressSpace(DWARFAddressSpace),
604 PtrAuthData(PtrAuthData), Flags(Flags), ExtraData(ExtraData),
605 Annotations(Annotations) {}
606 MDNodeKeyImpl(const DIDerivedType *N)
607 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
608 Line(N->getLine()), Scope(N->getRawScope()),
609 BaseType(N->getRawBaseType()), SizeInBits(N->getRawSizeInBits()),
610 OffsetInBits(N->getRawOffsetInBits()), AlignInBits(N->getAlignInBits()),
611 DWARFAddressSpace(N->getDWARFAddressSpace()),
612 PtrAuthData(N->getPtrAuthData()), Flags(N->getFlags()),
613 ExtraData(N->getRawExtraData()), Annotations(N->getRawAnnotations()) {}
614
615 bool isKeyOf(const DIDerivedType *RHS) const {
616 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
617 File == RHS->getRawFile() && Line == RHS->getLine() &&
618 Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
619 SizeInBits == RHS->getRawSizeInBits() &&
620 AlignInBits == RHS->getAlignInBits() &&
621 OffsetInBits == RHS->getRawOffsetInBits() &&
622 DWARFAddressSpace == RHS->getDWARFAddressSpace() &&
623 PtrAuthData == RHS->getPtrAuthData() && Flags == RHS->getFlags() &&
624 ExtraData == RHS->getRawExtraData() &&
625 Annotations == RHS->getRawAnnotations();
626 }
627
628 unsigned getHashValue() const {
629 // If this is a member inside an ODR type, only hash the type and the name.
630 // Otherwise the hash will be stronger than
631 // MDNodeSubsetEqualImpl::isODRMember().
632 if (Tag == dwarf::DW_TAG_member && Name)
633 if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
634 if (CT->getRawIdentifier())
635 return hash_combine(Name, Scope);
636
637 // Intentionally computes the hash on a subset of the operands for
638 // performance reason. The subset has to be significant enough to avoid
639 // collision "most of the time". There is no correctness issue in case of
640 // collision because of the full check above.
641 return hash_combine(Tag, Name, File, Line, Scope, BaseType, Flags);
642 }
643};
644
645template <> struct MDNodeKeyImpl<DISubrangeType> {
648 unsigned Line;
652 unsigned Flags;
658
668 : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
669 Scope(N->getRawScope()), SizeInBits(N->getRawSizeInBits()),
670 AlignInBits(N->getAlignInBits()), Flags(N->getFlags()),
671 BaseType(N->getRawBaseType()), LowerBound(N->getRawLowerBound()),
672 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()),
673 Bias(N->getRawBias()) {}
674
675 bool isKeyOf(const DISubrangeType *RHS) const {
676 auto BoundsEqual = [=](Metadata *Node1, Metadata *Node2) -> bool {
677 if (Node1 == Node2)
678 return true;
679
682 if (MD1 && MD2) {
685 if (CV1->getSExtValue() == CV2->getSExtValue())
686 return true;
687 }
688 return false;
689 };
690
691 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
692 Line == RHS->getLine() && Scope == RHS->getRawScope() &&
693 SizeInBits == RHS->getRawSizeInBits() &&
694 AlignInBits == RHS->getAlignInBits() && Flags == RHS->getFlags() &&
695 BaseType == RHS->getRawBaseType() &&
696 BoundsEqual(LowerBound, RHS->getRawLowerBound()) &&
697 BoundsEqual(UpperBound, RHS->getRawUpperBound()) &&
698 BoundsEqual(Stride, RHS->getRawStride()) &&
699 BoundsEqual(Bias, RHS->getRawBias());
700 }
701
702 unsigned getHashValue() const {
703 unsigned val = 0;
704 auto HashBound = [&](Metadata *Node) -> void {
706 if (MD) {
708 val = hash_combine(val, CV->getSExtValue());
709 } else {
710 val = hash_combine(val, Node);
711 }
712 };
713
714 HashBound(LowerBound);
715 HashBound(UpperBound);
716 HashBound(Stride);
717 HashBound(Bias);
718
719 return hash_combine(val, Name, File, Line, Scope, BaseType, Flags);
720 }
721};
722
725
726 static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS) {
727 return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
728 }
729
730 static bool isSubsetEqual(const DIDerivedType *LHS,
731 const DIDerivedType *RHS) {
732 return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
733 RHS);
734 }
735
736 /// Subprograms compare equal if they declare the same function in an ODR
737 /// type.
738 static bool isODRMember(unsigned Tag, const Metadata *Scope,
739 const MDString *Name, const DIDerivedType *RHS) {
740 // Check whether the LHS is eligible.
741 if (Tag != dwarf::DW_TAG_member || !Name)
742 return false;
743
744 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
745 if (!CT || !CT->getRawIdentifier())
746 return false;
747
748 // Compare to the RHS.
749 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
750 Scope == RHS->getRawScope();
751 }
752};
753
754template <> struct MDNodeKeyImpl<DICompositeType> {
755 unsigned Tag;
758 unsigned Line;
764 unsigned Flags;
766 unsigned RuntimeLang;
779
800 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
801 Line(N->getLine()), Scope(N->getRawScope()),
802 BaseType(N->getRawBaseType()), SizeInBits(N->getRawSizeInBits()),
803 OffsetInBits(N->getRawOffsetInBits()), AlignInBits(N->getAlignInBits()),
804 Flags(N->getFlags()), Elements(N->getRawElements()),
805 RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()),
806 TemplateParams(N->getRawTemplateParams()),
807 Identifier(N->getRawIdentifier()),
808 Discriminator(N->getRawDiscriminator()),
809 DataLocation(N->getRawDataLocation()),
810 Associated(N->getRawAssociated()), Allocated(N->getRawAllocated()),
811 Rank(N->getRawRank()), Annotations(N->getRawAnnotations()),
812 Specification(N->getSpecification()),
813 NumExtraInhabitants(N->getNumExtraInhabitants()),
814 BitStride(N->getRawBitStride()) {}
815
816 bool isKeyOf(const DICompositeType *RHS) const {
817 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
818 File == RHS->getRawFile() && Line == RHS->getLine() &&
819 Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
820 SizeInBits == RHS->getRawSizeInBits() &&
821 AlignInBits == RHS->getAlignInBits() &&
822 OffsetInBits == RHS->getRawOffsetInBits() &&
823 Flags == RHS->getFlags() && Elements == RHS->getRawElements() &&
824 RuntimeLang == RHS->getRuntimeLang() &&
825 VTableHolder == RHS->getRawVTableHolder() &&
826 TemplateParams == RHS->getRawTemplateParams() &&
827 Identifier == RHS->getRawIdentifier() &&
828 Discriminator == RHS->getRawDiscriminator() &&
829 DataLocation == RHS->getRawDataLocation() &&
830 Associated == RHS->getRawAssociated() &&
831 Allocated == RHS->getRawAllocated() && Rank == RHS->getRawRank() &&
832 Annotations == RHS->getRawAnnotations() &&
833 Specification == RHS->getSpecification() &&
834 NumExtraInhabitants == RHS->getNumExtraInhabitants() &&
835 BitStride == RHS->getRawBitStride();
836 }
837
838 unsigned getHashValue() const {
839 // Intentionally computes the hash on a subset of the operands for
840 // performance reason. The subset has to be significant enough to avoid
841 // collision "most of the time". There is no correctness issue in case of
842 // collision because of the full check above.
845 }
846};
847
848template <> struct MDNodeKeyImpl<DISubroutineType> {
849 unsigned Flags;
852
856 : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {}
857
858 bool isKeyOf(const DISubroutineType *RHS) const {
859 return Flags == RHS->getFlags() && CC == RHS->getCC() &&
860 TypeArray == RHS->getRawTypeArray();
861 }
862
863 unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); }
864};
865
866template <> struct MDNodeKeyImpl<DIFile> {
869 std::optional<DIFile::ChecksumInfo<MDString *>> Checksum;
871
878 : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
879 Checksum(N->getRawChecksum()), Source(N->getRawSource()) {}
880
881 bool isKeyOf(const DIFile *RHS) const {
882 return Filename == RHS->getRawFilename() &&
883 Directory == RHS->getRawDirectory() &&
884 Checksum == RHS->getRawChecksum() && Source == RHS->getRawSource();
885 }
886
887 unsigned getHashValue() const {
888 return hash_combine(Filename, Directory, Checksum ? Checksum->Kind : 0,
889 Checksum ? Checksum->Value : nullptr, Source);
890 }
891};
892
893template <> struct MDNodeKeyImpl<DISubprogram> {
894 Metadata *Scope;
895 MDString *Name;
896 MDString *LinkageName;
897 Metadata *File;
898 unsigned Line;
899 unsigned ScopeLine;
900 Metadata *Type;
901 Metadata *ContainingType;
902 unsigned VirtualIndex;
903 int ThisAdjustment;
904 unsigned Flags;
905 unsigned SPFlags;
906 Metadata *Unit;
907 Metadata *TemplateParams;
908 Metadata *Declaration;
909 Metadata *RetainedNodes;
910 Metadata *ThrownTypes;
911 Metadata *Annotations;
912 MDString *TargetFuncName;
913 bool UsesKeyInstructions;
914
915 MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
916 Metadata *File, unsigned Line, Metadata *Type,
917 unsigned ScopeLine, Metadata *ContainingType,
918 unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
919 unsigned SPFlags, Metadata *Unit, Metadata *TemplateParams,
920 Metadata *Declaration, Metadata *RetainedNodes,
921 Metadata *ThrownTypes, Metadata *Annotations,
922 MDString *TargetFuncName, bool UsesKeyInstructions)
923 : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
924 Line(Line), ScopeLine(ScopeLine), Type(Type),
925 ContainingType(ContainingType), VirtualIndex(VirtualIndex),
926 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags),
927 Unit(Unit), TemplateParams(TemplateParams), Declaration(Declaration),
928 RetainedNodes(RetainedNodes), ThrownTypes(ThrownTypes),
929 Annotations(Annotations), TargetFuncName(TargetFuncName),
930 UsesKeyInstructions(UsesKeyInstructions) {}
931 MDNodeKeyImpl(const DISubprogram *N)
932 : Scope(N->getRawScope()), Name(N->getRawName()),
933 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
934 Line(N->getLine()), ScopeLine(N->getScopeLine()), Type(N->getRawType()),
935 ContainingType(N->getRawContainingType()),
936 VirtualIndex(N->getVirtualIndex()),
937 ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()),
938 SPFlags(N->getSPFlags()), Unit(N->getRawUnit()),
939 TemplateParams(N->getRawTemplateParams()),
940 Declaration(N->getRawDeclaration()),
941 RetainedNodes(N->getRawRetainedNodes()),
942 ThrownTypes(N->getRawThrownTypes()),
943 Annotations(N->getRawAnnotations()),
944 TargetFuncName(N->getRawTargetFuncName()),
945 UsesKeyInstructions(N->getKeyInstructionsEnabled()) {}
946
947 bool isKeyOf(const DISubprogram *RHS) const {
948 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
949 LinkageName == RHS->getRawLinkageName() &&
950 File == RHS->getRawFile() && Line == RHS->getLine() &&
951 Type == RHS->getRawType() && ScopeLine == RHS->getScopeLine() &&
952 ContainingType == RHS->getRawContainingType() &&
953 VirtualIndex == RHS->getVirtualIndex() &&
954 ThisAdjustment == RHS->getThisAdjustment() &&
955 Flags == RHS->getFlags() && SPFlags == RHS->getSPFlags() &&
956 Unit == RHS->getUnit() &&
957 TemplateParams == RHS->getRawTemplateParams() &&
958 Declaration == RHS->getRawDeclaration() &&
959 RetainedNodes == RHS->getRawRetainedNodes() &&
960 ThrownTypes == RHS->getRawThrownTypes() &&
961 Annotations == RHS->getRawAnnotations() &&
962 TargetFuncName == RHS->getRawTargetFuncName() &&
963 UsesKeyInstructions == RHS->getKeyInstructionsEnabled();
964 }
965
966 bool isDefinition() const { return SPFlags & DISubprogram::SPFlagDefinition; }
967
968 unsigned getHashValue() const {
969 // Use the Scope's linkage name instead of using the scope directly, as the
970 // scope may be a temporary one which can replaced, which would produce a
971 // different hash for the same DISubprogram.
972 llvm::StringRef ScopeLinkageName;
973 if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
974 if (auto *ID = CT->getRawIdentifier())
975 ScopeLinkageName = ID->getString();
976
977 // If this is a declaration inside an ODR type, only hash the type and the
978 // name. Otherwise the hash will be stronger than
979 // MDNodeSubsetEqualImpl::isDeclarationOfODRMember().
980 if (!isDefinition() && LinkageName &&
982 return hash_combine(LinkageName, ScopeLinkageName);
983
984 // Intentionally computes the hash on a subset of the operands for
985 // performance reason. The subset has to be significant enough to avoid
986 // collision "most of the time". There is no correctness issue in case of
987 // collision because of the full check above.
988 return hash_combine(Name, ScopeLinkageName, File, Type, Line);
989 }
990};
991
994
995 static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
996 return isDeclarationOfODRMember(LHS.isDefinition(), LHS.Scope,
997 LHS.LinkageName, LHS.TemplateParams, RHS);
998 }
999
1000 static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) {
1001 return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(),
1002 LHS->getRawLinkageName(),
1003 LHS->getRawTemplateParams(), RHS);
1004 }
1005
1006 /// Subprograms compare equal if they declare the same function in an ODR
1007 /// type.
1008 static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope,
1009 const MDString *LinkageName,
1010 const Metadata *TemplateParams,
1011 const DISubprogram *RHS) {
1012 // Check whether the LHS is eligible.
1013 if (IsDefinition || !Scope || !LinkageName)
1014 return false;
1015
1016 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
1017 if (!CT || !CT->getRawIdentifier())
1018 return false;
1019
1020 // Compare to the RHS.
1021 // FIXME: We need to compare template parameters here to avoid incorrect
1022 // collisions in mapMetadata when RF_ReuseAndMutateDistinctMDs and a
1023 // ODR-DISubprogram has a non-ODR template parameter (i.e., a
1024 // DICompositeType that does not have an identifier). Eventually we should
1025 // decouple ODR logic from uniquing logic.
1026 return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() &&
1027 LinkageName == RHS->getRawLinkageName() &&
1028 TemplateParams == RHS->getRawTemplateParams();
1029 }
1030};
1031
1032template <> struct MDNodeKeyImpl<DILexicalBlock> {
1035 unsigned Line;
1036 unsigned Column;
1037
1041 : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
1042 Column(N->getColumn()) {}
1043
1044 bool isKeyOf(const DILexicalBlock *RHS) const {
1045 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
1046 Line == RHS->getLine() && Column == RHS->getColumn();
1047 }
1048
1049 unsigned getHashValue() const {
1050 return hash_combine(Scope, File, Line, Column);
1051 }
1052};
1053
1058
1062 : Scope(N->getRawScope()), File(N->getRawFile()),
1063 Discriminator(N->getDiscriminator()) {}
1064
1065 bool isKeyOf(const DILexicalBlockFile *RHS) const {
1066 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
1067 Discriminator == RHS->getDiscriminator();
1068 }
1069
1070 unsigned getHashValue() const {
1072 }
1073};
1074
1075template <> struct MDNodeKeyImpl<DINamespace> {
1079
1083 : Scope(N->getRawScope()), Name(N->getRawName()),
1084 ExportSymbols(N->getExportSymbols()) {}
1085
1086 bool isKeyOf(const DINamespace *RHS) const {
1087 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1088 ExportSymbols == RHS->getExportSymbols();
1089 }
1090
1091 unsigned getHashValue() const { return hash_combine(Scope, Name); }
1092};
1093
1094template <> struct MDNodeKeyImpl<DICommonBlock> {
1099 unsigned LineNo;
1100
1105 : Scope(N->getRawScope()), Decl(N->getRawDecl()), Name(N->getRawName()),
1106 File(N->getRawFile()), LineNo(N->getLineNo()) {}
1107
1108 bool isKeyOf(const DICommonBlock *RHS) const {
1109 return Scope == RHS->getRawScope() && Decl == RHS->getRawDecl() &&
1110 Name == RHS->getRawName() && File == RHS->getRawFile() &&
1111 LineNo == RHS->getLineNo();
1112 }
1113
1114 unsigned getHashValue() const {
1115 return hash_combine(Scope, Decl, Name, File, LineNo);
1116 }
1117};
1118
1119template <> struct MDNodeKeyImpl<DIModule> {
1126 unsigned LineNo;
1128
1136 : File(N->getRawFile()), Scope(N->getRawScope()), Name(N->getRawName()),
1137 ConfigurationMacros(N->getRawConfigurationMacros()),
1138 IncludePath(N->getRawIncludePath()),
1139 APINotesFile(N->getRawAPINotesFile()), LineNo(N->getLineNo()),
1140 IsDecl(N->getIsDecl()) {}
1141
1142 bool isKeyOf(const DIModule *RHS) const {
1143 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1144 ConfigurationMacros == RHS->getRawConfigurationMacros() &&
1145 IncludePath == RHS->getRawIncludePath() &&
1146 APINotesFile == RHS->getRawAPINotesFile() &&
1147 File == RHS->getRawFile() && LineNo == RHS->getLineNo() &&
1148 IsDecl == RHS->getIsDecl();
1149 }
1150
1151 unsigned getHashValue() const {
1153 }
1154};
1155
1160
1164 : Name(N->getRawName()), Type(N->getRawType()),
1165 IsDefault(N->isDefault()) {}
1166
1168 return Name == RHS->getRawName() && Type == RHS->getRawType() &&
1169 IsDefault == RHS->isDefault();
1170 }
1171
1172 unsigned getHashValue() const { return hash_combine(Name, Type, IsDefault); }
1173};
1174
1176 unsigned Tag;
1181
1186 : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
1187 IsDefault(N->isDefault()), Value(N->getValue()) {}
1188
1190 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
1191 Type == RHS->getRawType() && IsDefault == RHS->isDefault() &&
1192 Value == RHS->getValue();
1193 }
1194
1195 unsigned getHashValue() const {
1197 }
1198};
1199
1200template <> struct MDNodeKeyImpl<DIGlobalVariable> {
1205 unsigned Line;
1213
1226 : Scope(N->getRawScope()), Name(N->getRawName()),
1227 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
1228 Line(N->getLine()), Type(N->getRawType()),
1229 IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
1230 StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
1231 TemplateParams(N->getRawTemplateParams()),
1232 AlignInBits(N->getAlignInBits()), Annotations(N->getRawAnnotations()) {}
1233
1234 bool isKeyOf(const DIGlobalVariable *RHS) const {
1235 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1236 LinkageName == RHS->getRawLinkageName() &&
1237 File == RHS->getRawFile() && Line == RHS->getLine() &&
1238 Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
1239 IsDefinition == RHS->isDefinition() &&
1241 RHS->getRawStaticDataMemberDeclaration() &&
1242 TemplateParams == RHS->getRawTemplateParams() &&
1243 AlignInBits == RHS->getAlignInBits() &&
1244 Annotations == RHS->getRawAnnotations();
1245 }
1246
1247 unsigned getHashValue() const {
1248 // We do not use AlignInBits in hashing function here on purpose:
1249 // in most cases this param for local variable is zero (for function param
1250 // it is always zero). This leads to lots of hash collisions and errors on
1251 // cases with lots of similar variables.
1252 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
1253 // generated IR is random for each run and test fails with Align included.
1254 // TODO: make hashing work fine with such situations
1256 IsLocalToUnit, IsDefinition, /* AlignInBits, */
1258 }
1259};
1260
1261template <> struct MDNodeKeyImpl<DILocalVariable> {
1265 unsigned Line;
1267 unsigned Arg;
1268 unsigned Flags;
1271
1278 : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
1279 Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
1280 Flags(N->getFlags()), AlignInBits(N->getAlignInBits()),
1281 Annotations(N->getRawAnnotations()) {}
1282
1283 bool isKeyOf(const DILocalVariable *RHS) const {
1284 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1285 File == RHS->getRawFile() && Line == RHS->getLine() &&
1286 Type == RHS->getRawType() && Arg == RHS->getArg() &&
1287 Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits() &&
1288 Annotations == RHS->getRawAnnotations();
1289 }
1290
1291 unsigned getHashValue() const {
1292 // We do not use AlignInBits in hashing function here on purpose:
1293 // in most cases this param for local variable is zero (for function param
1294 // it is always zero). This leads to lots of hash collisions and errors on
1295 // cases with lots of similar variables.
1296 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
1297 // generated IR is random for each run and test fails with Align included.
1298 // TODO: make hashing work fine with such situations
1300 }
1301};
1302
1303template <> struct MDNodeKeyImpl<DILabel> {
1307 unsigned Line;
1308 unsigned Column;
1310 std::optional<unsigned> CoroSuspendIdx;
1311
1318 : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
1319 Line(N->getLine()), Column(N->getColumn()),
1320 IsArtificial(N->isArtificial()),
1321 CoroSuspendIdx(N->getCoroSuspendIdx()) {}
1322
1323 bool isKeyOf(const DILabel *RHS) const {
1324 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1325 File == RHS->getRawFile() && Line == RHS->getLine() &&
1326 Column == RHS->getColumn() && IsArtificial == RHS->isArtificial() &&
1327 CoroSuspendIdx == RHS->getCoroSuspendIdx();
1328 }
1329
1330 /// Using name and line to get hash value. It should already be mostly unique.
1331 unsigned getHashValue() const {
1334 }
1335};
1336
1337template <> struct MDNodeKeyImpl<DIExpression> {
1339
1341 MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
1342
1343 bool isKeyOf(const DIExpression *RHS) const {
1344 return Elements == RHS->getElements();
1345 }
1346
1347 unsigned getHashValue() const { return hash_combine_range(Elements); }
1348};
1349
1353
1357 : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {}
1358
1360 return Variable == RHS->getRawVariable() &&
1361 Expression == RHS->getRawExpression();
1362 }
1363
1364 unsigned getHashValue() const { return hash_combine(Variable, Expression); }
1365};
1366
1367template <> struct MDNodeKeyImpl<DIObjCProperty> {
1370 unsigned Line;
1373 unsigned Attributes;
1375
1382 : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
1383 GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()),
1384 Attributes(N->getAttributes()), Type(N->getRawType()) {}
1385
1386 bool isKeyOf(const DIObjCProperty *RHS) const {
1387 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
1388 Line == RHS->getLine() && GetterName == RHS->getRawGetterName() &&
1389 SetterName == RHS->getRawSetterName() &&
1390 Attributes == RHS->getAttributes() && Type == RHS->getRawType();
1391 }
1392
1393 unsigned getHashValue() const {
1395 Type);
1396 }
1397};
1398
1399template <> struct MDNodeKeyImpl<DIImportedEntity> {
1400 unsigned Tag;
1404 unsigned Line;
1407
1413 : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
1414 File(N->getRawFile()), Line(N->getLine()), Name(N->getRawName()),
1415 Elements(N->getRawElements()) {}
1416
1417 bool isKeyOf(const DIImportedEntity *RHS) const {
1418 return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
1419 Entity == RHS->getRawEntity() && File == RHS->getFile() &&
1420 Line == RHS->getLine() && Name == RHS->getRawName() &&
1421 Elements == RHS->getRawElements();
1422 }
1423
1424 unsigned getHashValue() const {
1426 }
1427};
1428
1429template <> struct MDNodeKeyImpl<DIMacro> {
1430 unsigned MIType;
1431 unsigned Line;
1434
1438 : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()),
1439 Value(N->getRawValue()) {}
1440
1441 bool isKeyOf(const DIMacro *RHS) const {
1442 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
1443 Name == RHS->getRawName() && Value == RHS->getRawValue();
1444 }
1445
1446 unsigned getHashValue() const {
1447 return hash_combine(MIType, Line, Name, Value);
1448 }
1449};
1450
1451template <> struct MDNodeKeyImpl<DIMacroFile> {
1452 unsigned MIType;
1453 unsigned Line;
1456
1461 : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()),
1462 Elements(N->getRawElements()) {}
1463
1464 bool isKeyOf(const DIMacroFile *RHS) const {
1465 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
1466 File == RHS->getRawFile() && Elements == RHS->getRawElements();
1467 }
1468
1469 unsigned getHashValue() const {
1471 }
1472};
1473
1474// DIArgLists are not MDNodes, but we still want to unique them in a DenseSet
1475// based on a hash of their arguments.
1478
1480 DIArgListKeyInfo(const DIArgList *N) : Args(N->getArgs()) {}
1481
1482 bool isKeyOf(const DIArgList *RHS) const { return Args == RHS->getArgs(); }
1483
1484 unsigned getHashValue() const { return hash_combine_range(Args); }
1485};
1486
1487/// DenseMapInfo for DIArgList.
1490
1491 static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
1492
1493 static unsigned getHashValue(const DIArgList *N) {
1494 return KeyTy(N).getHashValue();
1495 }
1496
1497 static bool isEqual(const KeyTy &LHS, const DIArgList *RHS) {
1498 return LHS.isKeyOf(RHS);
1499 }
1500
1501 static bool isEqual(const DIArgList *LHS, const DIArgList *RHS) {
1502 return LHS == RHS;
1503 }
1504};
1505
1506/// DenseMapInfo for MDNode subclasses.
1507template <class NodeTy> struct MDNodeInfo {
1510
1511 static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
1512
1513 static unsigned getHashValue(const NodeTy *N) {
1514 return KeyTy(N).getHashValue();
1515 }
1516
1517 static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
1518 return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS);
1519 }
1520
1521 static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
1522 if (LHS == RHS)
1523 return true;
1525 }
1526};
1527
1528#define HANDLE_MDNODE_LEAF(CLASS) using CLASS##Info = MDNodeInfo<CLASS>;
1529#include "llvm/IR/Metadata.def"
1530
1531/// Single metadata attachment, forms linked list ended by index 0.
1533 unsigned Next = 0;
1534 unsigned MDKind;
1536};
1537
1539public:
1540 /// OwnedModules - The set of modules instantiated in this context, and which
1541 /// will be automatically deleted if this context is deleted.
1543
1544 /// MachineFunctionNums - Keep the next available unique number available for
1545 /// a MachineFunction in given module. Module must in OwnedModules.
1547
1548 /// The main remark streamer used by all the other streamers (e.g. IR, MIR,
1549 /// frontends, etc.). This should only be used by the specific streamers, and
1550 /// never directly.
1551 std::unique_ptr<remarks::RemarkStreamer> MainRemarkStreamer;
1552
1553 std::unique_ptr<DiagnosticHandler> DiagHandler;
1556 /// The minimum hotness value a diagnostic needs in order to be included in
1557 /// optimization diagnostics.
1558 ///
1559 /// The threshold is an Optional value, which maps to one of the 3 states:
1560 /// 1). 0 => threshold disabled. All emarks will be printed.
1561 /// 2). positive int => manual threshold by user. Remarks with hotness exceed
1562 /// threshold will be printed.
1563 /// 3). None => 'auto' threshold by user. The actual value is not
1564 /// available at command line, but will be synced with
1565 /// hotness threhold from profile summary during
1566 /// compilation.
1567 ///
1568 /// State 1 and 2 are considered as terminal states. State transition is
1569 /// only allowed from 3 to 2, when the threshold is first synced with profile
1570 /// summary. This ensures that the threshold is set only once and stays
1571 /// constant.
1572 ///
1573 /// If threshold option is not specified, it is disabled (0) by default.
1574 std::optional<uint64_t> DiagnosticsHotnessThreshold = 0;
1575
1576 /// The percentage of difference between profiling branch weights and
1577 /// llvm.expect branch weights to tolerate when emiting MisExpect diagnostics
1578 std::optional<uint32_t> DiagnosticsMisExpectTolerance = 0;
1580
1581 /// The specialized remark streamer used by LLVM's OptimizationRemarkEmitter.
1582 std::unique_ptr<LLVMRemarkStreamer> LLVMRS;
1583
1585 void *YieldOpaqueHandle = nullptr;
1586
1588
1592 DenseMap<std::pair<ElementCount, APInt>, std::unique_ptr<ConstantInt>>
1594
1598 DenseMap<std::pair<ElementCount, APInt>, std::unique_ptr<ConstantByte>>
1600
1602 DenseMap<std::pair<ElementCount, APFloat>, std::unique_ptr<ConstantFP>>
1604
1608
1613
1614#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
1615 DenseSet<CLASS *, CLASS##Info> CLASS##s;
1616#include "llvm/IR/Metadata.def"
1617
1618 // Optional map for looking up composite types by identifier.
1619 std::optional<DenseMap<const MDString *, DICompositeType *>> DITypeMap;
1620
1621 // MDNodes may be uniqued or not uniqued. When they're not uniqued, they
1622 // aren't in the MDNodeSet, but they're still shared between objects, so no
1623 // one object can destroy them. Keep track of them here so we can delete
1624 // them on context teardown.
1625 std::vector<MDNode *> DistinctMDNodes;
1626
1627 // ConstantRangeListAttributeImpl is a TrailingObjects/ArrayRef of
1628 // ConstantRange. Since this is a dynamically sized class, it's not
1629 // possible to use SpecificBumpPtrAllocator. Instead, we use normal Alloc
1630 // for allocation and record all allocated pointers in this vector. In the
1631 // LLVMContext destructor, call the destuctors of everything in the vector.
1632 std::vector<ConstantRangeListAttributeImpl *> ConstantRangeListAttributes;
1633
1635
1638
1641
1644
1646
1648
1650
1652
1654
1656
1658
1660
1662
1664
1666
1669
1672
1673 // Basic type instances.
1679
1680 std::unique_ptr<ConstantTokenNone> TheNoneToken;
1681
1686
1689
1696
1699
1702 PointerType *AS0PointerType = nullptr; // AddrSpace = 0
1705
1706 /// ValueHandles - This map keeps track of all of the value handles that are
1707 /// watching a Value*. The Value::HasValueHandle bit is used to know
1708 /// whether or not a value has an entry in this map.
1711
1712 /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
1714
1715 /// Collection of metadata attachments in this context.
1717 /// Index of first free Metadatas entry, linked list via MDAttachment::Next.
1719 /// Number of currently unused metadata entries. Only used/updated in debug
1720 /// builds to ensure that all metadata attachments are properly freed.
1722
1723 /// Map DIAssignID -> Instructions with that attachment.
1724 /// Managed by Instruction via Instruction::updateDIAssignIDMapping.
1725 /// Query using the at:: functions defined in DebugInfo.h.
1727
1728 /// Collection of per-GlobalObject sections used in this context.
1730
1731 /// Collection of per-GlobalValue partitions used in this context.
1733
1736
1737 /// DiscriminatorTable - This table maps file:line locations to an
1738 /// integer representing the next DWARF path discriminator to assign to
1739 /// instructions in different blocks at the same location.
1741
1742 /// A set of interned tags for operand bundles. The StringMap maps
1743 /// bundle tags to their IDs.
1744 ///
1745 /// \see LLVMContext::getOperandBundleTagID
1747
1751
1752 /// A set of interned synchronization scopes. The StringMap maps
1753 /// synchronization scope names to their respective synchronization scope IDs.
1755
1756 /// getOrInsertSyncScopeID - Maps synchronization scope name to
1757 /// synchronization scope ID. Every synchronization scope registered with
1758 /// LLVMContext has unique ID except pre-defined ones.
1760
1761 /// getSyncScopeNames - Populates client supplied SmallVector with
1762 /// synchronization scope names registered with LLVMContext. Synchronization
1763 /// scope names are ordered by increasing synchronization scope IDs.
1765
1766 /// getSyncScopeName - Returns the name of a SyncScope::ID
1767 /// registered with LLVMContext, if any.
1768 std::optional<StringRef> getSyncScopeName(SyncScope::ID Id) const;
1769
1770 /// Maintain the GC name for each function.
1771 ///
1772 /// This saves allocating an additional word in Function for programs which
1773 /// do not use GC (i.e., most programs) at the cost of increased overhead for
1774 /// clients which do use GC.
1776
1777 /// Flag to indicate if Value (other than GlobalValue) retains their name or
1778 /// not.
1779 bool DiscardValueNames = false;
1780
1783
1784 mutable OptPassGate *OPG = nullptr;
1785
1786 /// Access the object which can disable optional passes and individual
1787 /// optimizations at compile time.
1788 OptPassGate &getOptPassGate() const;
1789
1790 /// Set the object which can disable optional passes and individual
1791 /// optimizations at compile time.
1792 ///
1793 /// The lifetime of the object must be guaranteed to extend as long as the
1794 /// LLVMContext is used by compilation.
1796
1797 /// Mapping of blocks to collections of "trailing" DbgVariableRecords. As part
1798 /// of the "RemoveDIs" project, debug-info variable location records are going
1799 /// to cease being instructions... which raises the problem of where should
1800 /// they be recorded when we remove the terminator of a blocks, such as:
1801 ///
1802 /// %foo = add i32 0, 0
1803 /// br label %bar
1804 ///
1805 /// If the branch is removed, a legitimate transient state while editing a
1806 /// block, any debug-records between those two instructions will not have a
1807 /// location. Each block thus records any DbgVariableRecord records that
1808 /// "trail" in such a way. These are stored in LLVMContext because typically
1809 /// LLVM only edits a small number of blocks at a time, so there's no need to
1810 /// bloat BasicBlock with such a data structure.
1812
1813 // Set, get and delete operations for TrailingDbgRecords.
1818
1822
1824
1825 std::string DefaultTargetCPU;
1827
1828 /// The next available source atom group number. The front end is responsible
1829 /// for assigning source atom numbers, but certain optimisations need to
1830 /// assign new group numbers to a set of instructions. Most often code
1831 /// duplication optimisations like loop unroll. Tracking a global maximum
1832 /// value means we can know (cheaply) we're never using a group number that's
1833 /// already used within this function.
1834 ///
1835 /// Start a 1 because 0 means the source location isn't part of an atom group.
1837};
1838
1839} // end namespace llvm
1840
1841#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.
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.
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.
This class represents a single, uniqued attribute.
This class represents a set of attributes that apply to the function, return type,...
This class represents a group of attributes that apply to one element: function, return type,...
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.
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:289
This template class is used to instantiate a specialized implementation of the folding set to the nod...
Definition FoldingSet.h:529
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
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
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 deleteTrailingDbgRecords(BasicBlock *B)
FoldingSet< AttributeSetNode > AttrsSetNodes
FoldingSet< AttributeListImpl > AttrsLists
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
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...
uint64_t NextAtomGroup
The next available source atom group number.
LLVMContextImpl(LLVMContext &C)
DenseMap< const GlobalValue *, DSOLocalEquivalent * > DSOLocalEquivalents
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:1489
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:390
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:136
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
This is the common base class of value handles.
Definition ValueHandle.h:30
Base class of all SIMD vector types.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:558
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:1916
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:325
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition Hashing.h:305
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:860
#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(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)