LLVM 19.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;
56class AttributeListImpl;
57class AttributeSetNode;
58class BasicBlock;
59struct DiagnosticHandler;
60class DPMarker;
61class ElementCount;
62class Function;
63class GlobalObject;
64class GlobalValue;
65class InlineAsm;
66class LLVMRemarkStreamer;
67class OptPassGate;
68namespace remarks {
69class RemarkStreamer;
70}
71template <typename T> class StringMapEntry;
72class StringRef;
73class TypedPointerType;
74class ValueHandleBase;
75
76template <> struct DenseMapInfo<APFloat> {
77 static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); }
78 static inline APFloat getTombstoneKey() {
79 return APFloat(APFloat::Bogus(), 2);
80 }
81
82 static unsigned getHashValue(const APFloat &Key) {
83 return static_cast<unsigned>(hash_value(Key));
84 }
85
86 static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
87 return LHS.bitwiseIsEqual(RHS);
88 }
89};
90
92 struct KeyTy {
95
96 KeyTy(const ArrayRef<Type *> &E, bool P) : ETypes(E), isPacked(P) {}
97
98 KeyTy(const StructType *ST)
99 : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
100
101 bool operator==(const KeyTy &that) const {
102 if (isPacked != that.isPacked)
103 return false;
104 if (ETypes != that.ETypes)
105 return false;
106 return true;
107 }
108 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
109 };
110
111 static inline StructType *getEmptyKey() {
113 }
114
115 static inline StructType *getTombstoneKey() {
117 }
118
119 static unsigned getHashValue(const KeyTy &Key) {
120 return hash_combine(
121 hash_combine_range(Key.ETypes.begin(), Key.ETypes.end()), Key.isPacked);
122 }
123
124 static unsigned getHashValue(const StructType *ST) {
125 return getHashValue(KeyTy(ST));
126 }
127
128 static bool isEqual(const KeyTy &LHS, const StructType *RHS) {
129 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
130 return false;
131 return LHS == KeyTy(RHS);
132 }
133
134 static bool isEqual(const StructType *LHS, const StructType *RHS) {
135 return LHS == RHS;
136 }
137};
138
140 struct KeyTy {
144
145 KeyTy(const Type *R, const ArrayRef<Type *> &P, bool V)
146 : ReturnType(R), Params(P), isVarArg(V) {}
148 : ReturnType(FT->getReturnType()), Params(FT->params()),
149 isVarArg(FT->isVarArg()) {}
150
151 bool operator==(const KeyTy &that) const {
152 if (ReturnType != that.ReturnType)
153 return false;
154 if (isVarArg != that.isVarArg)
155 return false;
156 if (Params != that.Params)
157 return false;
158 return true;
159 }
160 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
161 };
162
163 static inline FunctionType *getEmptyKey() {
165 }
166
167 static inline FunctionType *getTombstoneKey() {
169 }
170
171 static unsigned getHashValue(const KeyTy &Key) {
172 return hash_combine(
173 Key.ReturnType,
174 hash_combine_range(Key.Params.begin(), Key.Params.end()), Key.isVarArg);
175 }
176
177 static unsigned getHashValue(const FunctionType *FT) {
178 return getHashValue(KeyTy(FT));
179 }
180
181 static bool isEqual(const KeyTy &LHS, const FunctionType *RHS) {
182 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
183 return false;
184 return LHS == KeyTy(RHS);
185 }
186
187 static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
188 return LHS == RHS;
189 }
190};
191
193 struct KeyTy {
197
199 : Name(N), TypeParams(TP), IntParams(IP) {}
201 : Name(TT->getName()), TypeParams(TT->type_params()),
202 IntParams(TT->int_params()) {}
203
204 bool operator==(const KeyTy &that) const {
205 return Name == that.Name && TypeParams == that.TypeParams &&
206 IntParams == that.IntParams;
207 }
208 bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
209 };
210
211 static inline TargetExtType *getEmptyKey() {
213 }
214
217 }
218
219 static unsigned getHashValue(const KeyTy &Key) {
220 return hash_combine(
221 Key.Name,
222 hash_combine_range(Key.TypeParams.begin(), Key.TypeParams.end()),
223 hash_combine_range(Key.IntParams.begin(), Key.IntParams.end()));
224 }
225
226 static unsigned getHashValue(const TargetExtType *FT) {
227 return getHashValue(KeyTy(FT));
228 }
229
230 static bool isEqual(const KeyTy &LHS, const TargetExtType *RHS) {
231 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
232 return false;
233 return LHS == KeyTy(RHS);
234 }
235
236 static bool isEqual(const TargetExtType *LHS, const TargetExtType *RHS) {
237 return LHS == RHS;
238 }
239};
240
241/// Structure for hashing arbitrary MDNode operands.
245 unsigned Hash;
246
247protected:
249 : RawOps(Ops), Hash(calculateHash(Ops)) {}
250
251 template <class NodeTy>
252 MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
253 : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
254
255 template <class NodeTy>
256 bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
257 if (getHash() != RHS->getHash())
258 return false;
259
260 assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
261 return RawOps.empty() ? compareOps(Ops, RHS, Offset)
262 : compareOps(RawOps, RHS, Offset);
263 }
264
265 static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
266
267private:
268 template <class T>
269 static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
270 if (Ops.size() != RHS->getNumOperands() - Offset)
271 return false;
272 return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
273 }
274
275 static unsigned calculateHash(ArrayRef<Metadata *> Ops);
276
277public:
278 unsigned getHash() const { return Hash; }
279};
280
281template <class NodeTy> struct MDNodeKeyImpl;
282
283/// Configuration point for MDNodeInfo::isEqual().
284template <class NodeTy> struct MDNodeSubsetEqualImpl {
286
287 static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) {
288 return false;
289 }
290
291 static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) {
292 return false;
293 }
294};
295
296/// DenseMapInfo for MDTuple.
297///
298/// Note that we don't need the is-function-local bit, since that's implicit in
299/// the operands.
300template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
303
304 bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
305
306 unsigned getHashValue() const { return getHash(); }
307
308 static unsigned calculateHash(MDTuple *N) {
310 }
311};
312
313/// DenseMapInfo for DILocation.
314template <> struct MDNodeKeyImpl<DILocation> {
315 unsigned Line;
316 unsigned Column;
320
321 MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
322 Metadata *InlinedAt, bool ImplicitCode)
323 : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt),
324 ImplicitCode(ImplicitCode) {}
326 : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()),
327 InlinedAt(L->getRawInlinedAt()), ImplicitCode(L->isImplicitCode()) {}
328
329 bool isKeyOf(const DILocation *RHS) const {
330 return Line == RHS->getLine() && Column == RHS->getColumn() &&
331 Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt() &&
332 ImplicitCode == RHS->isImplicitCode();
333 }
334
335 unsigned getHashValue() const {
336 return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode);
337 }
338};
339
340/// DenseMapInfo for GenericDINode.
342 unsigned Tag;
344
345 MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef<Metadata *> DwarfOps)
346 : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
348 : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {}
349
350 bool isKeyOf(const GenericDINode *RHS) const {
351 return Tag == RHS->getTag() && Header == RHS->getRawHeader() &&
352 compareOps(RHS, 1);
353 }
354
355 unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
356
357 static unsigned calculateHash(GenericDINode *N) {
359 }
360};
361
362template <> struct MDNodeKeyImpl<DISubrange> {
367
368 MDNodeKeyImpl(Metadata *CountNode, Metadata *LowerBound, Metadata *UpperBound,
369 Metadata *Stride)
370 : CountNode(CountNode), LowerBound(LowerBound), UpperBound(UpperBound),
371 Stride(Stride) {}
373 : CountNode(N->getRawCountNode()), LowerBound(N->getRawLowerBound()),
374 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()) {}
375
376 bool isKeyOf(const DISubrange *RHS) const {
377 auto BoundsEqual = [=](Metadata *Node1, Metadata *Node2) -> bool {
378 if (Node1 == Node2)
379 return true;
380
381 ConstantAsMetadata *MD1 = dyn_cast_or_null<ConstantAsMetadata>(Node1);
382 ConstantAsMetadata *MD2 = dyn_cast_or_null<ConstantAsMetadata>(Node2);
383 if (MD1 && MD2) {
384 ConstantInt *CV1 = cast<ConstantInt>(MD1->getValue());
385 ConstantInt *CV2 = cast<ConstantInt>(MD2->getValue());
386 if (CV1->getSExtValue() == CV2->getSExtValue())
387 return true;
388 }
389 return false;
390 };
391
392 return BoundsEqual(CountNode, RHS->getRawCountNode()) &&
393 BoundsEqual(LowerBound, RHS->getRawLowerBound()) &&
394 BoundsEqual(UpperBound, RHS->getRawUpperBound()) &&
395 BoundsEqual(Stride, RHS->getRawStride());
396 }
397
398 unsigned getHashValue() const {
399 if (CountNode)
400 if (auto *MD = dyn_cast<ConstantAsMetadata>(CountNode))
401 return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
402 LowerBound, UpperBound, Stride);
403 return hash_combine(CountNode, LowerBound, UpperBound, Stride);
404 }
405};
406
407template <> struct MDNodeKeyImpl<DIGenericSubrange> {
412
413 MDNodeKeyImpl(Metadata *CountNode, Metadata *LowerBound, Metadata *UpperBound,
414 Metadata *Stride)
415 : CountNode(CountNode), LowerBound(LowerBound), UpperBound(UpperBound),
416 Stride(Stride) {}
418 : CountNode(N->getRawCountNode()), LowerBound(N->getRawLowerBound()),
419 UpperBound(N->getRawUpperBound()), Stride(N->getRawStride()) {}
420
421 bool isKeyOf(const DIGenericSubrange *RHS) const {
422 return (CountNode == RHS->getRawCountNode()) &&
423 (LowerBound == RHS->getRawLowerBound()) &&
424 (UpperBound == RHS->getRawUpperBound()) &&
425 (Stride == RHS->getRawStride());
426 }
427
428 unsigned getHashValue() const {
429 auto *MD = dyn_cast_or_null<ConstantAsMetadata>(CountNode);
430 if (CountNode && MD)
431 return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
432 LowerBound, UpperBound, Stride);
433 return hash_combine(CountNode, LowerBound, UpperBound, Stride);
434 }
435};
436
437template <> struct MDNodeKeyImpl<DIEnumerator> {
441
443 : Value(Value), Name(Name), IsUnsigned(IsUnsigned) {}
444 MDNodeKeyImpl(int64_t Value, bool IsUnsigned, MDString *Name)
445 : Value(APInt(64, Value, !IsUnsigned)), Name(Name),
446 IsUnsigned(IsUnsigned) {}
448 : Value(N->getValue()), Name(N->getRawName()),
449 IsUnsigned(N->isUnsigned()) {}
450
451 bool isKeyOf(const DIEnumerator *RHS) const {
452 return Value.getBitWidth() == RHS->getValue().getBitWidth() &&
453 Value == RHS->getValue() && IsUnsigned == RHS->isUnsigned() &&
454 Name == RHS->getRawName();
455 }
456
457 unsigned getHashValue() const { return hash_combine(Value, Name); }
458};
459
460template <> struct MDNodeKeyImpl<DIBasicType> {
461 unsigned Tag;
465 unsigned Encoding;
466 unsigned Flags;
467
468 MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits,
469 uint32_t AlignInBits, unsigned Encoding, unsigned Flags)
470 : Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
471 Encoding(Encoding), Flags(Flags) {}
473 : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()),
474 AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()),
475 Flags(N->getFlags()) {}
476
477 bool isKeyOf(const DIBasicType *RHS) const {
478 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
479 SizeInBits == RHS->getSizeInBits() &&
480 AlignInBits == RHS->getAlignInBits() &&
481 Encoding == RHS->getEncoding() && Flags == RHS->getFlags();
482 }
483
484 unsigned getHashValue() const {
485 return hash_combine(Tag, Name, SizeInBits, AlignInBits, Encoding);
486 }
487};
488
489template <> struct MDNodeKeyImpl<DIStringType> {
490 unsigned Tag;
497 unsigned Encoding;
498
499 MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *StringLength,
500 Metadata *StringLengthExp, Metadata *StringLocationExp,
501 uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding)
502 : Tag(Tag), Name(Name), StringLength(StringLength),
503 StringLengthExp(StringLengthExp), StringLocationExp(StringLocationExp),
504 SizeInBits(SizeInBits), AlignInBits(AlignInBits), Encoding(Encoding) {}
506 : Tag(N->getTag()), Name(N->getRawName()),
507 StringLength(N->getRawStringLength()),
508 StringLengthExp(N->getRawStringLengthExp()),
509 StringLocationExp(N->getRawStringLocationExp()),
510 SizeInBits(N->getSizeInBits()), AlignInBits(N->getAlignInBits()),
511 Encoding(N->getEncoding()) {}
512
513 bool isKeyOf(const DIStringType *RHS) const {
514 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
515 StringLength == RHS->getRawStringLength() &&
516 StringLengthExp == RHS->getRawStringLengthExp() &&
517 StringLocationExp == RHS->getRawStringLocationExp() &&
518 SizeInBits == RHS->getSizeInBits() &&
519 AlignInBits == RHS->getAlignInBits() &&
520 Encoding == RHS->getEncoding();
521 }
522 unsigned getHashValue() const {
523 // Intentionally computes the hash on a subset of the operands for
524 // performance reason. The subset has to be significant enough to avoid
525 // collision "most of the time". There is no correctness issue in case of
526 // collision because of the full check above.
527 return hash_combine(Tag, Name, StringLength, Encoding);
528 }
529};
530
531template <> struct MDNodeKeyImpl<DIDerivedType> {
532 unsigned Tag;
535 unsigned Line;
541 std::optional<unsigned> DWARFAddressSpace;
542 unsigned Flags;
545
546 MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
547 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
548 uint32_t AlignInBits, uint64_t OffsetInBits,
549 std::optional<unsigned> DWARFAddressSpace, unsigned Flags,
550 Metadata *ExtraData, Metadata *Annotations)
551 : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
552 BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
553 AlignInBits(AlignInBits), DWARFAddressSpace(DWARFAddressSpace),
554 Flags(Flags), ExtraData(ExtraData), Annotations(Annotations) {}
556 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
557 Line(N->getLine()), Scope(N->getRawScope()),
558 BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
559 OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
560 DWARFAddressSpace(N->getDWARFAddressSpace()), Flags(N->getFlags()),
561 ExtraData(N->getRawExtraData()), Annotations(N->getRawAnnotations()) {}
562
563 bool isKeyOf(const DIDerivedType *RHS) const {
564 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
565 File == RHS->getRawFile() && Line == RHS->getLine() &&
566 Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
567 SizeInBits == RHS->getSizeInBits() &&
568 AlignInBits == RHS->getAlignInBits() &&
569 OffsetInBits == RHS->getOffsetInBits() &&
570 DWARFAddressSpace == RHS->getDWARFAddressSpace() &&
571 Flags == RHS->getFlags() && ExtraData == RHS->getRawExtraData() &&
572 Annotations == RHS->getRawAnnotations();
573 }
574
575 unsigned getHashValue() const {
576 // If this is a member inside an ODR type, only hash the type and the name.
577 // Otherwise the hash will be stronger than
578 // MDNodeSubsetEqualImpl::isODRMember().
579 if (Tag == dwarf::DW_TAG_member && Name)
580 if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
581 if (CT->getRawIdentifier())
582 return hash_combine(Name, Scope);
583
584 // Intentionally computes the hash on a subset of the operands for
585 // performance reason. The subset has to be significant enough to avoid
586 // collision "most of the time". There is no correctness issue in case of
587 // collision because of the full check above.
588 return hash_combine(Tag, Name, File, Line, Scope, BaseType, Flags);
589 }
590};
591
594
595 static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS) {
596 return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
597 }
598
599 static bool isSubsetEqual(const DIDerivedType *LHS,
600 const DIDerivedType *RHS) {
601 return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
602 RHS);
603 }
604
605 /// Subprograms compare equal if they declare the same function in an ODR
606 /// type.
607 static bool isODRMember(unsigned Tag, const Metadata *Scope,
608 const MDString *Name, const DIDerivedType *RHS) {
609 // Check whether the LHS is eligible.
610 if (Tag != dwarf::DW_TAG_member || !Name)
611 return false;
612
613 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
614 if (!CT || !CT->getRawIdentifier())
615 return false;
616
617 // Compare to the RHS.
618 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
619 Scope == RHS->getRawScope();
620 }
621};
622
623template <> struct MDNodeKeyImpl<DICompositeType> {
624 unsigned Tag;
627 unsigned Line;
633 unsigned Flags;
635 unsigned RuntimeLang;
645
646 MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
647 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
648 uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
649 Metadata *Elements, unsigned RuntimeLang,
650 Metadata *VTableHolder, Metadata *TemplateParams,
651 MDString *Identifier, Metadata *Discriminator,
652 Metadata *DataLocation, Metadata *Associated,
653 Metadata *Allocated, Metadata *Rank, Metadata *Annotations)
654 : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
655 BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
656 AlignInBits(AlignInBits), Flags(Flags), Elements(Elements),
657 RuntimeLang(RuntimeLang), VTableHolder(VTableHolder),
658 TemplateParams(TemplateParams), Identifier(Identifier),
659 Discriminator(Discriminator), DataLocation(DataLocation),
660 Associated(Associated), Allocated(Allocated), Rank(Rank),
663 : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
664 Line(N->getLine()), Scope(N->getRawScope()),
665 BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
666 OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
667 Flags(N->getFlags()), Elements(N->getRawElements()),
668 RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()),
669 TemplateParams(N->getRawTemplateParams()),
670 Identifier(N->getRawIdentifier()),
671 Discriminator(N->getRawDiscriminator()),
672 DataLocation(N->getRawDataLocation()),
673 Associated(N->getRawAssociated()), Allocated(N->getRawAllocated()),
674 Rank(N->getRawRank()), Annotations(N->getRawAnnotations()) {}
675
676 bool isKeyOf(const DICompositeType *RHS) const {
677 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
678 File == RHS->getRawFile() && Line == RHS->getLine() &&
679 Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
680 SizeInBits == RHS->getSizeInBits() &&
681 AlignInBits == RHS->getAlignInBits() &&
682 OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() &&
683 Elements == RHS->getRawElements() &&
684 RuntimeLang == RHS->getRuntimeLang() &&
685 VTableHolder == RHS->getRawVTableHolder() &&
686 TemplateParams == RHS->getRawTemplateParams() &&
687 Identifier == RHS->getRawIdentifier() &&
688 Discriminator == RHS->getRawDiscriminator() &&
689 DataLocation == RHS->getRawDataLocation() &&
690 Associated == RHS->getRawAssociated() &&
691 Allocated == RHS->getRawAllocated() && Rank == RHS->getRawRank() &&
692 Annotations == RHS->getRawAnnotations();
693 }
694
695 unsigned getHashValue() const {
696 // Intentionally computes the hash on a subset of the operands for
697 // performance reason. The subset has to be significant enough to avoid
698 // collision "most of the time". There is no correctness issue in case of
699 // collision because of the full check above.
700 return hash_combine(Name, File, Line, BaseType, Scope, Elements,
701 TemplateParams, Annotations);
702 }
703};
704
705template <> struct MDNodeKeyImpl<DISubroutineType> {
706 unsigned Flags;
707 uint8_t CC;
709
710 MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray)
711 : Flags(Flags), CC(CC), TypeArray(TypeArray) {}
713 : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {}
714
715 bool isKeyOf(const DISubroutineType *RHS) const {
716 return Flags == RHS->getFlags() && CC == RHS->getCC() &&
717 TypeArray == RHS->getRawTypeArray();
718 }
719
720 unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); }
721};
722
723template <> struct MDNodeKeyImpl<DIFile> {
726 std::optional<DIFile::ChecksumInfo<MDString *>> Checksum;
728
729 MDNodeKeyImpl(MDString *Filename, MDString *Directory,
730 std::optional<DIFile::ChecksumInfo<MDString *>> Checksum,
731 MDString *Source)
732 : Filename(Filename), Directory(Directory), Checksum(Checksum),
733 Source(Source) {}
735 : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
736 Checksum(N->getRawChecksum()), Source(N->getRawSource()) {}
737
738 bool isKeyOf(const DIFile *RHS) const {
739 return Filename == RHS->getRawFilename() &&
740 Directory == RHS->getRawDirectory() &&
741 Checksum == RHS->getRawChecksum() && Source == RHS->getRawSource();
742 }
743
744 unsigned getHashValue() const {
745 return hash_combine(Filename, Directory, Checksum ? Checksum->Kind : 0,
746 Checksum ? Checksum->Value : nullptr, Source);
747 }
748};
749
750template <> struct MDNodeKeyImpl<DISubprogram> {
755 unsigned Line;
757 unsigned ScopeLine;
759 unsigned VirtualIndex;
761 unsigned Flags;
762 unsigned SPFlags;
770
772 Metadata *File, unsigned Line, Metadata *Type,
773 unsigned ScopeLine, Metadata *ContainingType,
774 unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
775 unsigned SPFlags, Metadata *Unit, Metadata *TemplateParams,
776 Metadata *Declaration, Metadata *RetainedNodes,
777 Metadata *ThrownTypes, Metadata *Annotations,
778 MDString *TargetFuncName)
779 : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
780 Line(Line), Type(Type), ScopeLine(ScopeLine),
781 ContainingType(ContainingType), VirtualIndex(VirtualIndex),
782 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags),
783 Unit(Unit), TemplateParams(TemplateParams), Declaration(Declaration),
784 RetainedNodes(RetainedNodes), ThrownTypes(ThrownTypes),
785 Annotations(Annotations), TargetFuncName(TargetFuncName) {}
787 : Scope(N->getRawScope()), Name(N->getRawName()),
788 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
789 Line(N->getLine()), Type(N->getRawType()), ScopeLine(N->getScopeLine()),
790 ContainingType(N->getRawContainingType()),
791 VirtualIndex(N->getVirtualIndex()),
792 ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()),
793 SPFlags(N->getSPFlags()), Unit(N->getRawUnit()),
794 TemplateParams(N->getRawTemplateParams()),
795 Declaration(N->getRawDeclaration()),
796 RetainedNodes(N->getRawRetainedNodes()),
797 ThrownTypes(N->getRawThrownTypes()),
798 Annotations(N->getRawAnnotations()),
799 TargetFuncName(N->getRawTargetFuncName()) {}
800
801 bool isKeyOf(const DISubprogram *RHS) const {
802 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
803 LinkageName == RHS->getRawLinkageName() &&
804 File == RHS->getRawFile() && Line == RHS->getLine() &&
805 Type == RHS->getRawType() && ScopeLine == RHS->getScopeLine() &&
806 ContainingType == RHS->getRawContainingType() &&
807 VirtualIndex == RHS->getVirtualIndex() &&
808 ThisAdjustment == RHS->getThisAdjustment() &&
809 Flags == RHS->getFlags() && SPFlags == RHS->getSPFlags() &&
810 Unit == RHS->getUnit() &&
811 TemplateParams == RHS->getRawTemplateParams() &&
812 Declaration == RHS->getRawDeclaration() &&
813 RetainedNodes == RHS->getRawRetainedNodes() &&
814 ThrownTypes == RHS->getRawThrownTypes() &&
815 Annotations == RHS->getRawAnnotations() &&
816 TargetFuncName == RHS->getRawTargetFuncName();
817 }
818
819 bool isDefinition() const { return SPFlags & DISubprogram::SPFlagDefinition; }
820
821 unsigned getHashValue() const {
822 // If this is a declaration inside an ODR type, only hash the type and the
823 // name. Otherwise the hash will be stronger than
824 // MDNodeSubsetEqualImpl::isDeclarationOfODRMember().
825 if (!isDefinition() && LinkageName)
826 if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
827 if (CT->getRawIdentifier())
828 return hash_combine(LinkageName, Scope);
829
830 // Intentionally computes the hash on a subset of the operands for
831 // performance reason. The subset has to be significant enough to avoid
832 // collision "most of the time". There is no correctness issue in case of
833 // collision because of the full check above.
834 return hash_combine(Name, Scope, File, Type, Line);
835 }
836};
837
840
841 static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
842 return isDeclarationOfODRMember(LHS.isDefinition(), LHS.Scope,
843 LHS.LinkageName, LHS.TemplateParams, RHS);
844 }
845
846 static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) {
847 return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(),
848 LHS->getRawLinkageName(),
849 LHS->getRawTemplateParams(), RHS);
850 }
851
852 /// Subprograms compare equal if they declare the same function in an ODR
853 /// type.
854 static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope,
855 const MDString *LinkageName,
856 const Metadata *TemplateParams,
857 const DISubprogram *RHS) {
858 // Check whether the LHS is eligible.
859 if (IsDefinition || !Scope || !LinkageName)
860 return false;
861
862 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
863 if (!CT || !CT->getRawIdentifier())
864 return false;
865
866 // Compare to the RHS.
867 // FIXME: We need to compare template parameters here to avoid incorrect
868 // collisions in mapMetadata when RF_ReuseAndMutateDistinctMDs and a
869 // ODR-DISubprogram has a non-ODR template parameter (i.e., a
870 // DICompositeType that does not have an identifier). Eventually we should
871 // decouple ODR logic from uniquing logic.
872 return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() &&
873 LinkageName == RHS->getRawLinkageName() &&
874 TemplateParams == RHS->getRawTemplateParams();
875 }
876};
877
878template <> struct MDNodeKeyImpl<DILexicalBlock> {
881 unsigned Line;
882 unsigned Column;
883
884 MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
885 : Scope(Scope), File(File), Line(Line), Column(Column) {}
887 : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
888 Column(N->getColumn()) {}
889
890 bool isKeyOf(const DILexicalBlock *RHS) const {
891 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
892 Line == RHS->getLine() && Column == RHS->getColumn();
893 }
894
895 unsigned getHashValue() const {
896 return hash_combine(Scope, File, Line, Column);
897 }
898};
899
904
905 MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
906 : Scope(Scope), File(File), Discriminator(Discriminator) {}
908 : Scope(N->getRawScope()), File(N->getRawFile()),
909 Discriminator(N->getDiscriminator()) {}
910
911 bool isKeyOf(const DILexicalBlockFile *RHS) const {
912 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
913 Discriminator == RHS->getDiscriminator();
914 }
915
916 unsigned getHashValue() const {
917 return hash_combine(Scope, File, Discriminator);
918 }
919};
920
921template <> struct MDNodeKeyImpl<DINamespace> {
925
926 MDNodeKeyImpl(Metadata *Scope, MDString *Name, bool ExportSymbols)
927 : Scope(Scope), Name(Name), ExportSymbols(ExportSymbols) {}
929 : Scope(N->getRawScope()), Name(N->getRawName()),
930 ExportSymbols(N->getExportSymbols()) {}
931
932 bool isKeyOf(const DINamespace *RHS) const {
933 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
934 ExportSymbols == RHS->getExportSymbols();
935 }
936
937 unsigned getHashValue() const { return hash_combine(Scope, Name); }
938};
939
940template <> struct MDNodeKeyImpl<DICommonBlock> {
945 unsigned LineNo;
946
948 unsigned LineNo)
949 : Scope(Scope), Decl(Decl), Name(Name), File(File), LineNo(LineNo) {}
951 : Scope(N->getRawScope()), Decl(N->getRawDecl()), Name(N->getRawName()),
952 File(N->getRawFile()), LineNo(N->getLineNo()) {}
953
954 bool isKeyOf(const DICommonBlock *RHS) const {
955 return Scope == RHS->getRawScope() && Decl == RHS->getRawDecl() &&
956 Name == RHS->getRawName() && File == RHS->getRawFile() &&
957 LineNo == RHS->getLineNo();
958 }
959
960 unsigned getHashValue() const {
961 return hash_combine(Scope, Decl, Name, File, LineNo);
962 }
963};
964
965template <> struct MDNodeKeyImpl<DIModule> {
972 unsigned LineNo;
973 bool IsDecl;
974
976 MDString *ConfigurationMacros, MDString *IncludePath,
977 MDString *APINotesFile, unsigned LineNo, bool IsDecl)
978 : File(File), Scope(Scope), Name(Name),
979 ConfigurationMacros(ConfigurationMacros), IncludePath(IncludePath),
980 APINotesFile(APINotesFile), LineNo(LineNo), IsDecl(IsDecl) {}
982 : File(N->getRawFile()), Scope(N->getRawScope()), Name(N->getRawName()),
983 ConfigurationMacros(N->getRawConfigurationMacros()),
984 IncludePath(N->getRawIncludePath()),
985 APINotesFile(N->getRawAPINotesFile()), LineNo(N->getLineNo()),
986 IsDecl(N->getIsDecl()) {}
987
988 bool isKeyOf(const DIModule *RHS) const {
989 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
990 ConfigurationMacros == RHS->getRawConfigurationMacros() &&
991 IncludePath == RHS->getRawIncludePath() &&
992 APINotesFile == RHS->getRawAPINotesFile() &&
993 File == RHS->getRawFile() && LineNo == RHS->getLineNo() &&
994 IsDecl == RHS->getIsDecl();
995 }
996
997 unsigned getHashValue() const {
998 return hash_combine(Scope, Name, ConfigurationMacros, IncludePath);
999 }
1000};
1001
1006
1008 : Name(Name), Type(Type), IsDefault(IsDefault) {}
1010 : Name(N->getRawName()), Type(N->getRawType()),
1011 IsDefault(N->isDefault()) {}
1012
1014 return Name == RHS->getRawName() && Type == RHS->getRawType() &&
1015 IsDefault == RHS->isDefault();
1016 }
1017
1018 unsigned getHashValue() const { return hash_combine(Name, Type, IsDefault); }
1019};
1020
1022 unsigned Tag;
1027
1028 MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, bool IsDefault,
1029 Metadata *Value)
1030 : Tag(Tag), Name(Name), Type(Type), IsDefault(IsDefault), Value(Value) {}
1032 : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
1033 IsDefault(N->isDefault()), Value(N->getValue()) {}
1034
1036 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
1037 Type == RHS->getRawType() && IsDefault == RHS->isDefault() &&
1038 Value == RHS->getValue();
1039 }
1040
1041 unsigned getHashValue() const {
1042 return hash_combine(Tag, Name, Type, IsDefault, Value);
1043 }
1044};
1045
1046template <> struct MDNodeKeyImpl<DIGlobalVariable> {
1051 unsigned Line;
1059
1061 Metadata *File, unsigned Line, Metadata *Type,
1062 bool IsLocalToUnit, bool IsDefinition,
1063 Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
1064 uint32_t AlignInBits, Metadata *Annotations)
1065 : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
1066 Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
1067 IsDefinition(IsDefinition),
1068 StaticDataMemberDeclaration(StaticDataMemberDeclaration),
1069 TemplateParams(TemplateParams), AlignInBits(AlignInBits),
1072 : Scope(N->getRawScope()), Name(N->getRawName()),
1073 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
1074 Line(N->getLine()), Type(N->getRawType()),
1075 IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
1076 StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
1077 TemplateParams(N->getRawTemplateParams()),
1078 AlignInBits(N->getAlignInBits()), Annotations(N->getRawAnnotations()) {}
1079
1080 bool isKeyOf(const DIGlobalVariable *RHS) const {
1081 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1082 LinkageName == RHS->getRawLinkageName() &&
1083 File == RHS->getRawFile() && Line == RHS->getLine() &&
1084 Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
1085 IsDefinition == RHS->isDefinition() &&
1086 StaticDataMemberDeclaration ==
1087 RHS->getRawStaticDataMemberDeclaration() &&
1088 TemplateParams == RHS->getRawTemplateParams() &&
1089 AlignInBits == RHS->getAlignInBits() &&
1090 Annotations == RHS->getRawAnnotations();
1091 }
1092
1093 unsigned getHashValue() const {
1094 // We do not use AlignInBits in hashing function here on purpose:
1095 // in most cases this param for local variable is zero (for function param
1096 // it is always zero). This leads to lots of hash collisions and errors on
1097 // cases with lots of similar variables.
1098 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
1099 // generated IR is random for each run and test fails with Align included.
1100 // TODO: make hashing work fine with such situations
1101 return hash_combine(Scope, Name, LinkageName, File, Line, Type,
1102 IsLocalToUnit, IsDefinition, /* AlignInBits, */
1103 StaticDataMemberDeclaration, Annotations);
1104 }
1105};
1106
1107template <> struct MDNodeKeyImpl<DILocalVariable> {
1111 unsigned Line;
1113 unsigned Arg;
1114 unsigned Flags;
1117
1118 MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
1119 Metadata *Type, unsigned Arg, unsigned Flags,
1120 uint32_t AlignInBits, Metadata *Annotations)
1121 : Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
1122 Flags(Flags), AlignInBits(AlignInBits), Annotations(Annotations) {}
1124 : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
1125 Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
1126 Flags(N->getFlags()), AlignInBits(N->getAlignInBits()),
1127 Annotations(N->getRawAnnotations()) {}
1128
1129 bool isKeyOf(const DILocalVariable *RHS) const {
1130 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1131 File == RHS->getRawFile() && Line == RHS->getLine() &&
1132 Type == RHS->getRawType() && Arg == RHS->getArg() &&
1133 Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits() &&
1134 Annotations == RHS->getRawAnnotations();
1135 }
1136
1137 unsigned getHashValue() const {
1138 // We do not use AlignInBits in hashing function here on purpose:
1139 // in most cases this param for local variable is zero (for function param
1140 // it is always zero). This leads to lots of hash collisions and errors on
1141 // cases with lots of similar variables.
1142 // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
1143 // generated IR is random for each run and test fails with Align included.
1144 // TODO: make hashing work fine with such situations
1145 return hash_combine(Scope, Name, File, Line, Type, Arg, Flags, Annotations);
1146 }
1147};
1148
1149template <> struct MDNodeKeyImpl<DILabel> {
1153 unsigned Line;
1154
1155 MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line)
1156 : Scope(Scope), Name(Name), File(File), Line(Line) {}
1158 : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
1159 Line(N->getLine()) {}
1160
1161 bool isKeyOf(const DILabel *RHS) const {
1162 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
1163 File == RHS->getRawFile() && Line == RHS->getLine();
1164 }
1165
1166 /// Using name and line to get hash value. It should already be mostly unique.
1167 unsigned getHashValue() const { return hash_combine(Scope, Name, Line); }
1168};
1169
1170template <> struct MDNodeKeyImpl<DIExpression> {
1172
1173 MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
1174 MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
1175
1176 bool isKeyOf(const DIExpression *RHS) const {
1177 return Elements == RHS->getElements();
1178 }
1179
1180 unsigned getHashValue() const {
1181 return hash_combine_range(Elements.begin(), Elements.end());
1182 }
1183};
1184
1188
1190 : Variable(Variable), Expression(Expression) {}
1192 : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {}
1193
1195 return Variable == RHS->getRawVariable() &&
1196 Expression == RHS->getRawExpression();
1197 }
1198
1199 unsigned getHashValue() const { return hash_combine(Variable, Expression); }
1200};
1201
1202template <> struct MDNodeKeyImpl<DIObjCProperty> {
1205 unsigned Line;
1208 unsigned Attributes;
1210
1211 MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line,
1212 MDString *GetterName, MDString *SetterName, unsigned Attributes,
1213 Metadata *Type)
1214 : Name(Name), File(File), Line(Line), GetterName(GetterName),
1215 SetterName(SetterName), Attributes(Attributes), Type(Type) {}
1217 : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
1218 GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()),
1219 Attributes(N->getAttributes()), Type(N->getRawType()) {}
1220
1221 bool isKeyOf(const DIObjCProperty *RHS) const {
1222 return Name == RHS->getRawName() && File == RHS->getRawFile() &&
1223 Line == RHS->getLine() && GetterName == RHS->getRawGetterName() &&
1224 SetterName == RHS->getRawSetterName() &&
1225 Attributes == RHS->getAttributes() && Type == RHS->getRawType();
1226 }
1227
1228 unsigned getHashValue() const {
1229 return hash_combine(Name, File, Line, GetterName, SetterName, Attributes,
1230 Type);
1231 }
1232};
1233
1234template <> struct MDNodeKeyImpl<DIImportedEntity> {
1235 unsigned Tag;
1239 unsigned Line;
1242
1243 MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, Metadata *File,
1244 unsigned Line, MDString *Name, Metadata *Elements)
1245 : Tag(Tag), Scope(Scope), Entity(Entity), File(File), Line(Line),
1246 Name(Name), Elements(Elements) {}
1248 : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
1249 File(N->getRawFile()), Line(N->getLine()), Name(N->getRawName()),
1250 Elements(N->getRawElements()) {}
1251
1252 bool isKeyOf(const DIImportedEntity *RHS) const {
1253 return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
1254 Entity == RHS->getRawEntity() && File == RHS->getFile() &&
1255 Line == RHS->getLine() && Name == RHS->getRawName() &&
1256 Elements == RHS->getRawElements();
1257 }
1258
1259 unsigned getHashValue() const {
1260 return hash_combine(Tag, Scope, Entity, File, Line, Name, Elements);
1261 }
1262};
1263
1264template <> struct MDNodeKeyImpl<DIMacro> {
1265 unsigned MIType;
1266 unsigned Line;
1269
1270 MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value)
1271 : MIType(MIType), Line(Line), Name(Name), Value(Value) {}
1273 : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()),
1274 Value(N->getRawValue()) {}
1275
1276 bool isKeyOf(const DIMacro *RHS) const {
1277 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
1278 Name == RHS->getRawName() && Value == RHS->getRawValue();
1279 }
1280
1281 unsigned getHashValue() const {
1282 return hash_combine(MIType, Line, Name, Value);
1283 }
1284};
1285
1286template <> struct MDNodeKeyImpl<DIMacroFile> {
1287 unsigned MIType;
1288 unsigned Line;
1291
1292 MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File,
1293 Metadata *Elements)
1294 : MIType(MIType), Line(Line), File(File), Elements(Elements) {}
1296 : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()),
1297 Elements(N->getRawElements()) {}
1298
1299 bool isKeyOf(const DIMacroFile *RHS) const {
1300 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
1301 File == RHS->getRawFile() && Elements == RHS->getRawElements();
1302 }
1303
1304 unsigned getHashValue() const {
1305 return hash_combine(MIType, Line, File, Elements);
1306 }
1307};
1308
1309// DIArgLists are not MDNodes, but we still want to unique them in a DenseSet
1310// based on a hash of their arguments.
1313
1315 DIArgListKeyInfo(const DIArgList *N) : Args(N->getArgs()) {}
1316
1317 bool isKeyOf(const DIArgList *RHS) const { return Args == RHS->getArgs(); }
1318
1319 unsigned getHashValue() const {
1320 return hash_combine_range(Args.begin(), Args.end());
1321 }
1322};
1323
1324/// DenseMapInfo for DIArgList.
1327
1328 static inline DIArgList *getEmptyKey() {
1330 }
1331
1332 static inline DIArgList *getTombstoneKey() {
1334 }
1335
1336 static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
1337
1338 static unsigned getHashValue(const DIArgList *N) {
1339 return KeyTy(N).getHashValue();
1340 }
1341
1342 static bool isEqual(const KeyTy &LHS, const DIArgList *RHS) {
1343 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1344 return false;
1345 return LHS.isKeyOf(RHS);
1346 }
1347
1348 static bool isEqual(const DIArgList *LHS, const DIArgList *RHS) {
1349 return LHS == RHS;
1350 }
1351};
1352
1353/// DenseMapInfo for MDNode subclasses.
1354template <class NodeTy> struct MDNodeInfo {
1357
1358 static inline NodeTy *getEmptyKey() {
1360 }
1361
1362 static inline NodeTy *getTombstoneKey() {
1364 }
1365
1366 static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
1367
1368 static unsigned getHashValue(const NodeTy *N) {
1369 return KeyTy(N).getHashValue();
1370 }
1371
1372 static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
1373 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1374 return false;
1375 return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS);
1376 }
1377
1378 static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
1379 if (LHS == RHS)
1380 return true;
1381 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1382 return false;
1384 }
1385};
1386
1387#define HANDLE_MDNODE_LEAF(CLASS) using CLASS##Info = MDNodeInfo<CLASS>;
1388#include "llvm/IR/Metadata.def"
1389
1390/// Multimap-like storage for metadata attachments.
1392public:
1393 struct Attachment {
1394 unsigned MDKind;
1396 };
1397
1398private:
1399 SmallVector<Attachment, 1> Attachments;
1400
1401public:
1402 bool empty() const { return Attachments.empty(); }
1403 size_t size() const { return Attachments.size(); }
1404
1405 /// Returns the first attachment with the given ID or nullptr if no such
1406 /// attachment exists.
1407 MDNode *lookup(unsigned ID) const;
1408
1409 /// Appends all attachments with the given ID to \c Result in insertion order.
1410 /// If the global has no attachments with the given ID, or if ID is invalid,
1411 /// leaves Result unchanged.
1412 void get(unsigned ID, SmallVectorImpl<MDNode *> &Result) const;
1413
1414 /// Appends all attachments for the global to \c Result, sorting by attachment
1415 /// ID. Attachments with the same ID appear in insertion order. This function
1416 /// does \em not clear \c Result.
1417 void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
1418
1419 /// Set an attachment to a particular node.
1420 ///
1421 /// Set the \c ID attachment to \c MD, replacing the current attachments at \c
1422 /// ID (if anyway).
1423 void set(unsigned ID, MDNode *MD);
1424
1425 /// Adds an attachment to a particular node.
1426 void insert(unsigned ID, MDNode &MD);
1427
1428 /// Remove attachments with the given ID.
1429 ///
1430 /// Remove the attachments at \c ID, if any.
1431 bool erase(unsigned ID);
1432
1433 /// Erase matching attachments.
1434 ///
1435 /// Erases all attachments matching the \c shouldRemove predicate.
1436 template <class PredTy> void remove_if(PredTy shouldRemove) {
1437 llvm::erase_if(Attachments, shouldRemove);
1438 }
1439};
1440
1442public:
1443 /// OwnedModules - The set of modules instantiated in this context, and which
1444 /// will be automatically deleted if this context is deleted.
1446
1447 /// The main remark streamer used by all the other streamers (e.g. IR, MIR,
1448 /// frontends, etc.). This should only be used by the specific streamers, and
1449 /// never directly.
1450 std::unique_ptr<remarks::RemarkStreamer> MainRemarkStreamer;
1451
1452 std::unique_ptr<DiagnosticHandler> DiagHandler;
1455 /// The minimum hotness value a diagnostic needs in order to be included in
1456 /// optimization diagnostics.
1457 ///
1458 /// The threshold is an Optional value, which maps to one of the 3 states:
1459 /// 1). 0 => threshold disabled. All emarks will be printed.
1460 /// 2). positive int => manual threshold by user. Remarks with hotness exceed
1461 /// threshold will be printed.
1462 /// 3). None => 'auto' threshold by user. The actual value is not
1463 /// available at command line, but will be synced with
1464 /// hotness threhold from profile summary during
1465 /// compilation.
1466 ///
1467 /// State 1 and 2 are considered as terminal states. State transition is
1468 /// only allowed from 3 to 2, when the threshold is first synced with profile
1469 /// summary. This ensures that the threshold is set only once and stays
1470 /// constant.
1471 ///
1472 /// If threshold option is not specified, it is disabled (0) by default.
1473 std::optional<uint64_t> DiagnosticsHotnessThreshold = 0;
1474
1475 /// The percentage of difference between profiling branch weights and
1476 /// llvm.expect branch weights to tolerate when emiting MisExpect diagnostics
1477 std::optional<uint32_t> DiagnosticsMisExpectTolerance = 0;
1479
1480 /// The specialized remark streamer used by LLVM's OptimizationRemarkEmitter.
1481 std::unique_ptr<LLVMRemarkStreamer> LLVMRS;
1482
1484 void *YieldOpaqueHandle = nullptr;
1485
1487
1491
1493
1497
1502
1503#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
1504 DenseSet<CLASS *, CLASS##Info> CLASS##s;
1505#include "llvm/IR/Metadata.def"
1506
1507 // Optional map for looking up composite types by identifier.
1508 std::optional<DenseMap<const MDString *, DICompositeType *>> DITypeMap;
1509
1510 // MDNodes may be uniqued or not uniqued. When they're not uniqued, they
1511 // aren't in the MDNodeSet, but they're still shared between objects, so no
1512 // one object can destroy them. Keep track of them here so we can delete
1513 // them on context teardown.
1514 std::vector<MDNode *> DistinctMDNodes;
1515
1517
1520
1523
1526
1528
1530
1532
1534
1536
1539
1541
1543
1545
1547
1550
1551 // Basic type instances.
1556
1557 std::unique_ptr<ConstantTokenNone> TheNoneToken;
1558
1561
1563
1570
1573
1576 PointerType *AS0PointerType = nullptr; // AddrSpace = 0
1580
1581 /// ValueHandles - This map keeps track of all of the value handles that are
1582 /// watching a Value*. The Value::HasValueHandle bit is used to know
1583 /// whether or not a value has an entry in this map.
1586
1587 /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
1589
1590 /// Collection of metadata used in this context.
1592
1593 /// Map DIAssignID -> Instructions with that attachment.
1594 /// Managed by Instruction via Instruction::updateDIAssignIDMapping.
1595 /// Query using the at:: functions defined in DebugInfo.h.
1597
1598 /// Collection of per-GlobalObject sections used in this context.
1600
1601 /// Collection of per-GlobalValue partitions used in this context.
1603
1606
1607 /// DiscriminatorTable - This table maps file:line locations to an
1608 /// integer representing the next DWARF path discriminator to assign to
1609 /// instructions in different blocks at the same location.
1611
1612 /// A set of interned tags for operand bundles. The StringMap maps
1613 /// bundle tags to their IDs.
1614 ///
1615 /// \see LLVMContext::getOperandBundleTagID
1617
1621
1622 /// A set of interned synchronization scopes. The StringMap maps
1623 /// synchronization scope names to their respective synchronization scope IDs.
1625
1626 /// getOrInsertSyncScopeID - Maps synchronization scope name to
1627 /// synchronization scope ID. Every synchronization scope registered with
1628 /// LLVMContext has unique ID except pre-defined ones.
1630
1631 /// getSyncScopeNames - Populates client supplied SmallVector with
1632 /// synchronization scope names registered with LLVMContext. Synchronization
1633 /// scope names are ordered by increasing synchronization scope IDs.
1635
1636 /// Maintain the GC name for each function.
1637 ///
1638 /// This saves allocating an additional word in Function for programs which
1639 /// do not use GC (i.e., most programs) at the cost of increased overhead for
1640 /// clients which do use GC.
1642
1643 /// Flag to indicate if Value (other than GlobalValue) retains their name or
1644 /// not.
1645 bool DiscardValueNames = false;
1646
1649
1650 /// Destroy the ConstantArrays if they are not used.
1652
1653 mutable OptPassGate *OPG = nullptr;
1654
1655 /// Access the object which can disable optional passes and individual
1656 /// optimizations at compile time.
1657 OptPassGate &getOptPassGate() const;
1658
1659 /// Set the object which can disable optional passes and individual
1660 /// optimizations at compile time.
1661 ///
1662 /// The lifetime of the object must be guaranteed to extend as long as the
1663 /// LLVMContext is used by compilation.
1665
1666 /// Mapping of blocks to collections of "trailing" DPValues. As part of the
1667 /// "RemoveDIs" project, debug-info variable location records are going to
1668 /// cease being instructions... which raises the problem of where should they
1669 /// be recorded when we remove the terminator of a blocks, such as:
1670 ///
1671 /// %foo = add i32 0, 0
1672 /// br label %bar
1673 ///
1674 /// If the branch is removed, a legitimate transient state while editing a
1675 /// block, any debug-records between those two instructions will not have a
1676 /// location. Each block thus records any DPValue records that "trail" in
1677 /// such a way. These are stored in LLVMContext because typically LLVM only
1678 /// edits a small number of blocks at a time, so there's no need to bloat
1679 /// BasicBlock with such a data structure.
1681
1682 // Set, get and delete operations for TrailingDPValues.
1684 assert(!TrailingDPValues.count(B));
1685 TrailingDPValues[B] = M;
1686 }
1687
1689 return TrailingDPValues.lookup(B);
1690 }
1691
1693 TrailingDPValues.erase(B);
1694 }
1695};
1696
1697} // end namespace llvm
1698
1699#endif // LLVM_LIB_IR_LLVMCONTEXTIMPL_H
This file defines the StringMap class.
AMDGPU Kernel Attributes
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< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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.
std::string Name
This file defines a hash set that can be used to remove duplication of nodes in a graph.
This file contains the declarations for metadata subclasses.
Module.h This file contains the declarations for the Module class.
#define P(N)
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:27
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition: APInt.h:76
Annotations lets you mark points and ranges inside source code, for tests:
Definition: Annotations.h:53
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
iterator end() const
Definition: ArrayRef.h:154
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
iterator begin() const
Definition: ArrayRef.h:153
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:160
Class to represent array types.
Definition: DerivedTypes.h:371
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
The address of a basic block.
Definition: Constants.h:874
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
Constant * getValue() const
Definition: Metadata.h:536
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
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:152
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.
Debug location.
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.
Array subrange.
Type array for a subprogram.
Per-instruction record of debug-info.
Implements a dense probed hash-table based set.
Definition: DenseSet.h:271
Class representing an expression and its matching format.
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
Definition: FoldingSet.h:521
Class to represent function types.
Definition: DerivedTypes.h:103
Generic tagged DWARF-like metadata node.
Class to represent integer types.
Definition: DerivedTypes.h:40
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< 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< PointerType *, std::unique_ptr< ConstantPointerNull > > CPNConstants
DenseMap< Type *, std::unique_ptr< ConstantAggregateZero > > CAZConstants
StringMap< MDString, BumpPtrAllocator > MDStringCache
TargetExtTypeSet TargetExtTypes
void setTrailingDPValues(BasicBlock *B, DPMarker *M)
DenseMap< DIAssignID *, SmallVector< Instruction *, 1 > > AssignmentIDToInstrs
Map DIAssignID -> Instructions with that attachment.
DenseMap< Type *, std::unique_ptr< PoisonValue > > PVConstants
DenseMap< std::pair< const Function *, const BasicBlock * >, BlockAddress * > BlockAddresses
DenseMap< APInt, std::unique_ptr< ConstantInt > > IntConstants
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
void deleteTrailingDPValues(BasicBlock *B)
SyncScope::ID getOrInsertSyncScopeID(StringRef SSN)
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID.
void dropTriviallyDeadConstantArrays()
Destroy the ConstantArrays if they are not used.
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
SmallDenseMap< BasicBlock *, DPMarker * > TrailingDPValues
Mapping of blocks to collections of "trailing" DPValues.
DenseMap< const Function *, std::string > GCNames
Maintain the GC name for each function.
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
DenseMap< const Value *, MDAttachments > ValueMetadata
Collection of metadata used in this context.
StringMap< unsigned > CustomMDKindNames
CustomMDKindNames - Map to hold the metadata string to ID mapping.
StringMapEntry< uint32_t > * getOrInsertBundleTag(StringRef Tag)
std::unique_ptr< DiagnosticHandler > DiagHandler
StringMap< uint32_t > BundleTagCache
A set of interned tags for operand bundles.
BumpPtrAllocator Alloc
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
FoldingSet< AttributeSetNode > AttrsSetNodes
FoldingSet< AttributeListImpl > AttrsLists
DenseMap< TargetExtType *, std::unique_ptr< ConstantTargetNone > > CTNConstants
std::optional< uint64_t > DiagnosticsHotnessThreshold
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
ConstantUniqueMap< ConstantExpr > ExprConstants
uint32_t getOperandBundleTagID(StringRef Tag) const
DenseMap< std::pair< Type *, unsigned >, PointerType * > LegacyPointerTypes
StringMap< SyncScope::ID > SSC
A set of interned synchronization scopes.
DenseMap< unsigned, PointerType * > PointerTypes
UniqueStringSaver Saver
LLVMContext::YieldCallbackTy YieldCallback
DenseMap< unsigned, IntegerType * > IntegerTypes
StringMap< StructType * > NamedStructTypes
PointerType * AS0PointerType
DenseSet< DIArgList *, DIArgListInfo > DIArgLists
ValueHandlesTy ValueHandles
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...
DenseMap< const GlobalValue *, DSOLocalEquivalent * > DSOLocalEquivalents
DPMarker * getTrailingDPValues(BasicBlock *B)
FunctionTypeSet FunctionTypes
std::optional< DenseMap< const MDString *, DICompositeType * > > DITypeMap
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
void(*)(LLVMContext *Context, void *OpaqueHandle) YieldCallbackTy
Defines the type of a yield callback.
Definition: LLVMContext.h:160
Multimap-like storage for metadata attachments.
void insert(unsigned ID, MDNode &MD)
Adds an attachment to a particular node.
Definition: Metadata.cpp:1432
void remove_if(PredTy shouldRemove)
Erase matching attachments.
void get(unsigned ID, SmallVectorImpl< MDNode * > &Result) const
Appends all attachments with the given ID to Result in insertion order.
Definition: Metadata.cpp:1409
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * > > &Result) const
Appends all attachments for the global to Result, sorting by attachment ID.
Definition: Metadata.cpp:1415
void set(unsigned ID, MDNode *MD)
Set an attachment to a particular node.
Definition: Metadata.cpp:1426
MDNode * lookup(unsigned ID) const
Returns the first attachment with the given ID or nullptr if no such attachment exists.
Definition: Metadata.cpp:1402
bool erase(unsigned ID)
Remove attachments with the given ID.
Definition: Metadata.cpp:1436
Structure for hashing arbitrary MDNode operands.
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:1067
A single uniqued string.
Definition: Metadata.h:720
Tuple of metadata.
Definition: Metadata.h:1470
Root of the metadata hierarchy.
Definition: Metadata.h:62
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
Definition: OptBisect.h:24
Class to represent pointers.
Definition: DerivedTypes.h:646
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:427
bool empty() const
Definition: SmallVector.h:94
size_t size() const
Definition: SmallVector.h:91
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
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:128
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Class to represent struct types.
Definition: DerivedTypes.h:216
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:720
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
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:44
LLVM Value Representation.
Definition: Value.h:74
Base class of all SIMD vector types.
Definition: DerivedTypes.h:403
unsigned getTag(StringRef TagString)
Definition: Dwarf.cpp:32
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
hash_code hash_value(const FixedPointSemantics &Val)
Definition: APFixedPoint.h:128
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
Definition: STLExtras.h:2025
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:613
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:491
#define N
static const fltSemantics & Bogus() LLVM_READNONE
A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real.
Definition: APFloat.cpp:266
KeyTy(const ArrayRef< Type * > &E, bool P)
bool operator==(const KeyTy &that) const
bool operator!=(const KeyTy &that) const
static StructType * getEmptyKey()
static bool isEqual(const StructType *LHS, const StructType *RHS)
static unsigned getHashValue(const StructType *ST)
static unsigned getHashValue(const KeyTy &Key)
static StructType * getTombstoneKey()
static bool isEqual(const KeyTy &LHS, const StructType *RHS)
DenseMapInfo for DIArgList.
static unsigned getHashValue(const KeyTy &Key)
static DIArgList * getEmptyKey()
static unsigned getHashValue(const DIArgList *N)
static bool isEqual(const DIArgList *LHS, const DIArgList *RHS)
DIArgListKeyInfo KeyTy
static DIArgList * getTombstoneKey()
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 APFloat getTombstoneKey()
static unsigned getHashValue(const APFloat &Key)
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:50
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 FunctionType * getTombstoneKey()
static bool isEqual(const KeyTy &LHS, const FunctionType *RHS)
static unsigned getHashValue(const KeyTy &Key)
static bool isEqual(const FunctionType *LHS, const FunctionType *RHS)
static FunctionType * getEmptyKey()
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)
MDNodeKeyImpl< NodeTy > KeyTy
static NodeTy * getTombstoneKey()
static NodeTy * getEmptyKey()
bool isKeyOf(const DIBasicType *RHS) const
MDNodeKeyImpl(const DIBasicType *N)
MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding, unsigned Flags)
bool isKeyOf(const DICommonBlock *RHS) const
MDNodeKeyImpl(const DICommonBlock *N)
MDNodeKeyImpl(Metadata *Scope, Metadata *Decl, MDString *Name, Metadata *File, unsigned LineNo)
MDNodeKeyImpl(const DICompositeType *N)
bool isKeyOf(const DICompositeType *RHS) const
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t 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)
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, std::optional< unsigned > DWARFAddressSpace, unsigned Flags, Metadata *ExtraData, Metadata *Annotations)
MDNodeKeyImpl(const DIDerivedType *N)
bool isKeyOf(const DIDerivedType *RHS) const
std::optional< unsigned > DWARFAddressSpace
MDNodeKeyImpl(APInt Value, bool IsUnsigned, MDString *Name)
MDNodeKeyImpl(int64_t Value, bool IsUnsigned, MDString *Name)
bool isKeyOf(const DIEnumerator *RHS) const
MDNodeKeyImpl(const DIEnumerator *N)
bool isKeyOf(const DIExpression *RHS) const
MDNodeKeyImpl(const DIExpression *N)
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)
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
MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line)
MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
MDNodeKeyImpl(const DILexicalBlockFile *N)
bool isKeyOf(const DILexicalBlockFile *RHS) const
bool isKeyOf(const DILexicalBlock *RHS) const
MDNodeKeyImpl(const DILexicalBlock *N)
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, unsigned Column, Metadata *Scope, Metadata *InlinedAt, bool ImplicitCode)
MDNodeKeyImpl(const DILocation *L)
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(const DINamespace *N)
MDNodeKeyImpl(Metadata *Scope, MDString *Name, bool ExportSymbols)
bool isKeyOf(const DINamespace *RHS) const
MDNodeKeyImpl(const DIObjCProperty *N)
bool isKeyOf(const DIObjCProperty *RHS) const
MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line, MDString *GetterName, MDString *SetterName, unsigned Attributes, Metadata *Type)
MDNodeKeyImpl(const DIStringType *N)
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *StringLength, Metadata *StringLengthExp, Metadata *StringLocationExp, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding)
bool isKeyOf(const DIStringType *RHS) const
MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex, int ThisAdjustment, unsigned Flags, unsigned SPFlags, Metadata *Unit, Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes, Metadata *ThrownTypes, Metadata *Annotations, MDString *TargetFuncName)
bool isKeyOf(const DISubprogram *RHS) const
MDNodeKeyImpl(const DISubprogram *N)
MDNodeKeyImpl(Metadata *CountNode, Metadata *LowerBound, Metadata *UpperBound, Metadata *Stride)
bool isKeyOf(const DISubrange *RHS) const
MDNodeKeyImpl(const DISubrange *N)
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)
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)
static TargetExtType * getTombstoneKey()
static TargetExtType * getEmptyKey()