LCOV - code coverage report
Current view: top level - lib/IR - LLVMContextImpl.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 579 797 72.6 %
Date: 2018-10-20 13:21:21 Functions: 73 126 57.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- LLVMContextImpl.h - The LLVMContextImpl opaque class -----*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : //  This file declares LLVMContextImpl, the opaque implementation
      11             : //  of LLVMContext.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #ifndef LLVM_LIB_IR_LLVMCONTEXTIMPL_H
      16             : #define LLVM_LIB_IR_LLVMCONTEXTIMPL_H
      17             : 
      18             : #include "AttributeImpl.h"
      19             : #include "ConstantsContext.h"
      20             : #include "llvm/ADT/APFloat.h"
      21             : #include "llvm/ADT/APInt.h"
      22             : #include "llvm/ADT/ArrayRef.h"
      23             : #include "llvm/ADT/DenseMap.h"
      24             : #include "llvm/ADT/DenseMapInfo.h"
      25             : #include "llvm/ADT/DenseSet.h"
      26             : #include "llvm/ADT/FoldingSet.h"
      27             : #include "llvm/ADT/Hashing.h"
      28             : #include "llvm/ADT/Optional.h"
      29             : #include "llvm/ADT/STLExtras.h"
      30             : #include "llvm/ADT/SmallPtrSet.h"
      31             : #include "llvm/ADT/SmallVector.h"
      32             : #include "llvm/ADT/StringMap.h"
      33             : #include "llvm/ADT/StringRef.h"
      34             : #include "llvm/ADT/StringSet.h"
      35             : #include "llvm/BinaryFormat/Dwarf.h"
      36             : #include "llvm/IR/Constants.h"
      37             : #include "llvm/IR/DebugInfoMetadata.h"
      38             : #include "llvm/IR/DerivedTypes.h"
      39             : #include "llvm/IR/LLVMContext.h"
      40             : #include "llvm/IR/Metadata.h"
      41             : #include "llvm/IR/TrackingMDRef.h"
      42             : #include "llvm/Support/Allocator.h"
      43             : #include "llvm/Support/Casting.h"
      44             : #include "llvm/Support/YAMLTraits.h"
      45             : #include <algorithm>
      46             : #include <cassert>
      47             : #include <cstddef>
      48             : #include <cstdint>
      49             : #include <memory>
      50             : #include <string>
      51             : #include <utility>
      52             : #include <vector>
      53             : 
      54             : namespace llvm {
      55             : 
      56             : class ConstantFP;
      57             : class ConstantInt;
      58             : class Type;
      59             : class Value;
      60             : class ValueHandleBase;
      61             : 
      62             : struct DenseMapAPIntKeyInfo {
      63             :   static inline APInt getEmptyKey() {
      64             :     APInt V(nullptr, 0);
      65             :     V.U.VAL = 0;
      66             :     return V;
      67             :   }
      68             : 
      69             :   static inline APInt getTombstoneKey() {
      70             :     APInt V(nullptr, 0);
      71       89769 :     V.U.VAL = 1;
      72             :     return V;
      73             :   }
      74             : 
      75             :   static unsigned getHashValue(const APInt &Key) {
      76    94492025 :     return static_cast<unsigned>(hash_value(Key));
      77             :   }
      78             : 
      79   543403464 :   static bool isEqual(const APInt &LHS, const APInt &RHS) {
      80   657958512 :     return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
      81             :   }
      82             : };
      83             : 
      84             : struct DenseMapAPFloatKeyInfo {
      85      243147 :   static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); }
      86       13463 :   static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus(), 2); }
      87             : 
      88             :   static unsigned getHashValue(const APFloat &Key) {
      89      190252 :     return static_cast<unsigned>(hash_value(Key));
      90             :   }
      91             : 
      92             :   static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
      93     1248822 :     return LHS.bitwiseIsEqual(RHS);
      94             :   }
      95             : };
      96             : 
      97             : struct AnonStructTypeKeyInfo {
      98             :   struct KeyTy {
      99             :     ArrayRef<Type*> ETypes;
     100             :     bool isPacked;
     101             : 
     102      472901 :     KeyTy(const ArrayRef<Type*>& E, bool P) :
     103      472901 :       ETypes(E), isPacked(P) {}
     104             : 
     105             :     KeyTy(const StructType *ST)
     106      932436 :         : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
     107             : 
     108      450483 :     bool operator==(const KeyTy& that) const {
     109      450483 :       if (isPacked != that.isPacked)
     110             :         return false;
     111      450262 :       if (ETypes != that.ETypes)
     112        8255 :         return false;
     113             :       return true;
     114             :     }
     115             :     bool operator!=(const KeyTy& that) const {
     116             :       return !this->operator==(that);
     117             :     }
     118             :   };
     119             : 
     120             :   static inline StructType* getEmptyKey() {
     121             :     return DenseMapInfo<StructType*>::getEmptyKey();
     122             :   }
     123             : 
     124             :   static inline StructType* getTombstoneKey() {
     125             :     return DenseMapInfo<StructType*>::getTombstoneKey();
     126             :   }
     127             : 
     128      491391 :   static unsigned getHashValue(const KeyTy& Key) {
     129      491391 :     return hash_combine(hash_combine_range(Key.ETypes.begin(),
     130      982782 :                                            Key.ETypes.end()),
     131      491391 :                         Key.isPacked);
     132             :   }
     133             : 
     134       31470 :   static unsigned getHashValue(const StructType *ST) {
     135       31470 :     return getHashValue(KeyTy(ST));
     136             :   }
     137             : 
     138      468397 :   static bool isEqual(const KeyTy& LHS, const StructType *RHS) {
     139      468397 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
     140             :       return false;
     141      450483 :     return LHS == KeyTy(RHS);
     142             :   }
     143             : 
     144             :   static bool isEqual(const StructType *LHS, const StructType *RHS) {
     145       60013 :     return LHS == RHS;
     146             :   }
     147             : };
     148             : 
     149             : struct FunctionTypeKeyInfo {
     150             :   struct KeyTy {
     151             :     const Type *ReturnType;
     152             :     ArrayRef<Type*> Params;
     153             :     bool isVarArg;
     154             : 
     155     8240281 :     KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) :
     156     8240281 :       ReturnType(R), Params(P), isVarArg(V) {}
     157             :     KeyTy(const FunctionType *FT)
     158    29359263 :         : ReturnType(FT->getReturnType()), Params(FT->params()),
     159    15348913 :           isVarArg(FT->isVarArg()) {}
     160             : 
     161    14010350 :     bool operator==(const KeyTy& that) const {
     162    14010350 :       if (ReturnType != that.ReturnType)
     163             :         return false;
     164    10103195 :       if (isVarArg != that.isVarArg)
     165             :         return false;
     166    10091037 :       if (Params != that.Params)
     167     2614807 :         return false;
     168             :       return true;
     169             :     }
     170             :     bool operator!=(const KeyTy& that) const {
     171             :       return !this->operator==(that);
     172             :     }
     173             :   };
     174             : 
     175             :   static inline FunctionType* getEmptyKey() {
     176             :     return DenseMapInfo<FunctionType*>::getEmptyKey();
     177             :   }
     178             : 
     179             :   static inline FunctionType* getTombstoneKey() {
     180             :     return DenseMapInfo<FunctionType*>::getTombstoneKey();
     181             :   }
     182             : 
     183     9528322 :   static unsigned getHashValue(const KeyTy& Key) {
     184    19056644 :     return hash_combine(Key.ReturnType,
     185     9528322 :                         hash_combine_range(Key.Params.begin(),
     186    19056644 :                                            Key.Params.end()),
     187     9528322 :                         Key.isVarArg);
     188             :   }
     189             : 
     190     1338563 :   static unsigned getHashValue(const FunctionType *FT) {
     191     1338563 :     return getHashValue(KeyTy(FT));
     192             :   }
     193             : 
     194    14723879 :   static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) {
     195    14723879 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
     196             :       return false;
     197    14010350 :     return LHS == KeyTy(RHS);
     198             :   }
     199             : 
     200             :   static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
     201     9422913 :     return LHS == RHS;
     202             :   }
     203             : };
     204             : 
     205             : /// Structure for hashing arbitrary MDNode operands.
     206             : class MDNodeOpsKey {
     207             :   ArrayRef<Metadata *> RawOps;
     208             :   ArrayRef<MDOperand> Ops;
     209             :   unsigned Hash;
     210             : 
     211             : protected:
     212             :   MDNodeOpsKey(ArrayRef<Metadata *> Ops)
     213     1921413 :       : RawOps(Ops), Hash(calculateHash(Ops)) {}
     214             : 
     215             :   template <class NodeTy>
     216       27147 :   MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
     217      639462 :       : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
     218             : 
     219             :   template <class NodeTy>
     220     1381801 :   bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
     221     1381801 :     if (getHash() != RHS->getHash())
     222             :       return false;
     223             : 
     224             :     assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
     225      693911 :     return RawOps.empty() ? compareOps(Ops, RHS, Offset)
     226             :                           : compareOps(RawOps, RHS, Offset);
     227             :   }
     228           1 : 
     229           1 :   static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
     230             : 
     231             : private:
     232             :   template <class T>
     233           1 :   static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
     234          13 :     if (Ops.size() != RHS->getNumOperands() - Offset)
     235             :       return false;
     236     1381800 :     return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
     237     1381787 :   }
     238             : 
     239             :   static unsigned calculateHash(ArrayRef<Metadata *> Ops);
     240             : 
     241      693897 : public:
     242           0 :   unsigned getHash() const { return Hash; }
     243             : };
     244             : 
     245             : template <class NodeTy> struct MDNodeKeyImpl;
     246             : 
     247             : /// Configuration point for MDNodeInfo::isEqual().
     248             : template <class NodeTy> struct MDNodeSubsetEqualImpl {
     249             :   using KeyTy = MDNodeKeyImpl<NodeTy>;
     250      693898 : 
     251           0 :   static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) {
     252      693898 :     return false;
     253             :   }
     254           0 : 
     255           0 :   static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) {
     256           0 :     return false;
     257           0 :   }
     258           0 : };
     259           0 : 
     260           0 : /// DenseMapInfo for MDTuple.
     261           0 : ///
     262           0 : /// Note that we don't need the is-function-local bit, since that's implicit in
     263           0 : /// the operands.
     264           0 : template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
     265           0 :   MDNodeKeyImpl(ArrayRef<Metadata *> Ops) : MDNodeOpsKey(Ops) {}
     266           0 :   MDNodeKeyImpl(const MDTuple *N) : MDNodeOpsKey(N) {}
     267           0 : 
     268           0 :   bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
     269           0 : 
     270           0 :   unsigned getHashValue() const { return getHash(); }
     271           0 : 
     272           0 :   static unsigned calculateHash(MDTuple *N) {
     273           0 :     return MDNodeOpsKey::calculateHash(N);
     274           0 :   }
     275           0 : };
     276           0 : 
     277           0 : /// DenseMapInfo for DILocation.
     278           0 : template <> struct MDNodeKeyImpl<DILocation> {
     279           0 :   unsigned Line;
     280           0 :   unsigned Column;
     281           0 :   Metadata *Scope;
     282           0 :   Metadata *InlinedAt;
     283           0 :   bool ImplicitCode;
     284           0 : 
     285           0 :   MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
     286           0 :                 Metadata *InlinedAt, bool ImplicitCode)
     287           0 :       : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt),
     288           0 :         ImplicitCode(ImplicitCode) {}
     289           0 :   MDNodeKeyImpl(const DILocation *L)
     290           0 :       : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()),
     291           0 :         InlinedAt(L->getRawInlinedAt()), ImplicitCode(L->isImplicitCode()) {}
     292           0 : 
     293           0 :   bool isKeyOf(const DILocation *RHS) const {
     294           0 :     return Line == RHS->getLine() && Column == RHS->getColumn() &&
     295           0 :            Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt() &&
     296           0 :            ImplicitCode == RHS->isImplicitCode();
     297           0 :   }
     298           0 : 
     299           0 :   unsigned getHashValue() const {
     300           0 :     return hash_combine(Line, Column, Scope, InlinedAt, ImplicitCode);
     301           0 :   }
     302           0 : };
     303           0 : 
     304           0 : /// DenseMapInfo for GenericDINode.
     305           0 : template <> struct MDNodeKeyImpl<GenericDINode> : MDNodeOpsKey {
     306           0 :   unsigned Tag;
     307           0 :   MDString *Header;
     308           0 : 
     309           0 :   MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef<Metadata *> DwarfOps)
     310           0 :       : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
     311           0 :   MDNodeKeyImpl(const GenericDINode *N)
     312           0 :       : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {}
     313           0 : 
     314           0 :   bool isKeyOf(const GenericDINode *RHS) const {
     315           0 :     return Tag == RHS->getTag() && Header == RHS->getRawHeader() &&
     316           0 :            compareOps(RHS, 1);
     317           0 :   }
     318           0 : 
     319           0 :   unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
     320           0 : 
     321           0 :   static unsigned calculateHash(GenericDINode *N) {
     322           0 :     return MDNodeOpsKey::calculateHash(N, 1);
     323             :   }
     324           0 : };
     325           0 : 
     326             : template <> struct MDNodeKeyImpl<DISubrange> {
     327           0 :   Metadata *CountNode;
     328           0 :   int64_t LowerBound;
     329             : 
     330           0 :   MDNodeKeyImpl(Metadata *CountNode, int64_t LowerBound)
     331           0 :       : CountNode(CountNode), LowerBound(LowerBound) {}
     332             :   MDNodeKeyImpl(const DISubrange *N)
     333           0 :       : CountNode(N->getRawCountNode()),
     334           0 :         LowerBound(N->getLowerBound()) {}
     335             : 
     336           0 :   bool isKeyOf(const DISubrange *RHS) const {
     337           0 :     if (LowerBound != RHS->getLowerBound())
     338             :       return false;
     339           0 : 
     340           0 :     if (auto *RHSCount = RHS->getCount().dyn_cast<ConstantInt*>())
     341             :       if (auto *MD = dyn_cast<ConstantAsMetadata>(CountNode))
     342           0 :         if (RHSCount->getSExtValue() ==
     343           0 :             cast<ConstantInt>(MD->getValue())->getSExtValue())
     344           0 :           return true;
     345           0 : 
     346           0 :     return CountNode == RHS->getRawCountNode();
     347           0 :   }
     348           0 : 
     349           0 :   unsigned getHashValue() const {
     350           0 :     if (auto *MD = dyn_cast<ConstantAsMetadata>(CountNode))
     351           0 :       return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
     352           0 :                           LowerBound);
     353           0 :     return hash_combine(CountNode, LowerBound);
     354           0 :   }
     355           0 : };
     356           0 : 
     357           0 : template <> struct MDNodeKeyImpl<DIEnumerator> {
     358           0 :   int64_t Value;
     359           0 :   MDString *Name;
     360           0 :   bool IsUnsigned;
     361           0 : 
     362           0 :   MDNodeKeyImpl(int64_t Value, bool IsUnsigned, MDString *Name)
     363           0 :       : Value(Value), Name(Name), IsUnsigned(IsUnsigned) {}
     364           0 :   MDNodeKeyImpl(const DIEnumerator *N)
     365           0 :       : Value(N->getValue()), Name(N->getRawName()),
     366           0 :         IsUnsigned(N->isUnsigned()) {}
     367           0 : 
     368           0 :   bool isKeyOf(const DIEnumerator *RHS) const {
     369           0 :     return Value == RHS->getValue() && IsUnsigned == RHS->isUnsigned() &&
     370           0 :            Name == RHS->getRawName();
     371           0 :   }
     372           0 : 
     373           0 :   unsigned getHashValue() const { return hash_combine(Value, Name); }
     374           0 : };
     375           0 : 
     376           0 : template <> struct MDNodeKeyImpl<DIBasicType> {
     377           0 :   unsigned Tag;
     378           0 :   MDString *Name;
     379           0 :   uint64_t SizeInBits;
     380           0 :   uint32_t AlignInBits;
     381           0 :   unsigned Encoding;
     382           0 :   unsigned Flags;
     383           0 : 
     384           0 :   MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits,
     385           0 :                 uint32_t AlignInBits, unsigned Encoding, unsigned Flags)
     386           0 :       : Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
     387           0 :         Encoding(Encoding), Flags(Flags) {}
     388           0 :   MDNodeKeyImpl(const DIBasicType *N)
     389           0 :       : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()),
     390           0 :         AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()), Flags(N->getFlags()) {}
     391           0 : 
     392           0 :   bool isKeyOf(const DIBasicType *RHS) const {
     393           0 :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     394           0 :            SizeInBits == RHS->getSizeInBits() &&
     395           0 :            AlignInBits == RHS->getAlignInBits() &&
     396             :            Encoding == RHS->getEncoding() &&
     397           0 :            Flags == RHS->getFlags();
     398           0 :   }
     399             : 
     400           0 :   unsigned getHashValue() const {
     401           0 :     return hash_combine(Tag, Name, SizeInBits, AlignInBits, Encoding);
     402             :   }
     403           0 : };
     404           0 : 
     405             : template <> struct MDNodeKeyImpl<DIDerivedType> {
     406           0 :   unsigned Tag;
     407           0 :   MDString *Name;
     408             :   Metadata *File;
     409           0 :   unsigned Line;
     410           0 :   Metadata *Scope;
     411             :   Metadata *BaseType;
     412           0 :   uint64_t SizeInBits;
     413           0 :   uint64_t OffsetInBits;
     414             :   uint32_t AlignInBits;
     415           0 :   Optional<unsigned> DWARFAddressSpace;
     416           0 :   unsigned Flags;
     417             :   Metadata *ExtraData;
     418             : 
     419             :   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
     420             :                 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
     421             :                 uint32_t AlignInBits, uint64_t OffsetInBits,
     422             :                 Optional<unsigned> DWARFAddressSpace, unsigned Flags,
     423             :                 Metadata *ExtraData)
     424             :       : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
     425     3712300 :         BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
     426     3712300 :         AlignInBits(AlignInBits), DWARFAddressSpace(DWARFAddressSpace),
     427             :         Flags(Flags), ExtraData(ExtraData) {}
     428     7439393 :   MDNodeKeyImpl(const DIDerivedType *N)
     429     7168202 :       : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
     430      965111 :         Line(N->getLine()), Scope(N->getRawScope()),
     431     8094622 :         BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
     432     5071320 :         OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
     433    12200627 :         DWARFAddressSpace(N->getDWARFAddressSpace()), Flags(N->getFlags()),
     434     4938288 :         ExtraData(N->getRawExtraData()) {}
     435             : 
     436             :   bool isKeyOf(const DIDerivedType *RHS) const {
     437             :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     438     6738783 :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     439             :            Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
     440             :            SizeInBits == RHS->getSizeInBits() &&
     441             :            AlignInBits == RHS->getAlignInBits() &&
     442             :            OffsetInBits == RHS->getOffsetInBits() &&
     443             :            DWARFAddressSpace == RHS->getDWARFAddressSpace() &&
     444             :            Flags == RHS->getFlags() &&
     445             :            ExtraData == RHS->getRawExtraData();
     446             :   }
     447             : 
     448          49 :   unsigned getHashValue() const {
     449             :     // If this is a member inside an ODR type, only hash the type and the name.
     450        2860 :     // Otherwise the hash will be stronger than
     451        4644 :     // MDNodeSubsetEqualImpl::isODRMember().
     452          13 :     if (Tag == dwarf::DW_TAG_member && Name)
     453         331 :       if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
     454          69 :         if (CT->getRawIdentifier())
     455         307 :           return hash_combine(Name, Scope);
     456           0 : 
     457          99 :     // Intentionally computes the hash on a subset of the operands for
     458             :     // performance reason. The subset has to be significant enough to avoid
     459             :     // collision "most of the time". There is no correctness issue in case of
     460        1381 :     // collision because of the full check above.
     461             :     return hash_combine(Tag, Name, File, Line, Scope, BaseType, Flags);
     462             :   }
     463             : };
     464             : 
     465             : template <> struct MDNodeSubsetEqualImpl<DIDerivedType> {
     466             :   using KeyTy = MDNodeKeyImpl<DIDerivedType>;
     467             : 
     468             :   static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS) {
     469         996 :     return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
     470             :   }
     471         952 : 
     472         997 :   static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS) {
     473             :     return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
     474         377 :                        RHS);
     475         379 :   }
     476           1 : 
     477             :   /// Subprograms compare equal if they declare the same function in an ODR
     478         351 :   /// type.
     479         366 :   static bool isODRMember(unsigned Tag, const Metadata *Scope,
     480         349 :                           const MDString *Name, const DIDerivedType *RHS) {
     481             :     // Check whether the LHS is eligible.
     482             :     if (Tag != dwarf::DW_TAG_member || !Name)
     483             :       return false;
     484         226 : 
     485             :     auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
     486             :     if (!CT || !CT->getRawIdentifier())
     487        1648 :       return false;
     488        1648 : 
     489        3102 :     // Compare to the RHS.
     490        3102 :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     491          97 :            Scope == RHS->getRawScope();
     492             :   }
     493          11 : };
     494          11 : 
     495             : template <> struct MDNodeKeyImpl<DICompositeType> {
     496           1 :   unsigned Tag;
     497           1 :   MDString *Name;
     498             :   Metadata *File;
     499             :   unsigned Line;
     500           1 :   Metadata *Scope;
     501        7644 :   Metadata *BaseType;
     502           1 :   uint64_t SizeInBits;
     503       15058 :   uint64_t OffsetInBits;
     504       15058 :   uint32_t AlignInBits;
     505             :   unsigned Flags;
     506           0 :   Metadata *Elements;
     507       10718 :   unsigned RuntimeLang;
     508          34 :   Metadata *VTableHolder;
     509          11 :   Metadata *TemplateParams;
     510          11 :   MDString *Identifier;
     511       22588 :   Metadata *Discriminator;
     512           2 : 
     513          10 :   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
     514             :                 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
     515             :                 uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
     516             :                 Metadata *Elements, unsigned RuntimeLang,
     517             :                 Metadata *VTableHolder, Metadata *TemplateParams,
     518             :                 MDString *Identifier, Metadata *Discriminator)
     519             :       : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
     520             :         BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
     521             :         AlignInBits(AlignInBits), Flags(Flags), Elements(Elements),
     522             :         RuntimeLang(RuntimeLang), VTableHolder(VTableHolder),
     523             :         TemplateParams(TemplateParams), Identifier(Identifier),
     524        4402 :         Discriminator(Discriminator) {}
     525        4403 :   MDNodeKeyImpl(const DICompositeType *N)
     526           1 :       : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
     527        8028 :         Line(N->getLine()), Scope(N->getRawScope()),
     528        4014 :         BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
     529           2 :         OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
     530         590 :         Flags(N->getFlags()), Elements(N->getRawElements()),
     531         591 :         RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()),
     532         392 :         TemplateParams(N->getRawTemplateParams()),
     533         393 :         Identifier(N->getRawIdentifier()),
     534         981 :         Discriminator(N->getRawDiscriminator()) {}
     535         391 : 
     536             :   bool isKeyOf(const DICompositeType *RHS) const {
     537             :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     538             :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     539        6495 :            Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
     540             :            SizeInBits == RHS->getSizeInBits() &&
     541             :            AlignInBits == RHS->getAlignInBits() &&
     542             :            OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() &&
     543             :            Elements == RHS->getRawElements() &&
     544           0 :            RuntimeLang == RHS->getRuntimeLang() &&
     545           0 :            VTableHolder == RHS->getRawVTableHolder() &&
     546           0 :            TemplateParams == RHS->getRawTemplateParams() &&
     547             :            Identifier == RHS->getRawIdentifier() &&
     548             :            Discriminator == RHS->getRawDiscriminator();
     549           2 :   }
     550           2 : 
     551           0 :   unsigned getHashValue() const {
     552           2 :     // Intentionally computes the hash on a subset of the operands for
     553           2 :     // performance reason. The subset has to be significant enough to avoid
     554           2 :     // collision "most of the time". There is no correctness issue in case of
     555           2 :     // collision because of the full check above.
     556           4 :     return hash_combine(Name, File, Line, BaseType, Scope, Elements,
     557           2 :                         TemplateParams);
     558             :   }
     559             : };
     560             : 
     561           2 : template <> struct MDNodeKeyImpl<DISubroutineType> {
     562       72677 :   unsigned Flags;
     563             :   uint8_t CC;
     564             :   Metadata *TypeArray;
     565       72730 : 
     566      107763 :   MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray)
     567      107763 :       : Flags(Flags), CC(CC), TypeArray(TypeArray) {}
     568      107763 :   MDNodeKeyImpl(const DISubroutineType *N)
     569      107763 :       : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {}
     570      215526 : 
     571      107763 :   bool isKeyOf(const DISubroutineType *RHS) const {
     572      485092 :     return Flags == RHS->getFlags() && CC == RHS->getCC() &&
     573             :            TypeArray == RHS->getRawTypeArray();
     574      116357 :   }
     575      196378 : 
     576       80415 :   unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); }
     577       40101 : };
     578       29203 : 
     579       29181 : template <> struct MDNodeKeyImpl<DIFile> {
     580       58338 :   MDString *Filename;
     581       87210 :   MDString *Directory;
     582      145511 :   Optional<DIFile::ChecksumInfo<MDString *>> Checksum;
     583       29153 :   Optional<MDString *> Source;
     584             : 
     585             :   MDNodeKeyImpl(MDString *Filename, MDString *Directory,
     586      179310 :                 Optional<DIFile::ChecksumInfo<MDString *>> Checksum,
     587             :                 Optional<MDString *> Source)
     588       35368 :       : Filename(Filename), Directory(Directory), Checksum(Checksum),
     589       35368 :         Source(Source) {}
     590      214678 :   MDNodeKeyImpl(const DIFile *N)
     591       65256 :       : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
     592       70736 :         Checksum(N->getRawChecksum()), Source(N->getRawSource()) {}
     593       60555 : 
     594      175554 :   bool isKeyOf(const DIFile *RHS) const {
     595             :     return Filename == RHS->getRawFilename() &&
     596       71944 :            Directory == RHS->getRawDirectory() &&
     597      149770 :            Checksum == RHS->getRawChecksum() &&
     598       77931 :            Source == RHS->getRawSource();
     599      193083 :   }
     600       29032 : 
     601       29031 :   unsigned getHashValue() const {
     602       58062 :     return hash_combine(
     603       43047 :         Filename, Directory, Checksum ? Checksum->Kind : 0,
     604      100975 :         Checksum ? Checksum->Value : nullptr, Source.getValueOr(nullptr));
     605       28899 :   }
     606             : };
     607      116411 : 
     608       35368 : template <> struct MDNodeKeyImpl<DISubprogram> {
     609             :   Metadata *Scope;
     610       79916 :   MDString *Name;
     611      159832 :   MDString *LinkageName;
     612      115284 :   Metadata *File;
     613         568 :   unsigned Line;
     614             :   Metadata *Type;
     615         187 :   bool IsLocalToUnit;
     616             :   bool IsDefinition;
     617      196327 :   unsigned ScopeLine;
     618             :   Metadata *ContainingType;
     619             :   unsigned Virtuality;
     620      196327 :   unsigned VirtualIndex;
     621       35181 :   int ThisAdjustment;
     622             :   unsigned Flags;
     623             :   bool IsOptimized;
     624             :   Metadata *Unit;
     625             :   Metadata *TemplateParams;
     626             :   Metadata *Declaration;
     627             :   Metadata *RetainedNodes;
     628       28858 :   Metadata *ThrownTypes;
     629       71944 : 
     630             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
     631             :                 Metadata *File, unsigned Line, Metadata *Type,
     632           0 :                 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
     633           0 :                 Metadata *ContainingType, unsigned Virtuality,
     634           0 :                 unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
     635             :                 bool IsOptimized, Metadata *Unit, Metadata *TemplateParams,
     636             :                 Metadata *Declaration, Metadata *RetainedNodes,
     637             :                 Metadata *ThrownTypes)
     638             :       : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
     639       71944 :         Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
     640             :         IsDefinition(IsDefinition), ScopeLine(ScopeLine),
     641             :         ContainingType(ContainingType), Virtuality(Virtuality),
     642       71944 :         VirtualIndex(VirtualIndex), ThisAdjustment(ThisAdjustment),
     643             :         Flags(Flags), IsOptimized(IsOptimized), Unit(Unit),
     644             :         TemplateParams(TemplateParams), Declaration(Declaration),
     645             :         RetainedNodes(RetainedNodes), ThrownTypes(ThrownTypes) {}
     646             :   MDNodeKeyImpl(const DISubprogram *N)
     647             :       : Scope(N->getRawScope()), Name(N->getRawName()),
     648             :         LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
     649             :         Line(N->getLine()), Type(N->getRawType()),
     650         236 :         IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
     651             :         ScopeLine(N->getScopeLine()), ContainingType(N->getRawContainingType()),
     652             :         Virtuality(N->getVirtuality()), VirtualIndex(N->getVirtualIndex()),
     653             :         ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()),
     654             :         IsOptimized(N->isOptimized()), Unit(N->getRawUnit()),
     655             :         TemplateParams(N->getRawTemplateParams()),
     656             :         Declaration(N->getRawDeclaration()), RetainedNodes(N->getRawRetainedNodes()),
     657        2161 :         ThrownTypes(N->getRawThrownTypes()) {}
     658             : 
     659             :   bool isKeyOf(const DISubprogram *RHS) const {
     660             :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     661             :            LinkageName == RHS->getRawLinkageName() &&
     662        2161 :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     663        6251 :            Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
     664        6251 :            IsDefinition == RHS->isDefinition() &&
     665        6251 :            ScopeLine == RHS->getScopeLine() &&
     666        6251 :            ContainingType == RHS->getRawContainingType() &&
     667       12502 :            Virtuality == RHS->getVirtuality() &&
     668        6251 :            VirtualIndex == RHS->getVirtualIndex() &&
     669        6251 :            ThisAdjustment == RHS->getThisAdjustment() &&
     670             :            Flags == RHS->getFlags() && IsOptimized == RHS->isOptimized() &&
     671             :            Unit == RHS->getUnit() &&
     672       46277 :            TemplateParams == RHS->getRawTemplateParams() &&
     673             :            Declaration == RHS->getRawDeclaration() &&
     674         533 :            RetainedNodes == RHS->getRawRetainedNodes() &&
     675        1223 :            ThrownTypes == RHS->getRawThrownTypes();
     676         740 :   }
     677         367 : 
     678         236 :   unsigned getHashValue() const {
     679          87 :     // If this is a declaration inside an ODR type, only hash the type and the
     680          79 :     // name.  Otherwise the hash will be stronger than
     681          66 :     // MDNodeSubsetEqualImpl::isDeclarationOfODRMember().
     682          66 :     if (!IsDefinition && LinkageName)
     683          48 :       if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
     684          88 :         if (CT->getRawIdentifier())
     685        2881 :           return hash_combine(LinkageName, Scope);
     686        2304 : 
     687        2267 :     // Intentionally computes the hash on a subset of the operands for
     688        2267 :     // performance reason. The subset has to be significant enough to avoid
     689        4534 :     // collision "most of the time". There is no correctness issue in case of
     690        2267 :     // collision because of the full check above.
     691        2267 :     return hash_combine(Name, Scope, File, Type, Line);
     692             :   }
     693             : };
     694       25618 : 
     695        7723 : template <> struct MDNodeSubsetEqualImpl<DISubprogram> {
     696         886 :   using KeyTy = MDNodeKeyImpl<DISubprogram>;
     697         944 : 
     698          44 :   static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
     699          19 :     return isDeclarationOfODRMember(LHS.IsDefinition, LHS.Scope,
     700          11 :                                     LHS.LinkageName, LHS.TemplateParams, RHS);
     701          11 :   }
     702          11 : 
     703          11 :   static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) {
     704          11 :     return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(),
     705       90481 :                                     LHS->getRawLinkageName(),
     706          22 :                                     LHS->getRawTemplateParams(), RHS);
     707      210228 :   }
     708          11 : 
     709             :   /// Subprograms compare equal if they declare the same function in an ODR
     710      124725 :   /// type.
     711      124649 :   static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope,
     712             :                                        const MDString *LinkageName,
     713             :                                        const Metadata *TemplateParams,
     714      192786 :                                        const DISubprogram *RHS) {
     715             :     // Check whether the LHS is eligible.
     716        4424 :     if (IsDefinition || !Scope || !LinkageName)
     717        2212 :       return false;
     718             : 
     719             :     auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
     720             :     if (!CT || !CT->getRawIdentifier())
     721             :       return false;
     722             : 
     723             :     // Compare to the RHS.
     724             :     // FIXME: We need to compare template parameters here to avoid incorrect
     725             :     // collisions in mapMetadata when RF_MoveDistinctMDs and a ODR-DISubprogram
     726       23939 :     // has a non-ODR template parameter (i.e., a DICompositeType that does not
     727       23939 :     // have an identifier). Eventually we should decouple ODR logic from
     728       11803 :     // uniquing logic.
     729       15137 :     return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() &&
     730       12054 :            LinkageName == RHS->getRawLinkageName() &&
     731             :            TemplateParams == RHS->getRawTemplateParams();
     732       18311 :   }
     733       32561 : };
     734       28451 : 
     735       32417 : template <> struct MDNodeKeyImpl<DILexicalBlock> {
     736       19836 :   Metadata *Scope;
     737             :   Metadata *File;
     738             :   unsigned Line;
     739       32705 :   unsigned Column;
     740       32705 : 
     741         445 :   MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
     742       33150 :       : Scope(Scope), File(File), Line(Line), Column(Column) {}
     743             :   MDNodeKeyImpl(const DILexicalBlock *N)
     744             :       : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
     745             :         Column(N->getColumn()) {}
     746             : 
     747             :   bool isKeyOf(const DILexicalBlock *RHS) const {
     748             :     return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
     749             :            Line == RHS->getLine() && Column == RHS->getColumn();
     750           1 :   }
     751           1 : 
     752           1 :   unsigned getHashValue() const {
     753             :     return hash_combine(Scope, File, Line, Column);
     754           1 :   }
     755           2 : };
     756           1 : 
     757           2 : template <> struct MDNodeKeyImpl<DILexicalBlockFile> {
     758           1 :   Metadata *Scope;
     759             :   Metadata *File;
     760             :   unsigned Discriminator;
     761           1 : 
     762           1 :   MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
     763           1 :       : Scope(Scope), File(File), Discriminator(Discriminator) {}
     764           2 :   MDNodeKeyImpl(const DILexicalBlockFile *N)
     765             :       : Scope(N->getRawScope()), File(N->getRawFile()),
     766             :         Discriminator(N->getDiscriminator()) {}
     767             : 
     768             :   bool isKeyOf(const DILexicalBlockFile *RHS) const {
     769             :     return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
     770             :            Discriminator == RHS->getDiscriminator();
     771             :   }
     772             : 
     773             :   unsigned getHashValue() const {
     774             :     return hash_combine(Scope, File, Discriminator);
     775           0 :   }
     776       27832 : };
     777             : 
     778           0 : template <> struct MDNodeKeyImpl<DINamespace> {
     779             :   Metadata *Scope;
     780             :   MDString *Name;
     781             :   bool ExportSymbols;
     782             : 
     783       27832 :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, bool ExportSymbols)
     784      100214 :       : Scope(Scope), Name(Name), ExportSymbols(ExportSymbols) {}
     785      100214 :   MDNodeKeyImpl(const DINamespace *N)
     786             :       : Scope(N->getRawScope()), Name(N->getRawName()),
     787      100214 :         ExportSymbols(N->getExportSymbols()) {}
     788           0 : 
     789      100214 :   bool isKeyOf(const DINamespace *RHS) const {
     790      100214 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     791      200428 :            ExportSymbols == RHS->getExportSymbols();
     792             :   }
     793             : 
     794             :   unsigned getHashValue() const {
     795      575804 :     return hash_combine(Scope, Name);
     796             :   }
     797       61421 : };
     798       62258 : 
     799        1603 : template <> struct MDNodeKeyImpl<DIModule> {
     800        1532 :   Metadata *Scope;
     801         712 :   MDString *Name;
     802         700 :   MDString *ConfigurationMacros;
     803        1368 :   MDString *IncludePath;
     804        1349 :   MDString *ISysRoot;
     805         670 : 
     806       15958 :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *ConfigurationMacros,
     807       15951 :                 MDString *IncludePath, MDString *ISysRoot)
     808        1304 :       : Scope(Scope), Name(Name), ConfigurationMacros(ConfigurationMacros),
     809       16589 :         IncludePath(IncludePath), ISysRoot(ISysRoot) {}
     810        1283 :   MDNodeKeyImpl(const DIModule *N)
     811       15935 :       : Scope(N->getRawScope()), Name(N->getRawName()),
     812       77987 :         ConfigurationMacros(N->getRawConfigurationMacros()),
     813       31226 :         IncludePath(N->getRawIncludePath()), ISysRoot(N->getRawISysRoot()) {}
     814             : 
     815             :   bool isKeyOf(const DIModule *RHS) const {
     816      127648 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     817       94631 :            ConfigurationMacros == RHS->getRawConfigurationMacros() &&
     818             :            IncludePath == RHS->getRawIncludePath() &&
     819           0 :            ISysRoot == RHS->getRawISysRoot();
     820      127648 :   }
     821       83607 : 
     822           0 :   unsigned getHashValue() const {
     823       79545 :     return hash_combine(Scope, Name,
     824           0 :                         ConfigurationMacros, IncludePath, ISysRoot);
     825           0 :   }
     826           0 : };
     827           0 : 
     828           0 : template <> struct MDNodeKeyImpl<DITemplateTypeParameter> {
     829       48103 :   MDString *Name;
     830           0 :   Metadata *Type;
     831           0 : 
     832           0 :   MDNodeKeyImpl(MDString *Name, Metadata *Type) : Name(Name), Type(Type) {}
     833           0 :   MDNodeKeyImpl(const DITemplateTypeParameter *N)
     834           0 :       : Name(N->getRawName()), Type(N->getRawType()) {}
     835           0 : 
     836             :   bool isKeyOf(const DITemplateTypeParameter *RHS) const {
     837       39756 :     return Name == RHS->getRawName() && Type == RHS->getRawType();
     838       55036 :   }
     839             : 
     840             :   unsigned getHashValue() const { return hash_combine(Name, Type); }
     841       76069 : };
     842       91349 : 
     843        1843 : template <> struct MDNodeKeyImpl<DITemplateValueParameter> {
     844       76069 :   unsigned Tag;
     845        1394 :   MDString *Name;
     846             :   Metadata *Type;
     847             :   Metadata *Value;
     848             : 
     849      137498 :   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, Metadata *Value)
     850             :       : Tag(Tag), Name(Name), Type(Type), Value(Value) {}
     851       13886 :   MDNodeKeyImpl(const DITemplateValueParameter *N)
     852             :       : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
     853             :         Value(N->getValue()) {}
     854      137498 : 
     855             :   bool isKeyOf(const DITemplateValueParameter *RHS) const {
     856             :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     857             :            Type == RHS->getRawType() && Value == RHS->getValue();
     858             :   }
     859       21673 : 
     860       21673 :   unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
     861             : };
     862             : 
     863           0 : template <> struct MDNodeKeyImpl<DIGlobalVariable> {
     864           0 :   Metadata *Scope;
     865             :   MDString *Name;
     866           0 :   MDString *LinkageName;
     867       80627 :   Metadata *File;
     868       75178 :   unsigned Line;
     869             :   Metadata *Type;
     870             :   bool IsLocalToUnit;
     871           0 :   bool IsDefinition;
     872             :   Metadata *StaticDataMemberDeclaration;
     873             :   Metadata *TemplateParams;
     874             :   uint32_t AlignInBits;
     875             : 
     876           0 :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
     877             :                 Metadata *File, unsigned Line, Metadata *Type,
     878             :                 bool IsLocalToUnit, bool IsDefinition,
     879             :                 Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
     880          42 :                 uint32_t AlignInBits)
     881             :       : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
     882          76 :         Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
     883          76 :         IsDefinition(IsDefinition),
     884             :         StaticDataMemberDeclaration(StaticDataMemberDeclaration),
     885           4 :         TemplateParams(TemplateParams), AlignInBits(AlignInBits) {}
     886           8 :   MDNodeKeyImpl(const DIGlobalVariable *N)
     887           8 :       : Scope(N->getRawScope()), Name(N->getRawName()),
     888             :         LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
     889           0 :         Line(N->getLine()), Type(N->getRawType()),
     890           0 :         IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
     891          61 :         StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
     892             :         TemplateParams(N->getRawTemplateParams()),
     893             :         AlignInBits(N->getAlignInBits()) {}
     894             : 
     895             :   bool isKeyOf(const DIGlobalVariable *RHS) const {
     896             :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     897             :            LinkageName == RHS->getRawLinkageName() &&
     898             :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     899             :            Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
     900             :            IsDefinition == RHS->isDefinition() &&
     901      247194 :            StaticDataMemberDeclaration ==
     902             :                RHS->getRawStaticDataMemberDeclaration() &&
     903       34679 :            TemplateParams == RHS->getRawTemplateParams() &&
     904       34680 :            AlignInBits == RHS->getAlignInBits();
     905           3 :   }
     906             : 
     907     1376478 :   unsigned getHashValue() const {
     908      231652 :     // We do not use AlignInBits in hashing function here on purpose:
     909           2 :     // in most cases this param for local variable is zero (for function param
     910             :     // it is always zero). This leads to lots of hash collisions and errors on
     911             :     // cases with lots of similar variables.
     912      281521 :     // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
     913           1 :     // generated IR is random for each run and test fails with Align included.
     914             :     // TODO: make hashing work fine with such situations
     915             :     return hash_combine(Scope, Name, LinkageName, File, Line, Type,
     916             :                         IsLocalToUnit, IsDefinition, /* AlignInBits, */
     917             :                         StaticDataMemberDeclaration);
     918             :   }
     919             : };
     920             : 
     921             : template <> struct MDNodeKeyImpl<DILocalVariable> {
     922        2985 :   Metadata *Scope;
     923             :   MDString *Name;
     924         671 :   Metadata *File;
     925         843 :   unsigned Line;
     926         172 :   Metadata *Type;
     927        2439 :   unsigned Arg;
     928        4908 :   unsigned Flags;
     929        2353 :   uint32_t AlignInBits;
     930           1 : 
     931             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
     932             :                 Metadata *Type, unsigned Arg, unsigned Flags,
     933        3462 :                 uint32_t AlignInBits)
     934          86 :       : Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
     935             :         Flags(Flags), AlignInBits(AlignInBits) {}
     936             :   MDNodeKeyImpl(const DILocalVariable *N)
     937             :       : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
     938             :         Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
     939             :         Flags(N->getFlags()), AlignInBits(N->getAlignInBits()) {}
     940             : 
     941             :   bool isKeyOf(const DILocalVariable *RHS) const {
     942             :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     943             :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     944             :            Type == RHS->getRawType() && Arg == RHS->getArg() &&
     945             :            Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits();
     946         108 :   }
     947         112 : 
     948          89 :   unsigned getHashValue() const {
     949          91 :     // We do not use AlignInBits in hashing function here on purpose:
     950           4 :     // in most cases this param for local variable is zero (for function param
     951         170 :     // it is always zero). This leads to lots of hash collisions and errors on
     952             :     // cases with lots of similar variables.
     953           7 :     // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
     954          14 :     // generated IR is random for each run and test fails with Align included.
     955          26 :     // TODO: make hashing work fine with such situations
     956          21 :     return hash_combine(Scope, Name, File, Line, Type, Arg, Flags);
     957           7 :   }
     958             : };
     959             : 
     960             : template <> struct MDNodeKeyImpl<DILabel> {
     961         175 :   Metadata *Scope;
     962         132 :   MDString *Name;
     963             :   Metadata *File;
     964             :   unsigned Line;
     965             : 
     966             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line)
     967             :       : Scope(Scope), Name(Name), File(File), Line(Line) {}
     968             :   MDNodeKeyImpl(const DILabel *N)
     969             :       : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
     970       14871 :         Line(N->getLine()) {}
     971           1 : 
     972       10242 :   bool isKeyOf(const DILabel *RHS) const {
     973           1 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     974           0 :            File == RHS->getRawFile() && Line == RHS->getLine();
     975       23095 :   }
     976           2 : 
     977           2 :   /// Using name and line to get hash value. It should already be mostly unique.
     978       24930 :   unsigned getHashValue() const {
     979           1 :     return hash_combine(Scope, Name, Line);
     980             :   }
     981             : };
     982             : 
     983           2 : template <> struct MDNodeKeyImpl<DIExpression> {
     984           1 :   ArrayRef<uint64_t> Elements;
     985             : 
     986             :   MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
     987             :   MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
     988        4117 : 
     989             :   bool isKeyOf(const DIExpression *RHS) const {
     990        2134 :     return Elements == RHS->getElements();
     991        2528 :   }
     992             : 
     993        5191 :   unsigned getHashValue() const {
     994        5980 :     return hash_combine_range(Elements.begin(), Elements.end());
     995        8573 :   }
     996           0 : };
     997         184 : 
     998        6135 : template <> struct MDNodeKeyImpl<DIGlobalVariableExpression> {
     999             :   Metadata *Variable;
    1000         147 :   Metadata *Expression;
    1001             : 
    1002             :   MDNodeKeyImpl(Metadata *Variable, Metadata *Expression)
    1003             :       : Variable(Variable), Expression(Expression) {}
    1004             :   MDNodeKeyImpl(const DIGlobalVariableExpression *N)
    1005             :       : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {}
    1006             : 
    1007             :   bool isKeyOf(const DIGlobalVariableExpression *RHS) const {
    1008             :     return Variable == RHS->getRawVariable() &&
    1009             :            Expression == RHS->getRawExpression();
    1010             :   }
    1011             : 
    1012          25 :   unsigned getHashValue() const { return hash_combine(Variable, Expression); }
    1013          40 : };
    1014             : 
    1015           1 : template <> struct MDNodeKeyImpl<DIObjCProperty> {
    1016           1 :   MDString *Name;
    1017           2 :   Metadata *File;
    1018             :   unsigned Line;
    1019         574 :   MDString *GetterName;
    1020          25 :   MDString *SetterName;
    1021             :   unsigned Attributes;
    1022             :   Metadata *Type;
    1023         574 : 
    1024        1956 :   MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line,
    1025        1956 :                 MDString *GetterName, MDString *SetterName, unsigned Attributes,
    1026             :                 Metadata *Type)
    1027        1956 :       : Name(Name), File(File), Line(Line), GetterName(GetterName),
    1028        3912 :         SetterName(SetterName), Attributes(Attributes), Type(Type) {}
    1029             :   MDNodeKeyImpl(const DIObjCProperty *N)
    1030             :       : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
    1031        1956 :         GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()),
    1032             :         Attributes(N->getAttributes()), Type(N->getRawType()) {}
    1033         157 : 
    1034         163 :   bool isKeyOf(const DIObjCProperty *RHS) const {
    1035          11 :     return Name == RHS->getRawName() && File == RHS->getRawFile() &&
    1036           5 :            Line == RHS->getLine() && GetterName == RHS->getRawGetterName() &&
    1037           4 :            SetterName == RHS->getRawSetterName() &&
    1038           4 :            Attributes == RHS->getAttributes() && Type == RHS->getRawType();
    1039           4 :   }
    1040           4 : 
    1041         161 :   unsigned getHashValue() const {
    1042           2 :     return hash_combine(Name, File, Line, GetterName, SetterName, Attributes,
    1043             :                         Type);
    1044             :   }
    1045        2272 : };
    1046         634 : 
    1047         634 : template <> struct MDNodeKeyImpl<DIImportedEntity> {
    1048             :   unsigned Tag;
    1049         634 :   Metadata *Scope;
    1050        1268 :   Metadata *Entity;
    1051             :   Metadata *File;
    1052             :   unsigned Line;
    1053        5178 :   MDString *Name;
    1054        2272 : 
    1055        2286 :   MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, Metadata *File,
    1056          15 :                 unsigned Line, MDString *Name)
    1057           2 :       : Tag(Tag), Scope(Scope), Entity(Entity), File(File), Line(Line),
    1058           1 :         Name(Name) {}
    1059           1 :   MDNodeKeyImpl(const DIImportedEntity *N)
    1060           1 :       : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
    1061           1 :         File(N->getRawFile()), Line(N->getLine()), Name(N->getRawName()) {}
    1062           1 : 
    1063          15 :   bool isKeyOf(const DIImportedEntity *RHS) const {
    1064           1 :     return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
    1065             :            Entity == RHS->getRawEntity() && File == RHS->getFile() &&
    1066             :            Line == RHS->getLine() && Name == RHS->getRawName();
    1067         607 :   }
    1068             : 
    1069             :   unsigned getHashValue() const {
    1070             :     return hash_combine(Tag, Scope, Entity, File, Line, Name);
    1071             :   }
    1072       37645 : };
    1073       37645 : 
    1074       82929 : template <> struct MDNodeKeyImpl<DIMacro> {
    1075       84143 :   unsigned MIType;
    1076       83536 :   unsigned Line;
    1077       83536 :   MDString *Name;
    1078             :   MDString *Value;
    1079       47871 : 
    1080       48251 :   MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value)
    1081         472 :       : MIType(MIType), Line(Line), Name(Name), Value(Value) {}
    1082         162 :   MDNodeKeyImpl(const DIMacro *N)
    1083       48005 :       : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()),
    1084             :         Value(N->getRawValue()) {}
    1085             : 
    1086             :   bool isKeyOf(const DIMacro *RHS) const {
    1087             :     return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
    1088             :            Name == RHS->getRawName() && Value == RHS->getRawValue();
    1089             :   }
    1090             : 
    1091             :   unsigned getHashValue() const {
    1092             :     return hash_combine(MIType, Line, Name, Value);
    1093             :   }
    1094      119198 : };
    1095             : 
    1096        1625 : template <> struct MDNodeKeyImpl<DIMacroFile> {
    1097        1625 :   unsigned MIType;
    1098        1625 :   unsigned Line;
    1099        1625 :   Metadata *File;
    1100             :   Metadata *Elements;
    1101        1137 : 
    1102        1137 :   MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File,
    1103           1 :                 Metadata *Elements)
    1104           1 :       : MIType(MIType), Line(Line), File(File), Elements(Elements) {}
    1105        1173 :   MDNodeKeyImpl(const DIMacroFile *N)
    1106             :       : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()),
    1107          37 :         Elements(N->getRawElements()) {}
    1108          37 : 
    1109             :   bool isKeyOf(const DIMacroFile *RHS) const {
    1110           0 :     return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
    1111           0 :            File == RHS->getRawFile() && Elements == RHS->getRawElements();
    1112           0 :   }
    1113             : 
    1114             :   unsigned getHashValue() const {
    1115             :     return hash_combine(MIType, Line, File, Elements);
    1116        1625 :   }
    1117          53 : };
    1118             : 
    1119             : /// DenseMapInfo for MDNode subclasses.
    1120             : template <class NodeTy> struct MDNodeInfo {
    1121             :   using KeyTy = MDNodeKeyImpl<NodeTy>;
    1122             :   using SubsetEqualTy = MDNodeSubsetEqualImpl<NodeTy>;
    1123             : 
    1124       64937 :   static inline NodeTy *getEmptyKey() {
    1125             :     return DenseMapInfo<NodeTy *>::getEmptyKey();
    1126             :   }
    1127           0 : 
    1128       68721 :   static inline NodeTy *getTombstoneKey() {
    1129           1 :     return DenseMapInfo<NodeTy *>::getTombstoneKey();
    1130           1 :   }
    1131             : 
    1132       68124 :   static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
    1133           0 : 
    1134           0 :   static unsigned getHashValue(const NodeTy *N) {
    1135             :     return KeyTy(N).getHashValue();
    1136             :   }
    1137             : 
    1138             :   static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
    1139           1 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
    1140             :       return false;
    1141        1847 :     return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS);
    1142             :   }
    1143        4680 : 
    1144             :   static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
    1145           0 :     if (LHS == RHS)
    1146         910 :       return true;
    1147           6 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
    1148             :       return false;
    1149           0 :     return SubsetEqualTy::isSubsetEqual(LHS, RHS);
    1150        5950 :   }
    1151             : };
    1152             : 
    1153             : #define HANDLE_MDNODE_LEAF(CLASS) using CLASS##Info = MDNodeInfo<CLASS>;
    1154           1 : #include "llvm/IR/Metadata.def"
    1155             : 
    1156             : /// Map-like storage for metadata attachments.
    1157             : class MDAttachmentMap {
    1158             :   SmallVector<std::pair<unsigned, TrackingMDNodeRef>, 2> Attachments;
    1159             : 
    1160             : public:
    1161             :   bool empty() const { return Attachments.empty(); }
    1162             :   size_t size() const { return Attachments.size(); }
    1163             : 
    1164             :   /// Get a particular attachment (if any).
    1165        2762 :   MDNode *lookup(unsigned ID) const;
    1166         122 : 
    1167          90 :   /// Set an attachment to a particular node.
    1168         726 :   ///
    1169           1 :   /// Set the \c ID attachment to \c MD, replacing the current attachment at \c
    1170         245 :   /// ID (if anyway).
    1171             :   void set(unsigned ID, MDNode &MD);
    1172         915 : 
    1173          99 :   /// Remove an attachment.
    1174          94 :   ///
    1175          32 :   /// Remove the attachment at \c ID, if any.
    1176          67 :   bool erase(unsigned ID);
    1177             : 
    1178             :   /// Copy out all the attachments.
    1179             :   ///
    1180         242 :   /// Copies all the current attachments into \c Result, sorting by attachment
    1181         166 :   /// ID.  This function does \em not clear \c Result.
    1182             :   void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
    1183             : 
    1184             :   /// Erase matching attachments.
    1185             :   ///
    1186             :   /// Erases all attachments matching the \c shouldRemove predicate.
    1187             :   template <class PredTy> void remove_if(PredTy shouldRemove) {
    1188             :     Attachments.erase(llvm::remove_if(Attachments, shouldRemove),
    1189           1 :                       Attachments.end());
    1190           1 :   }
    1191             : };
    1192           2 : 
    1193             : /// Multimap-like storage for metadata attachments for globals. This differs
    1194           1 : /// from MDAttachmentMap in that it allows multiple attachments per metadata
    1195       16766 : /// kind.
    1196       16765 : class MDGlobalAttachmentMap {
    1197       39899 :   struct Attachment {
    1198       39900 :     unsigned MDKind;
    1199      159592 :     TrackingMDNodeRef Node;
    1200             :   };
    1201       21462 :   SmallVector<Attachment, 1> Attachments;
    1202       21464 : 
    1203       20070 : public:
    1204       21473 :   bool empty() const { return Attachments.empty(); }
    1205             : 
    1206             :   /// Appends all attachments with the given ID to \c Result in insertion order.
    1207             :   /// If the global has no attachments with the given ID, or if ID is invalid,
    1208       56511 :   /// leaves Result unchanged.
    1209             :   void get(unsigned ID, SmallVectorImpl<MDNode *> &Result) const;
    1210             : 
    1211             :   /// Returns the first attachment with the given ID or nullptr if no such
    1212             :   /// attachment exists.
    1213             :   MDNode *lookup(unsigned ID) const;
    1214             : 
    1215             :   void insert(unsigned ID, MDNode &MD);
    1216             :   bool erase(unsigned ID);
    1217     4070311 : 
    1218             :   /// Appends all attachments for the global to \c Result, sorting by attachment
    1219        2363 :   /// ID. Attachments with the same ID appear in insertion order. This function
    1220         901 :   /// does \em not clear \c Result.
    1221        9194 :   void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
    1222        2795 : };
    1223        1204 : 
    1224        3322 : class LLVMContextImpl {
    1225        5156 : public:
    1226        5380 :   /// OwnedModules - The set of modules instantiated in this context, and which
    1227             :   /// will be automatically deleted if this context is deleted.
    1228             :   SmallPtrSet<Module*, 4> OwnedModules;
    1229           0 : 
    1230        5122 :   LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler = nullptr;
    1231             :   void *InlineAsmDiagContext = nullptr;
    1232             : 
    1233             :   std::unique_ptr<DiagnosticHandler> DiagHandler;
    1234             :   bool RespectDiagnosticFilters = false;
    1235             :   bool DiagnosticsHotnessRequested = false;
    1236             :   uint64_t DiagnosticsHotnessThreshold = 0;
    1237             :   std::unique_ptr<yaml::Output> DiagnosticsOutputFile;
    1238             : 
    1239             :   LLVMContext::YieldCallbackTy YieldCallback = nullptr;
    1240             :   void *YieldOpaqueHandle = nullptr;
    1241             : 
    1242          70 :   using IntMapTy =
    1243           0 :       DenseMap<APInt, std::unique_ptr<ConstantInt>, DenseMapAPIntKeyInfo>;
    1244         190 :   IntMapTy IntConstants;
    1245         190 : 
    1246           0 :   using FPMapTy =
    1247           3 :       DenseMap<APFloat, std::unique_ptr<ConstantFP>, DenseMapAPFloatKeyInfo>;
    1248           3 :   FPMapTy FPConstants;
    1249           5 : 
    1250             :   FoldingSet<AttributeImpl> AttrsSet;
    1251             :   FoldingSet<AttributeListImpl> AttrsLists;
    1252           0 :   FoldingSet<AttributeSetNode> AttrsSetNodes;
    1253         129 : 
    1254             :   StringMap<MDString, BumpPtrAllocator> MDStringCache;
    1255             :   DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
    1256             :   DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
    1257             : 
    1258             :   DenseMap<const Value*, ValueName*> ValueNames;
    1259             : 
    1260             : #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS)                                    \
    1261             :   DenseSet<CLASS *, CLASS##Info> CLASS##s;
    1262             : #include "llvm/IR/Metadata.def"
    1263             : 
    1264             :   // Optional map for looking up composite types by identifier.
    1265             :   Optional<DenseMap<const MDString *, DICompositeType *>> DITypeMap;
    1266          14 : 
    1267          42 :   // MDNodes may be uniqued or not uniqued.  When they're not uniqued, they
    1268           0 :   // aren't in the MDNodeSet, but they're still shared between objects, so no
    1269           1 :   // one object can destroy them.  Keep track of them here so we can delete
    1270      120896 :   // them on context teardown.
    1271           2 :   std::vector<MDNode *> DistinctMDNodes;
    1272     3337227 : 
    1273     3559915 :   DenseMap<Type *, std::unique_ptr<ConstantAggregateZero>> CAZConstants;
    1274             : 
    1275         103 :   using ArrayConstantsTy = ConstantUniqueMap<ConstantArray>;
    1276          89 :   ArrayConstantsTy ArrayConstants;
    1277             : 
    1278     3028803 :   using StructConstantsTy = ConstantUniqueMap<ConstantStruct>;
    1279     3028803 :   StructConstantsTy StructConstants;
    1280             : 
    1281          64 :   using VectorConstantsTy = ConstantUniqueMap<ConstantVector>;
    1282          64 :   VectorConstantsTy VectorConstants;
    1283             : 
    1284       15058 :   DenseMap<PointerType *, std::unique_ptr<ConstantPointerNull>> CPNConstants;
    1285       15058 : 
    1286             :   DenseMap<Type *, std::unique_ptr<UndefValue>> UVConstants;
    1287        4014 : 
    1288        4014 :   StringMap<ConstantDataSequential*> CDSConstants;
    1289             : 
    1290        6251 :   DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *>
    1291        6251 :     BlockAddresses;
    1292       51267 :   ConstantUniqueMap<ConstantExpr> ExprConstants;
    1293      104660 : 
    1294      104660 :   ConstantUniqueMap<InlineAsm> InlineAsms;
    1295           0 : 
    1296          38 :   ConstantInt *TheTrueVal = nullptr;
    1297          38 :   ConstantInt *TheFalseVal = nullptr;
    1298           0 : 
    1299       34679 :   std::unique_ptr<ConstantTokenNone> TheNoneToken;
    1300       34679 : 
    1301           0 :   // Basic type instances.
    1302         671 :   Type VoidTy, LabelTy, HalfTy, FloatTy, DoubleTy, MetadataTy, TokenTy;
    1303         671 :   Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
    1304           0 :   IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty, Int128Ty;
    1305          95 : 
    1306          95 :   /// TypeAllocator - All dynamically allocated types are allocated from this.
    1307           0 :   /// They live forever until the context is torn down.
    1308       10242 :   BumpPtrAllocator TypeAllocator;
    1309       10242 : 
    1310           0 :   DenseMap<unsigned, IntegerType*> IntegerTypes;
    1311        2134 : 
    1312        2134 :   using FunctionTypeSet = DenseSet<FunctionType *, FunctionTypeKeyInfo>;
    1313           0 :   FunctionTypeSet FunctionTypes;
    1314       82929 :   using StructTypeSet = DenseSet<StructType *, AnonStructTypeKeyInfo>;
    1315       82929 :   StructTypeSet AnonStructTypes;
    1316           0 :   StringMap<StructType*> NamedStructTypes;
    1317          37 :   unsigned NamedStructTypesUniqueID = 0;
    1318          37 : 
    1319           0 :   DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes;
    1320        4680 :   DenseMap<std::pair<Type *, unsigned>, VectorType*> VectorTypes;
    1321        4680 :   DenseMap<Type*, PointerType*> PointerTypes;  // Pointers in AddrSpace = 0
    1322           0 :   DenseMap<std::pair<Type*, unsigned>, PointerType*> ASPointerTypes;
    1323          90 : 
    1324          90 :   /// ValueHandles - This map keeps track of all of the value handles that are
    1325           0 :   /// watching a Value*.  The Value::HasValueHandle bit is used to know
    1326       39898 :   /// whether or not a value has an entry in this map.
    1327       39898 :   using ValueHandlesTy = DenseMap<Value *, ValueHandleBase *>;
    1328           0 :   ValueHandlesTy ValueHandles;
    1329        2795 : 
    1330        2795 :   /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
    1331           0 :   StringMap<unsigned> CustomMDKindNames;
    1332             : 
    1333      930554 :   /// Collection of per-instruction metadata used in this context.
    1334    10603853 :   DenseMap<const Instruction *, MDAttachmentMap> InstructionMetadata;
    1335             : 
    1336     8684092 :   /// Collection of per-GlobalObject metadata used in this context.
    1337           0 :   DenseMap<const GlobalObject *, MDGlobalAttachmentMap> GlobalObjectMetadata;
    1338       70804 : 
    1339       70804 :   /// Collection of per-GlobalObject sections used in this context.
    1340           0 :   DenseMap<const GlobalObject *, StringRef> GlobalObjectSections;
    1341       68721 : 
    1342           0 :   /// Stable collection of section strings.
    1343       27838 :   StringSet<> SectionStrings;
    1344       27838 : 
    1345           0 :   /// DiscriminatorTable - This table maps file:line locations to an
    1346       33035 :   /// integer representing the next DWARF path discriminator to assign to
    1347             :   /// instructions in different blocks at the same location.
    1348      587613 :   DenseMap<std::pair<const char *, unsigned>, unsigned> DiscriminatorTable;
    1349      587613 : 
    1350             :   int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx);
    1351      231645 :   int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx);
    1352           0 : 
    1353       67245 :   /// A set of interned tags for operand bundles.  The StringMap maps
    1354       67245 :   /// bundle tags to their IDs.
    1355      116755 :   ///
    1356     1894087 :   /// \see LLVMContext::getOperandBundleTagID
    1357             :   StringMap<uint32_t> BundleTagCache;
    1358     1638650 : 
    1359      158867 :   StringMapEntry<uint32_t> *getOrInsertBundleTag(StringRef Tag);
    1360         322 :   void getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const;
    1361      116733 :   uint32_t getOperandBundleTagID(StringRef Tag) const;
    1362             : 
    1363       18390 :   /// A set of interned synchronization scopes.  The StringMap maps
    1364       18187 :   /// synchronization scope names to their respective synchronization scope IDs.
    1365          90 :   StringMap<SyncScope::ID> SSC;
    1366         115 : 
    1367             :   /// getOrInsertSyncScopeID - Maps synchronization scope name to
    1368           1 :   /// synchronization scope ID.  Every synchronization scope registered with
    1369             :   /// LLVMContext has unique ID except pre-defined ones.
    1370    33800179 :   SyncScope::ID getOrInsertSyncScopeID(StringRef SSN);
    1371       37535 : 
    1372      361082 :   /// getSyncScopeNames - Populates client supplied SmallVector with
    1373       21673 :   /// synchronization scope names registered with LLVMContext.  Synchronization
    1374      155985 :   /// scope names are ordered by increasing synchronization scope IDs.
    1375       78806 :   void getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const;
    1376       78806 : 
    1377             :   /// Maintain the GC name for each function.
    1378       71944 :   ///
    1379             :   /// This saves allocating an additional word in Function for programs which
    1380           1 :   /// do not use GC (i.e., most programs) at the cost of increased overhead for
    1381           1 :   /// clients which do use GC.
    1382             :   DenseMap<const Function*, std::string> GCNames;
    1383           1 : 
    1384             :   /// Flag to indicate if Value (other than GlobalValue) retains their name or
    1385           1 :   /// not.
    1386           1 :   bool DiscardValueNames = false;
    1387             : 
    1388           1 :   LLVMContextImpl(LLVMContext &C);
    1389             :   ~LLVMContextImpl();
    1390             : 
    1391             :   /// Destroy the ConstantArrays if they are not used.
    1392     4999960 :   void dropTriviallyDeadConstantArrays();
    1393             : 
    1394           0 :   mutable OptPassGate *OPG = nullptr;
    1395             : 
    1396           0 :   /// Access the object which can disable optional passes and individual
    1397             :   /// optimizations at compile time.
    1398             :   OptPassGate &getOptPassGate() const;
    1399             : 
    1400             :   /// Set the object which can disable optional passes and individual
    1401             :   /// optimizations at compile time.
    1402             :   ///
    1403             :   /// The lifetime of the object must be guaranteed to extend as long as the
    1404     1661326 :   /// LLVMContext is used by compilation.
    1405             :   void setOptPassGate(OptPassGate&);
    1406             : };
    1407             : 
    1408     2705419 : } // end namespace llvm
    1409             : 
    1410             : #endif // LLVM_LIB_IR_LLVMCONTEXTIMPL_H

Generated by: LCOV version 1.13