LCOV - code coverage report
Current view: top level - lib/IR - LLVMContextImpl.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 350 353 99.2 %
Date: 2018-07-13 00:08:38 Functions: 73 74 98.6 %
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    48331285 :     V.U.VAL = 1;
      72             :     return V;
      73             :   }
      74             : 
      75             :   static unsigned getHashValue(const APInt &Key) {
      76    96493808 :     return static_cast<unsigned>(hash_value(Key));
      77             :   }
      78             : 
      79   232668829 :   static bool isEqual(const APInt &LHS, const APInt &RHS) {
      80   291231400 :     return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
      81             :   }
      82             : };
      83             : 
      84             : struct DenseMapAPFloatKeyInfo {
      85      171635 :   static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); }
      86             :   static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus(), 2); }
      87             : 
      88             :   static unsigned getHashValue(const APFloat &Key) {
      89      254814 :     return static_cast<unsigned>(hash_value(Key));
      90             :   }
      91             : 
      92             :   static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
      93     1083837 :     return LHS.bitwiseIsEqual(RHS);
      94             :   }
      95             : };
      96             : 
      97             : struct AnonStructTypeKeyInfo {
      98             :   struct KeyTy {
      99             :     ArrayRef<Type*> ETypes;
     100             :     bool isPacked;
     101             : 
     102       93204 :     KeyTy(const ArrayRef<Type*>& E, bool P) :
     103       93204 :       ETypes(E), isPacked(P) {}
     104             : 
     105             :     KeyTy(const StructType *ST)
     106      298392 :         : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
     107             : 
     108       80303 :     bool operator==(const KeyTy& that) const {
     109       80303 :       if (isPacked != that.isPacked)
     110             :         return false;
     111       80084 :       if (ETypes != that.ETypes)
     112             :         return false;
     113       74523 :       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      102968 :   static unsigned getHashValue(const KeyTy& Key) {
     129      205936 :     return hash_combine(hash_combine_range(Key.ETypes.begin(),
     130             :                                            Key.ETypes.end()),
     131      308904 :                         Key.isPacked);
     132             :   }
     133             : 
     134       19161 :   static unsigned getHashValue(const StructType *ST) {
     135       19161 :     return getHashValue(KeyTy(ST));
     136             :   }
     137             : 
     138       89587 :   static bool isEqual(const KeyTy& LHS, const StructType *RHS) {
     139       89587 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
     140             :       return false;
     141       80303 :     return LHS == KeyTy(RHS);
     142             :   }
     143             : 
     144             :   static bool isEqual(const StructType *LHS, const StructType *RHS) {
     145       56578 :     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     1864054 :     KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) :
     156     1864054 :       ReturnType(R), Params(P), isVarArg(V) {}
     157             :     KeyTy(const FunctionType *FT)
     158     2921768 :         : ReturnType(FT->getReturnType()), Params(FT->params()),
     159     8765304 :           isVarArg(FT->isVarArg()) {}
     160             : 
     161     2541106 :     bool operator==(const KeyTy& that) const {
     162     2541106 :       if (ReturnType != that.ReturnType)
     163             :         return false;
     164     1958851 :       if (isVarArg != that.isVarArg)
     165             :         return false;
     166     1954974 :       if (Params != that.Params)
     167             :         return false;
     168     1559232 :       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     2200337 :   static unsigned getHashValue(const KeyTy& Key) {
     184     4400674 :     return hash_combine(Key.ReturnType,
     185     4400674 :                         hash_combine_range(Key.Params.begin(),
     186             :                                            Key.Params.end()),
     187     8801348 :                         Key.isVarArg);
     188             :   }
     189             : 
     190      380662 :   static unsigned getHashValue(const FunctionType *FT) {
     191      380662 :     return getHashValue(KeyTy(FT));
     192             :   }
     193             : 
     194     2801549 :   static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) {
     195     2801549 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
     196             :       return false;
     197     2541106 :     return LHS == KeyTy(RHS);
     198             :   }
     199             : 
     200             :   static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
     201     2276225 :     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     1809014 :       : RawOps(Ops), Hash(calculateHash(Ops)) {}
     214             : 
     215             :   template <class NodeTy>
     216       20276 :   MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
     217     1126023 :       : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
     218             : 
     219             :   template <class NodeTy>
     220     1221656 :   bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
     221     1221656 :     if (getHash() != RHS->getHash())
     222             :       return false;
     223             : 
     224             :     assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
     225      424099 :     return RawOps.empty() ? compareOps(Ops, RHS, Offset)
     226             :                           : compareOps(RawOps, RHS, Offset);
     227             :   }
     228             : 
     229             :   static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
     230             : 
     231             : private:
     232             :   template <class T>
     233             :   static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
     234      424099 :     if (Ops.size() != RHS->getNumOperands() - Offset)
     235             :       return false;
     236      424099 :     return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
     237             :   }
     238             : 
     239             :   static unsigned calculateHash(ArrayRef<Metadata *> Ops);
     240             : 
     241             : public:
     242             :   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             : 
     251             :   static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) {
     252             :     return false;
     253             :   }
     254             : 
     255             :   static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) {
     256             :     return false;
     257             :   }
     258             : };
     259             : 
     260             : /// DenseMapInfo for MDTuple.
     261             : ///
     262             : /// Note that we don't need the is-function-local bit, since that's implicit in
     263             : /// the operands.
     264             : template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
     265             :   MDNodeKeyImpl(ArrayRef<Metadata *> Ops) : MDNodeOpsKey(Ops) {}
     266             :   MDNodeKeyImpl(const MDTuple *N) : MDNodeOpsKey(N) {}
     267             : 
     268     1221642 :   bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
     269             : 
     270      906960 :   unsigned getHashValue() const { return getHash(); }
     271             : 
     272             :   static unsigned calculateHash(MDTuple *N) {
     273       20197 :     return MDNodeOpsKey::calculateHash(N);
     274             :   }
     275             : };
     276             : 
     277             : /// DenseMapInfo for DILocation.
     278             : template <> struct MDNodeKeyImpl<DILocation> {
     279             :   unsigned Line;
     280             :   unsigned Column;
     281             :   Metadata *Scope;
     282             :   Metadata *InlinedAt;
     283             : 
     284             :   MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
     285             :                 Metadata *InlinedAt)
     286     3123319 :       : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {}
     287             :   MDNodeKeyImpl(const DILocation *L)
     288     5654968 :       : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()),
     289    11309936 :         InlinedAt(L->getRawInlinedAt()) {}
     290             : 
     291             :   bool isKeyOf(const DILocation *RHS) const {
     292    12715527 :     return Line == RHS->getLine() && Column == RHS->getColumn() &&
     293    12640065 :            Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt();
     294             :   }
     295             : 
     296             :   unsigned getHashValue() const {
     297    11894756 :     return hash_combine(Line, Column, Scope, InlinedAt);
     298             :   }
     299             : };
     300             : 
     301             : /// DenseMapInfo for GenericDINode.
     302             : template <> struct MDNodeKeyImpl<GenericDINode> : MDNodeOpsKey {
     303             :   unsigned Tag;
     304             :   MDString *Header;
     305             : 
     306             :   MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef<Metadata *> DwarfOps)
     307          98 :       : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
     308             :   MDNodeKeyImpl(const GenericDINode *N)
     309         316 :       : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {}
     310             : 
     311          15 :   bool isKeyOf(const GenericDINode *RHS) const {
     312          58 :     return Tag == RHS->getTag() && Header == RHS->getRawHeader() &&
     313          29 :            compareOps(RHS, 1);
     314             :   }
     315             : 
     316         228 :   unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
     317             : 
     318             :   static unsigned calculateHash(GenericDINode *N) {
     319          15 :     return MDNodeOpsKey::calculateHash(N, 1);
     320             :   }
     321             : };
     322             : 
     323             : template <> struct MDNodeKeyImpl<DISubrange> {
     324             :   Metadata *CountNode;
     325             :   int64_t LowerBound;
     326             : 
     327             :   MDNodeKeyImpl(Metadata *CountNode, int64_t LowerBound)
     328        3630 :       : CountNode(CountNode), LowerBound(LowerBound) {}
     329             :   MDNodeKeyImpl(const DISubrange *N)
     330        3226 :       : CountNode(N->getRawCountNode()),
     331        3226 :         LowerBound(N->getLowerBound()) {}
     332             : 
     333         703 :   bool isKeyOf(const DISubrange *RHS) const {
     334         703 :     if (LowerBound != RHS->getLowerBound())
     335             :       return false;
     336             : 
     337        1406 :     if (auto *RHSCount = RHS->getCount().dyn_cast<ConstantInt*>())
     338         699 :       if (auto *MD = dyn_cast<ConstantAsMetadata>(CountNode))
     339         699 :         if (RHSCount->getSExtValue() ==
     340             :             cast<ConstantInt>(MD->getValue())->getSExtValue())
     341             :           return true;
     342             : 
     343         346 :     return CountNode == RHS->getRawCountNode();
     344             :   }
     345             : 
     346        5997 :   unsigned getHashValue() const {
     347        5997 :     if (auto *MD = dyn_cast<ConstantAsMetadata>(CountNode))
     348       11828 :       return hash_combine(cast<ConstantInt>(MD->getValue())->getSExtValue(),
     349       11828 :                           LowerBound);
     350         166 :     return hash_combine(CountNode, LowerBound);
     351             :   }
     352             : };
     353             : 
     354             : template <> struct MDNodeKeyImpl<DIEnumerator> {
     355             :   int64_t Value;
     356             :   MDString *Name;
     357             :   bool IsUnsigned;
     358             : 
     359             :   MDNodeKeyImpl(int64_t Value, bool IsUnsigned, MDString *Name)
     360       17799 :       : Value(Value), Name(Name), IsUnsigned(IsUnsigned) {}
     361             :   MDNodeKeyImpl(const DIEnumerator *N)
     362       35069 :       : Value(N->getValue()), Name(N->getRawName()),
     363      105207 :         IsUnsigned(N->isUnsigned()) {}
     364             : 
     365             :   bool isKeyOf(const DIEnumerator *RHS) const {
     366       22579 :     return Value == RHS->getValue() && IsUnsigned == RHS->isUnsigned() &&
     367         234 :            Name == RHS->getRawName();
     368             :   }
     369             : 
     370      104948 :   unsigned getHashValue() const { return hash_combine(Value, Name); }
     371             : };
     372             : 
     373             : template <> struct MDNodeKeyImpl<DIBasicType> {
     374             :   unsigned Tag;
     375             :   MDString *Name;
     376             :   uint64_t SizeInBits;
     377             :   uint32_t AlignInBits;
     378             :   unsigned Encoding;
     379             : 
     380             :   MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits,
     381             :                 uint32_t AlignInBits, unsigned Encoding)
     382       12236 :       : Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
     383       12236 :         Encoding(Encoding) {}
     384             :   MDNodeKeyImpl(const DIBasicType *N)
     385       23704 :       : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()),
     386       35556 :         AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {}
     387             : 
     388        1542 :   bool isKeyOf(const DIBasicType *RHS) const {
     389        4784 :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     390         776 :            SizeInBits == RHS->getSizeInBits() &&
     391        2318 :            AlignInBits == RHS->getAlignInBits() &&
     392        1930 :            Encoding == RHS->getEncoding();
     393             :   }
     394             : 
     395             :   unsigned getHashValue() const {
     396       42014 :     return hash_combine(Tag, Name, SizeInBits, AlignInBits, Encoding);
     397             :   }
     398             : };
     399             : 
     400             : template <> struct MDNodeKeyImpl<DIDerivedType> {
     401             :   unsigned Tag;
     402             :   MDString *Name;
     403             :   Metadata *File;
     404             :   unsigned Line;
     405             :   Metadata *Scope;
     406             :   Metadata *BaseType;
     407             :   uint64_t SizeInBits;
     408             :   uint64_t OffsetInBits;
     409             :   uint32_t AlignInBits;
     410             :   Optional<unsigned> DWARFAddressSpace;
     411             :   unsigned Flags;
     412             :   Metadata *ExtraData;
     413             : 
     414             :   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
     415             :                 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
     416             :                 uint32_t AlignInBits, uint64_t OffsetInBits,
     417             :                 Optional<unsigned> DWARFAddressSpace, unsigned Flags,
     418             :                 Metadata *ExtraData)
     419      374237 :       : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
     420             :         BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
     421             :         AlignInBits(AlignInBits), DWARFAddressSpace(DWARFAddressSpace),
     422      748474 :         Flags(Flags), ExtraData(ExtraData) {}
     423      769165 :   MDNodeKeyImpl(const DIDerivedType *N)
     424      769165 :       : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
     425      769165 :         Line(N->getLine()), Scope(N->getRawScope()),
     426      769165 :         BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
     427     1538330 :         OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
     428      769165 :         DWARFAddressSpace(N->getDWARFAddressSpace()), Flags(N->getFlags()),
     429     8460815 :         ExtraData(N->getRawExtraData()) {}
     430             : 
     431     1009508 :   bool isKeyOf(const DIDerivedType *RHS) const {
     432     2355985 :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     433     1248140 :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     434     1545302 :            Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
     435      597429 :            SizeInBits == RHS->getSizeInBits() &&
     436      597404 :            AlignInBits == RHS->getAlignInBits() &&
     437      597384 :            OffsetInBits == RHS->getOffsetInBits() &&
     438     1010436 :            DWARFAddressSpace == RHS->getDWARFAddressSpace() &&
     439     1605942 :            Flags == RHS->getFlags() &&
     440     1307265 :            ExtraData == RHS->getRawExtraData();
     441             :   }
     442             : 
     443     1141178 :   unsigned getHashValue() const {
     444             :     // If this is a member inside an ODR type, only hash the type and the name.
     445             :     // Otherwise the hash will be stronger than
     446             :     // MDNodeSubsetEqualImpl::isODRMember().
     447     1141178 :     if (Tag == dwarf::DW_TAG_member && Name)
     448      198512 :       if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
     449             :         if (CT->getRawIdentifier())
     450      378344 :           return hash_combine(Name, Scope);
     451             : 
     452             :     // Intentionally computes the hash on a subset of the operands for
     453             :     // performance reason. The subset has to be significant enough to avoid
     454             :     // collision "most of the time". There is no correctness issue in case of
     455             :     // collision because of the full check above.
     456     1904012 :     return hash_combine(Tag, Name, File, Line, Scope, BaseType, Flags);
     457             :   }
     458             : };
     459             : 
     460             : template <> struct MDNodeSubsetEqualImpl<DIDerivedType> {
     461             :   using KeyTy = MDNodeKeyImpl<DIDerivedType>;
     462             : 
     463             :   static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS) {
     464     1009589 :     return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
     465             :   }
     466             : 
     467      445264 :   static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS) {
     468      445264 :     return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
     469      445264 :                        RHS);
     470             :   }
     471             : 
     472             :   /// Subprograms compare equal if they declare the same function in an ODR
     473             :   /// type.
     474     1454853 :   static bool isODRMember(unsigned Tag, const Metadata *Scope,
     475             :                           const MDString *Name, const DIDerivedType *RHS) {
     476             :     // Check whether the LHS is eligible.
     477     1454853 :     if (Tag != dwarf::DW_TAG_member || !Name)
     478             :       return false;
     479             : 
     480             :     auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
     481             :     if (!CT || !CT->getRawIdentifier())
     482             :       return false;
     483             : 
     484             :     // Compare to the RHS.
     485      411125 :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     486             :            Scope == RHS->getRawScope();
     487             :   }
     488             : };
     489             : 
     490             : template <> struct MDNodeKeyImpl<DICompositeType> {
     491             :   unsigned Tag;
     492             :   MDString *Name;
     493             :   Metadata *File;
     494             :   unsigned Line;
     495             :   Metadata *Scope;
     496             :   Metadata *BaseType;
     497             :   uint64_t SizeInBits;
     498             :   uint64_t OffsetInBits;
     499             :   uint32_t AlignInBits;
     500             :   unsigned Flags;
     501             :   Metadata *Elements;
     502             :   unsigned RuntimeLang;
     503             :   Metadata *VTableHolder;
     504             :   Metadata *TemplateParams;
     505             :   MDString *Identifier;
     506             :   Metadata *Discriminator;
     507             : 
     508             :   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
     509             :                 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
     510             :                 uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
     511             :                 Metadata *Elements, unsigned RuntimeLang,
     512             :                 Metadata *VTableHolder, Metadata *TemplateParams,
     513             :                 MDString *Identifier, Metadata *Discriminator)
     514        5783 :       : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
     515             :         BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
     516             :         AlignInBits(AlignInBits), Flags(Flags), Elements(Elements),
     517             :         RuntimeLang(RuntimeLang), VTableHolder(VTableHolder),
     518             :         TemplateParams(TemplateParams), Identifier(Identifier),
     519        5783 :         Discriminator(Discriminator) {}
     520       22398 :   MDNodeKeyImpl(const DICompositeType *N)
     521       22398 :       : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
     522       22398 :         Line(N->getLine()), Scope(N->getRawScope()),
     523       22398 :         BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
     524       44796 :         OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
     525       22398 :         Flags(N->getFlags()), Elements(N->getRawElements()),
     526       22398 :         RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()),
     527             :         TemplateParams(N->getRawTemplateParams()),
     528             :         Identifier(N->getRawIdentifier()),
     529      358368 :         Discriminator(N->getRawDiscriminator()) {}
     530             : 
     531        5849 :   bool isKeyOf(const DICompositeType *RHS) const {
     532       12621 :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     533        1507 :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     534        1860 :            Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
     535         535 :            SizeInBits == RHS->getSizeInBits() &&
     536         324 :            AlignInBits == RHS->getAlignInBits() &&
     537         454 :            OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() &&
     538         290 :            Elements == RHS->getRawElements() &&
     539         272 :            RuntimeLang == RHS->getRuntimeLang() &&
     540         250 :            VTableHolder == RHS->getRawVTableHolder() &&
     541         246 :            TemplateParams == RHS->getRawTemplateParams() &&
     542        6087 :            Identifier == RHS->getRawIdentifier() &&
     543        5964 :            Discriminator == RHS->getRawDiscriminator();
     544             :   }
     545             : 
     546             :   unsigned getHashValue() const {
     547             :     // Intentionally computes the hash on a subset of the operands for
     548             :     // performance reason. The subset has to be significant enough to avoid
     549             :     // collision "most of the time". There is no correctness issue in case of
     550             :     // collision because of the full check above.
     551       53676 :     return hash_combine(Name, File, Line, BaseType, Scope, Elements,
     552       36735 :                         TemplateParams);
     553             :   }
     554             : };
     555             : 
     556             : template <> struct MDNodeKeyImpl<DISubroutineType> {
     557             :   unsigned Flags;
     558             :   uint8_t CC;
     559             :   Metadata *TypeArray;
     560             : 
     561             :   MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray)
     562      382953 :       : Flags(Flags), CC(CC), TypeArray(TypeArray) {}
     563             :   MDNodeKeyImpl(const DISubroutineType *N)
     564     1428130 :       : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {}
     565             : 
     566             :   bool isKeyOf(const DISubroutineType *RHS) const {
     567     1187905 :     return Flags == RHS->getFlags() && CC == RHS->getCC() &&
     568      593915 :            TypeArray == RHS->getRawTypeArray();
     569             :   }
     570             : 
     571     2187124 :   unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); }
     572             : };
     573             : 
     574             : template <> struct MDNodeKeyImpl<DIFile> {
     575             :   MDString *Filename;
     576             :   MDString *Directory;
     577             :   Optional<DIFile::ChecksumInfo<MDString *>> Checksum;
     578             :   Optional<MDString *> Source;
     579             : 
     580             :   MDNodeKeyImpl(MDString *Filename, MDString *Directory,
     581             :                 Optional<DIFile::ChecksumInfo<MDString *>> Checksum,
     582             :                 Optional<MDString *> Source)
     583       52210 :       : Filename(Filename), Directory(Directory), Checksum(Checksum),
     584       52210 :         Source(Source) {}
     585       39842 :   MDNodeKeyImpl(const DIFile *N)
     586       39842 :       : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
     587      119526 :         Checksum(N->getRawChecksum()), Source(N->getRawSource()) {}
     588             : 
     589       41774 :   bool isKeyOf(const DIFile *RHS) const {
     590       66242 :     return Filename == RHS->getRawFilename() &&
     591       48874 :            Directory == RHS->getRawDirectory() &&
     592       66240 :            Checksum == RHS->getRawChecksum() &&
     593       41774 :            Source == RHS->getRawSource();
     594             :   }
     595             : 
     596       87906 :   unsigned getHashValue() const {
     597      175812 :     return hash_combine(
     598      175812 :         Filename, Directory, Checksum ? Checksum->Kind : 0,
     599      351624 :         Checksum ? Checksum->Value : nullptr, Source.getValueOr(nullptr));
     600             :   }
     601             : };
     602             : 
     603             : template <> struct MDNodeKeyImpl<DISubprogram> {
     604             :   Metadata *Scope;
     605             :   MDString *Name;
     606             :   MDString *LinkageName;
     607             :   Metadata *File;
     608             :   unsigned Line;
     609             :   Metadata *Type;
     610             :   bool IsLocalToUnit;
     611             :   bool IsDefinition;
     612             :   unsigned ScopeLine;
     613             :   Metadata *ContainingType;
     614             :   unsigned Virtuality;
     615             :   unsigned VirtualIndex;
     616             :   int ThisAdjustment;
     617             :   unsigned Flags;
     618             :   bool IsOptimized;
     619             :   Metadata *Unit;
     620             :   Metadata *TemplateParams;
     621             :   Metadata *Declaration;
     622             :   Metadata *RetainedNodes;
     623             :   Metadata *ThrownTypes;
     624             : 
     625             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
     626             :                 Metadata *File, unsigned Line, Metadata *Type,
     627             :                 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
     628             :                 Metadata *ContainingType, unsigned Virtuality,
     629             :                 unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
     630             :                 bool IsOptimized, Metadata *Unit, Metadata *TemplateParams,
     631             :                 Metadata *Declaration, Metadata *RetainedNodes,
     632             :                 Metadata *ThrownTypes)
     633      177400 :       : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
     634             :         Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
     635             :         IsDefinition(IsDefinition), ScopeLine(ScopeLine),
     636             :         ContainingType(ContainingType), Virtuality(Virtuality),
     637             :         VirtualIndex(VirtualIndex), ThisAdjustment(ThisAdjustment),
     638             :         Flags(Flags), IsOptimized(IsOptimized), Unit(Unit),
     639             :         TemplateParams(TemplateParams), Declaration(Declaration),
     640      177400 :         RetainedNodes(RetainedNodes), ThrownTypes(ThrownTypes) {}
     641      653805 :   MDNodeKeyImpl(const DISubprogram *N)
     642      653805 :       : Scope(N->getRawScope()), Name(N->getRawName()),
     643             :         LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
     644      653805 :         Line(N->getLine()), Type(N->getRawType()),
     645             :         IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
     646      653805 :         ScopeLine(N->getScopeLine()), ContainingType(N->getRawContainingType()),
     647      653805 :         Virtuality(N->getVirtuality()), VirtualIndex(N->getVirtualIndex()),
     648     1307610 :         ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()),
     649             :         IsOptimized(N->isOptimized()), Unit(N->getRawUnit()),
     650             :         TemplateParams(N->getRawTemplateParams()),
     651             :         Declaration(N->getRawDeclaration()), RetainedNodes(N->getRawRetainedNodes()),
     652    13076100 :         ThrownTypes(N->getRawThrownTypes()) {}
     653             : 
     654      382133 :   bool isKeyOf(const DISubprogram *RHS) const {
     655      497659 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     656       22026 :            LinkageName == RHS->getRawLinkageName() &&
     657       31878 :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     658       41009 :            Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
     659       20473 :            IsDefinition == RHS->isDefinition() &&
     660       20452 :            ScopeLine == RHS->getScopeLine() &&
     661       20433 :            ContainingType == RHS->getRawContainingType() &&
     662       20416 :            Virtuality == RHS->getVirtuality() &&
     663       20401 :            VirtualIndex == RHS->getVirtualIndex() &&
     664       20394 :            ThisAdjustment == RHS->getThisAdjustment() &&
     665       40782 :            Flags == RHS->getFlags() && IsOptimized == RHS->isOptimized() &&
     666       20377 :            Unit == RHS->getUnit() &&
     667       20367 :            TemplateParams == RHS->getRawTemplateParams() &&
     668       20359 :            Declaration == RHS->getRawDeclaration() &&
     669      402487 :            RetainedNodes == RHS->getRawRetainedNodes() &&
     670      392309 :            ThrownTypes == RHS->getRawThrownTypes();
     671             :   }
     672             : 
     673      830179 :   unsigned getHashValue() const {
     674             :     // If this is a declaration inside an ODR type, only hash the type and the
     675             :     // name.  Otherwise the hash will be stronger than
     676             :     // MDNodeSubsetEqualImpl::isDeclarationOfODRMember().
     677      830179 :     if (!IsDefinition && LinkageName)
     678      467849 :       if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
     679             :         if (CT->getRawIdentifier())
     680      927310 :           return hash_combine(LinkageName, Scope);
     681             : 
     682             :     // Intentionally computes the hash on a subset of the operands for
     683             :     // performance reason. The subset has to be significant enough to avoid
     684             :     // collision "most of the time". There is no correctness issue in case of
     685             :     // collision because of the full check above.
     686      733048 :     return hash_combine(Name, Scope, File, Type, Line);
     687             :   }
     688             : };
     689             : 
     690             : template <> struct MDNodeSubsetEqualImpl<DISubprogram> {
     691             :   using KeyTy = MDNodeKeyImpl<DISubprogram>;
     692             : 
     693             :   static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
     694      382141 :     return isDeclarationOfODRMember(LHS.IsDefinition, LHS.Scope,
     695      764282 :                                     LHS.LinkageName, LHS.TemplateParams, RHS);
     696             :   }
     697             : 
     698      447650 :   static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) {
     699      447650 :     return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(),
     700             :                                     LHS->getRawLinkageName(),
     701      447650 :                                     LHS->getRawTemplateParams(), RHS);
     702             :   }
     703             : 
     704             :   /// Subprograms compare equal if they declare the same function in an ODR
     705             :   /// type.
     706      829791 :   static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope,
     707             :                                        const MDString *LinkageName,
     708             :                                        const Metadata *TemplateParams,
     709             :                                        const DISubprogram *RHS) {
     710             :     // Check whether the LHS is eligible.
     711      829791 :     if (IsDefinition || !Scope || !LinkageName)
     712             :       return false;
     713             : 
     714             :     auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
     715             :     if (!CT || !CT->getRawIdentifier())
     716             :       return false;
     717             : 
     718             :     // Compare to the RHS.
     719             :     // FIXME: We need to compare template parameters here to avoid incorrect
     720             :     // collisions in mapMetadata when RF_MoveDistinctMDs and a ODR-DISubprogram
     721             :     // has a non-ODR template parameter (i.e., a DICompositeType that does not
     722             :     // have an identifier). Eventually we should decouple ODR logic from
     723             :     // uniquing logic.
     724      471963 :     return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() &&
     725      424939 :            LinkageName == RHS->getRawLinkageName() &&
     726             :            TemplateParams == RHS->getRawTemplateParams();
     727             :   }
     728             : };
     729             : 
     730             : template <> struct MDNodeKeyImpl<DILexicalBlock> {
     731             :   Metadata *Scope;
     732             :   Metadata *File;
     733             :   unsigned Line;
     734             :   unsigned Column;
     735             : 
     736             :   MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
     737          41 :       : Scope(Scope), File(File), Line(Line), Column(Column) {}
     738             :   MDNodeKeyImpl(const DILexicalBlock *N)
     739          76 :       : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
     740         152 :         Column(N->getColumn()) {}
     741             : 
     742           7 :   bool isKeyOf(const DILexicalBlock *RHS) const {
     743          26 :     return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
     744          22 :            Line == RHS->getLine() && Column == RHS->getColumn();
     745             :   }
     746             : 
     747             :   unsigned getHashValue() const {
     748         122 :     return hash_combine(Scope, File, Line, Column);
     749             :   }
     750             : };
     751             : 
     752             : template <> struct MDNodeKeyImpl<DILexicalBlockFile> {
     753             :   Metadata *Scope;
     754             :   Metadata *File;
     755             :   unsigned Discriminator;
     756             : 
     757             :   MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
     758         926 :       : Scope(Scope), File(File), Discriminator(Discriminator) {}
     759             :   MDNodeKeyImpl(const DILexicalBlockFile *N)
     760         720 :       : Scope(N->getRawScope()), File(N->getRawFile()),
     761        1440 :         Discriminator(N->getDiscriminator()) {}
     762             : 
     763             :   bool isKeyOf(const DILexicalBlockFile *RHS) const {
     764        1930 :     return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
     765         468 :            Discriminator == RHS->getDiscriminator();
     766             :   }
     767             : 
     768             :   unsigned getHashValue() const {
     769        2906 :     return hash_combine(Scope, File, Discriminator);
     770             :   }
     771             : };
     772             : 
     773             : template <> struct MDNodeKeyImpl<DINamespace> {
     774             :   Metadata *Scope;
     775             :   MDString *Name;
     776             :   bool ExportSymbols;
     777             : 
     778             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, bool ExportSymbols)
     779       17269 :       : Scope(Scope), Name(Name), ExportSymbols(ExportSymbols) {}
     780             :   MDNodeKeyImpl(const DINamespace *N)
     781        3485 :       : Scope(N->getRawScope()), Name(N->getRawName()),
     782       10455 :         ExportSymbols(N->getExportSymbols()) {}
     783             : 
     784       14217 :   bool isKeyOf(const DINamespace *RHS) const {
     785       56264 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     786       28050 :            ExportSymbols == RHS->getExportSymbols();
     787             :   }
     788             : 
     789             :   unsigned getHashValue() const {
     790       40000 :     return hash_combine(Scope, Name);
     791             :   }
     792             : };
     793             : 
     794             : template <> struct MDNodeKeyImpl<DIModule> {
     795             :   Metadata *Scope;
     796             :   MDString *Name;
     797             :   MDString *ConfigurationMacros;
     798             :   MDString *IncludePath;
     799             :   MDString *ISysRoot;
     800             : 
     801             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *ConfigurationMacros,
     802             :                 MDString *IncludePath, MDString *ISysRoot)
     803          96 :       : Scope(Scope), Name(Name), ConfigurationMacros(ConfigurationMacros),
     804          96 :         IncludePath(IncludePath), ISysRoot(ISysRoot) {}
     805          90 :   MDNodeKeyImpl(const DIModule *N)
     806          90 :       : Scope(N->getRawScope()), Name(N->getRawName()),
     807             :         ConfigurationMacros(N->getRawConfigurationMacros()),
     808         450 :         IncludePath(N->getRawIncludePath()), ISysRoot(N->getRawISysRoot()) {}
     809             : 
     810          10 :   bool isKeyOf(const DIModule *RHS) const {
     811          39 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     812          17 :            ConfigurationMacros == RHS->getRawConfigurationMacros() &&
     813          26 :            IncludePath == RHS->getRawIncludePath() &&
     814          18 :            ISysRoot == RHS->getRawISysRoot();
     815             :   }
     816             : 
     817             :   unsigned getHashValue() const {
     818         266 :     return hash_combine(Scope, Name,
     819         177 :                         ConfigurationMacros, IncludePath, ISysRoot);
     820             :   }
     821             : };
     822             : 
     823             : template <> struct MDNodeKeyImpl<DITemplateTypeParameter> {
     824             :   MDString *Name;
     825             :   Metadata *Type;
     826             : 
     827       53521 :   MDNodeKeyImpl(MDString *Name, Metadata *Type) : Name(Name), Type(Type) {}
     828             :   MDNodeKeyImpl(const DITemplateTypeParameter *N)
     829       97653 :       : Name(N->getRawName()), Type(N->getRawType()) {}
     830             : 
     831             :   bool isKeyOf(const DITemplateTypeParameter *RHS) const {
     832      190896 :     return Name == RHS->getRawName() && Type == RHS->getRawType();
     833             :   }
     834             : 
     835      171238 :   unsigned getHashValue() const { return hash_combine(Name, Type); }
     836             : };
     837             : 
     838             : template <> struct MDNodeKeyImpl<DITemplateValueParameter> {
     839             :   unsigned Tag;
     840             :   MDString *Name;
     841             :   Metadata *Type;
     842             :   Metadata *Value;
     843             : 
     844             :   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, Metadata *Value)
     845       21184 :       : Tag(Tag), Name(Name), Type(Type), Value(Value) {}
     846             :   MDNodeKeyImpl(const DITemplateValueParameter *N)
     847        8401 :       : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
     848       33604 :         Value(N->getValue()) {}
     849             : 
     850       22676 :   bool isKeyOf(const DITemplateValueParameter *RHS) const {
     851       78241 :     return Tag == RHS->getTag() && Name == RHS->getRawName() &&
     852       71995 :            Type == RHS->getRawType() && Value == RHS->getValue();
     853             :   }
     854             : 
     855       58484 :   unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
     856             : };
     857             : 
     858             : template <> struct MDNodeKeyImpl<DIGlobalVariable> {
     859             :   Metadata *Scope;
     860             :   MDString *Name;
     861             :   MDString *LinkageName;
     862             :   Metadata *File;
     863             :   unsigned Line;
     864             :   Metadata *Type;
     865             :   bool IsLocalToUnit;
     866             :   bool IsDefinition;
     867             :   Metadata *StaticDataMemberDeclaration;
     868             :   uint32_t AlignInBits;
     869             : 
     870             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
     871             :                 Metadata *File, unsigned Line, Metadata *Type,
     872             :                 bool IsLocalToUnit, bool IsDefinition,
     873             :                 Metadata *StaticDataMemberDeclaration, uint32_t AlignInBits)
     874         559 :       : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
     875             :         Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
     876             :         IsDefinition(IsDefinition),
     877             :         StaticDataMemberDeclaration(StaticDataMemberDeclaration),
     878         559 :         AlignInBits(AlignInBits) {}
     879        2949 :   MDNodeKeyImpl(const DIGlobalVariable *N)
     880        2949 :       : Scope(N->getRawScope()), Name(N->getRawName()),
     881             :         LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
     882        2949 :         Line(N->getLine()), Type(N->getRawType()),
     883        5898 :         IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
     884             :         StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
     885       26541 :         AlignInBits(N->getAlignInBits()) {}
     886             : 
     887         151 :   bool isKeyOf(const DIGlobalVariable *RHS) const {
     888         451 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     889           8 :            LinkageName == RHS->getRawLinkageName() &&
     890          10 :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     891           9 :            Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
     892           6 :            IsDefinition == RHS->isDefinition() &&
     893           3 :            StaticDataMemberDeclaration ==
     894         154 :                RHS->getRawStaticDataMemberDeclaration() &&
     895         154 :            AlignInBits == RHS->getAlignInBits();
     896             :   }
     897             : 
     898        3036 :   unsigned getHashValue() const {
     899             :     // We do not use AlignInBits in hashing function here on purpose:
     900             :     // in most cases this param for local variable is zero (for function param
     901             :     // it is always zero). This leads to lots of hash collisions and errors on
     902             :     // cases with lots of similar variables.
     903             :     // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
     904             :     // generated IR is random for each run and test fails with Align included.
     905             :     // TODO: make hashing work fine with such situations
     906        6072 :     return hash_combine(Scope, Name, LinkageName, File, Line, Type,
     907             :                         IsLocalToUnit, IsDefinition, /* AlignInBits, */
     908        9108 :                         StaticDataMemberDeclaration);
     909             :   }
     910             : };
     911             : 
     912             : template <> struct MDNodeKeyImpl<DILocalVariable> {
     913             :   Metadata *Scope;
     914             :   MDString *Name;
     915             :   Metadata *File;
     916             :   unsigned Line;
     917             :   Metadata *Type;
     918             :   unsigned Arg;
     919             :   unsigned Flags;
     920             :   uint32_t AlignInBits;
     921             : 
     922             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
     923             :                 Metadata *Type, unsigned Arg, unsigned Flags,
     924             :                 uint32_t AlignInBits)
     925       72392 :       : Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
     926       72392 :         Flags(Flags), AlignInBits(AlignInBits) {}
     927      143540 :   MDNodeKeyImpl(const DILocalVariable *N)
     928      143540 :       : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
     929      143540 :         Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
     930      861240 :         Flags(N->getFlags()), AlignInBits(N->getAlignInBits()) {}
     931             : 
     932       81676 :   bool isKeyOf(const DILocalVariable *RHS) const {
     933       86050 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     934         997 :            File == RHS->getRawFile() && Line == RHS->getLine() &&
     935         591 :            Type == RHS->getRawType() && Arg == RHS->getArg() &&
     936       81930 :            Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits();
     937             :   }
     938             : 
     939             :   unsigned getHashValue() const {
     940             :     // We do not use AlignInBits in hashing function here on purpose:
     941             :     // in most cases this param for local variable is zero (for function param
     942             :     // it is always zero). This leads to lots of hash collisions and errors on
     943             :     // cases with lots of similar variables.
     944             :     // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
     945             :     // generated IR is random for each run and test fails with Align included.
     946             :     // TODO: make hashing work fine with such situations
     947      426872 :     return hash_combine(Scope, Name, File, Line, Type, Arg, Flags);
     948             :   }
     949             : };
     950             : 
     951             : template <> struct MDNodeKeyImpl<DILabel> {
     952             :   Metadata *Scope;
     953             :   MDString *Name;
     954             :   Metadata *File;
     955             :   unsigned Line;
     956             : 
     957             :   MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line)
     958          27 :       : Scope(Scope), Name(Name), File(File), Line(Line) {}
     959             :   MDNodeKeyImpl(const DILabel *N)
     960          30 :       : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
     961          90 :         Line(N->getLine()) {}
     962             : 
     963           0 :   bool isKeyOf(const DILabel *RHS) const {
     964           0 :     return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
     965           0 :            File == RHS->getRawFile() && Line == RHS->getLine();
     966             :   }
     967             : 
     968             :   /// Using name and line to get hash value. It should already be mostly unique.
     969             :   unsigned getHashValue() const {
     970          86 :     return hash_combine(Scope, Name, Line);
     971             :   }
     972             : };
     973             : 
     974             : template <> struct MDNodeKeyImpl<DIExpression> {
     975             :   ArrayRef<uint64_t> Elements;
     976             : 
     977       83506 :   MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
     978           2 :   MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
     979             : 
     980             :   bool isKeyOf(const DIExpression *RHS) const {
     981             :     return Elements == RHS->getElements();
     982             :   }
     983             : 
     984             :   unsigned getHashValue() const {
     985       85572 :     return hash_combine_range(Elements.begin(), Elements.end());
     986             :   }
     987             : };
     988             : 
     989             : template <> struct MDNodeKeyImpl<DIGlobalVariableExpression> {
     990             :   Metadata *Variable;
     991             :   Metadata *Expression;
     992             : 
     993             :   MDNodeKeyImpl(Metadata *Variable, Metadata *Expression)
     994        4519 :       : Variable(Variable), Expression(Expression) {}
     995             :   MDNodeKeyImpl(const DIGlobalVariableExpression *N)
     996       23214 :       : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {}
     997             : 
     998             :   bool isKeyOf(const DIGlobalVariableExpression *RHS) const {
     999        4185 :     return Variable == RHS->getRawVariable() &&
    1000           5 :            Expression == RHS->getRawExpression();
    1001             :   }
    1002             : 
    1003       22358 :   unsigned getHashValue() const { return hash_combine(Variable, Expression); }
    1004             : };
    1005             : 
    1006             : template <> struct MDNodeKeyImpl<DIObjCProperty> {
    1007             :   MDString *Name;
    1008             :   Metadata *File;
    1009             :   unsigned Line;
    1010             :   MDString *GetterName;
    1011             :   MDString *SetterName;
    1012             :   unsigned Attributes;
    1013             :   Metadata *Type;
    1014             : 
    1015             :   MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line,
    1016             :                 MDString *GetterName, MDString *SetterName, unsigned Attributes,
    1017             :                 Metadata *Type)
    1018         122 :       : Name(Name), File(File), Line(Line), GetterName(GetterName),
    1019         122 :         SetterName(SetterName), Attributes(Attributes), Type(Type) {}
    1020          91 :   MDNodeKeyImpl(const DIObjCProperty *N)
    1021         182 :       : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
    1022             :         GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()),
    1023         546 :         Attributes(N->getAttributes()), Type(N->getRawType()) {}
    1024             : 
    1025          38 :   bool isKeyOf(const DIObjCProperty *RHS) const {
    1026         137 :     return Name == RHS->getRawName() && File == RHS->getRawFile() &&
    1027         132 :            Line == RHS->getLine() && GetterName == RHS->getRawGetterName() &&
    1028          66 :            SetterName == RHS->getRawSetterName() &&
    1029         137 :            Attributes == RHS->getAttributes() && Type == RHS->getRawType();
    1030             :   }
    1031             : 
    1032             :   unsigned getHashValue() const {
    1033         334 :     return hash_combine(Name, File, Line, GetterName, SetterName, Attributes,
    1034         244 :                         Type);
    1035             :   }
    1036             : };
    1037             : 
    1038             : template <> struct MDNodeKeyImpl<DIImportedEntity> {
    1039             :   unsigned Tag;
    1040             :   Metadata *Scope;
    1041             :   Metadata *Entity;
    1042             :   Metadata *File;
    1043             :   unsigned Line;
    1044             :   MDString *Name;
    1045             : 
    1046             :   MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, Metadata *File,
    1047             :                 unsigned Line, MDString *Name)
    1048       95543 :       : Tag(Tag), Scope(Scope), Entity(Entity), File(File), Line(Line),
    1049       95543 :         Name(Name) {}
    1050      251341 :   MDNodeKeyImpl(const DIImportedEntity *N)
    1051      251341 :       : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
    1052     1256705 :         File(N->getRawFile()), Line(N->getLine()), Name(N->getRawName()) {}
    1053             : 
    1054      137288 :   bool isKeyOf(const DIImportedEntity *RHS) const {
    1055      520316 :     return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
    1056      111031 :            Entity == RHS->getRawEntity() && File == RHS->getFile() &&
    1057      137315 :            Line == RHS->getLine() && Name == RHS->getRawName();
    1058             :   }
    1059             : 
    1060             :   unsigned getHashValue() const {
    1061      692448 :     return hash_combine(Tag, Scope, Entity, File, Line, Name);
    1062             :   }
    1063             : };
    1064             : 
    1065             : template <> struct MDNodeKeyImpl<DIMacro> {
    1066             :   unsigned MIType;
    1067             :   unsigned Line;
    1068             :   MDString *Name;
    1069             :   MDString *Value;
    1070             : 
    1071             :   MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value)
    1072        1106 :       : MIType(MIType), Line(Line), Name(Name), Value(Value) {}
    1073             :   MDNodeKeyImpl(const DIMacro *N)
    1074        4210 :       : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()),
    1075        8420 :         Value(N->getRawValue()) {}
    1076             : 
    1077        1554 :   bool isKeyOf(const DIMacro *RHS) const {
    1078        4483 :     return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
    1079        3022 :            Name == RHS->getRawName() && Value == RHS->getRawValue();
    1080             :   }
    1081             : 
    1082             :   unsigned getHashValue() const {
    1083        6352 :     return hash_combine(MIType, Line, Name, Value);
    1084             :   }
    1085             : };
    1086             : 
    1087             : template <> struct MDNodeKeyImpl<DIMacroFile> {
    1088             :   unsigned MIType;
    1089             :   unsigned Line;
    1090             :   Metadata *File;
    1091             :   Metadata *Elements;
    1092             : 
    1093             :   MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File,
    1094             :                 Metadata *Elements)
    1095          66 :       : MIType(MIType), Line(Line), File(File), Elements(Elements) {}
    1096             :   MDNodeKeyImpl(const DIMacroFile *N)
    1097         210 :       : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()),
    1098         420 :         Elements(N->getRawElements()) {}
    1099             : 
    1100           5 :   bool isKeyOf(const DIMacroFile *RHS) const {
    1101          13 :     return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
    1102          14 :            File == RHS->getRawFile() && Elements == RHS->getRawElements();
    1103             :   }
    1104             : 
    1105             :   unsigned getHashValue() const {
    1106         272 :     return hash_combine(MIType, Line, File, Elements);
    1107             :   }
    1108             : };
    1109             : 
    1110             : /// DenseMapInfo for MDNode subclasses.
    1111             : template <class NodeTy> struct MDNodeInfo {
    1112             :   using KeyTy = MDNodeKeyImpl<NodeTy>;
    1113             :   using SubsetEqualTy = MDNodeSubsetEqualImpl<NodeTy>;
    1114             : 
    1115             :   static inline NodeTy *getEmptyKey() {
    1116             :     return DenseMapInfo<NodeTy *>::getEmptyKey();
    1117             :   }
    1118             : 
    1119             :   static inline NodeTy *getTombstoneKey() {
    1120             :     return DenseMapInfo<NodeTy *>::getTombstoneKey();
    1121             :   }
    1122             : 
    1123      860177 :   static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
    1124             : 
    1125     4040330 :   static unsigned getHashValue(const NodeTy *N) {
    1126     5649059 :     return KeyTy(N).getHashValue();
    1127             :   }
    1128             : 
    1129     9996890 :   static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
    1130    13163312 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
    1131             :       return false;
    1132     4998816 :     return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS);
    1133             :   }
    1134             : 
    1135             :   static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
    1136    56082577 :     if (LHS == RHS)
    1137             :       return true;
    1138     2053559 :     if (RHS == getEmptyKey() || RHS == getTombstoneKey())
    1139             :       return false;
    1140      892914 :     return SubsetEqualTy::isSubsetEqual(LHS, RHS);
    1141             :   }
    1142             : };
    1143             : 
    1144             : #define HANDLE_MDNODE_LEAF(CLASS) using CLASS##Info = MDNodeInfo<CLASS>;
    1145             : #include "llvm/IR/Metadata.def"
    1146             : 
    1147             : /// Map-like storage for metadata attachments.
    1148      924582 : class MDAttachmentMap {
    1149             :   SmallVector<std::pair<unsigned, TrackingMDNodeRef>, 2> Attachments;
    1150             : 
    1151             : public:
    1152     1621574 :   bool empty() const { return Attachments.empty(); }
    1153             :   size_t size() const { return Attachments.size(); }
    1154             : 
    1155             :   /// Get a particular attachment (if any).
    1156             :   MDNode *lookup(unsigned ID) const;
    1157             : 
    1158             :   /// Set an attachment to a particular node.
    1159             :   ///
    1160             :   /// Set the \c ID attachment to \c MD, replacing the current attachment at \c
    1161             :   /// ID (if anyway).
    1162             :   void set(unsigned ID, MDNode &MD);
    1163             : 
    1164             :   /// Remove an attachment.
    1165             :   ///
    1166             :   /// Remove the attachment at \c ID, if any.
    1167             :   bool erase(unsigned ID);
    1168             : 
    1169             :   /// Copy out all the attachments.
    1170             :   ///
    1171             :   /// Copies all the current attachments into \c Result, sorting by attachment
    1172             :   /// ID.  This function does \em not clear \c Result.
    1173             :   void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
    1174             : 
    1175             :   /// Erase matching attachments.
    1176             :   ///
    1177             :   /// Erases all attachments matching the \c shouldRemove predicate.
    1178        2963 :   template <class PredTy> void remove_if(PredTy shouldRemove) {
    1179        5926 :     Attachments.erase(llvm::remove_if(Attachments, shouldRemove),
    1180             :                       Attachments.end());
    1181        2963 :   }
    1182             : };
    1183             : 
    1184             : /// Multimap-like storage for metadata attachments for globals. This differs
    1185             : /// from MDAttachmentMap in that it allows multiple attachments per metadata
    1186             : /// kind.
    1187      100853 : class MDGlobalAttachmentMap {
    1188      253483 :   struct Attachment {
    1189             :     unsigned MDKind;
    1190             :     TrackingMDNodeRef Node;
    1191             :   };
    1192             :   SmallVector<Attachment, 1> Attachments;
    1193             : 
    1194             : public:
    1195        2783 :   bool empty() const { return Attachments.empty(); }
    1196             : 
    1197             :   /// Appends all attachments with the given ID to \c Result in insertion order.
    1198             :   /// If the global has no attachments with the given ID, or if ID is invalid,
    1199             :   /// leaves Result unchanged.
    1200             :   void get(unsigned ID, SmallVectorImpl<MDNode *> &Result) const;
    1201             : 
    1202             :   /// Returns the first attachment with the given ID or nullptr if no such
    1203             :   /// attachment exists.
    1204             :   MDNode *lookup(unsigned ID) const;
    1205             : 
    1206             :   void insert(unsigned ID, MDNode &MD);
    1207             :   bool erase(unsigned ID);
    1208             : 
    1209             :   /// Appends all attachments for the global to \c Result, sorting by attachment
    1210             :   /// ID. Attachments with the same ID appear in insertion order. This function
    1211             :   /// does \em not clear \c Result.
    1212             :   void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
    1213             : };
    1214             : 
    1215             : class LLVMContextImpl {
    1216             : public:
    1217             :   /// OwnedModules - The set of modules instantiated in this context, and which
    1218             :   /// will be automatically deleted if this context is deleted.
    1219             :   SmallPtrSet<Module*, 4> OwnedModules;
    1220             :   
    1221             :   LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler = nullptr;
    1222             :   void *InlineAsmDiagContext = nullptr;
    1223             : 
    1224             :   std::unique_ptr<DiagnosticHandler> DiagHandler;
    1225             :   bool RespectDiagnosticFilters = false;
    1226             :   bool DiagnosticsHotnessRequested = false;
    1227             :   uint64_t DiagnosticsHotnessThreshold = 0;
    1228             :   std::unique_ptr<yaml::Output> DiagnosticsOutputFile;
    1229             : 
    1230             :   LLVMContext::YieldCallbackTy YieldCallback = nullptr;
    1231             :   void *YieldOpaqueHandle = nullptr;
    1232             : 
    1233             :   using IntMapTy =
    1234             :       DenseMap<APInt, std::unique_ptr<ConstantInt>, DenseMapAPIntKeyInfo>;
    1235             :   IntMapTy IntConstants;
    1236             : 
    1237             :   using FPMapTy =
    1238             :       DenseMap<APFloat, std::unique_ptr<ConstantFP>, DenseMapAPFloatKeyInfo>;
    1239             :   FPMapTy FPConstants;
    1240             : 
    1241             :   FoldingSet<AttributeImpl> AttrsSet;
    1242             :   FoldingSet<AttributeListImpl> AttrsLists;
    1243             :   FoldingSet<AttributeSetNode> AttrsSetNodes;
    1244             : 
    1245             :   StringMap<MDString, BumpPtrAllocator> MDStringCache;
    1246             :   DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
    1247             :   DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
    1248             : 
    1249             :   DenseMap<const Value*, ValueName*> ValueNames;
    1250             : 
    1251             : #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS)                                    \
    1252             :   DenseSet<CLASS *, CLASS##Info> CLASS##s;
    1253             : #include "llvm/IR/Metadata.def"
    1254             : 
    1255             :   // Optional map for looking up composite types by identifier.
    1256             :   Optional<DenseMap<const MDString *, DICompositeType *>> DITypeMap;
    1257             : 
    1258             :   // MDNodes may be uniqued or not uniqued.  When they're not uniqued, they
    1259             :   // aren't in the MDNodeSet, but they're still shared between objects, so no
    1260             :   // one object can destroy them.  Keep track of them here so we can delete
    1261             :   // them on context teardown.
    1262             :   std::vector<MDNode *> DistinctMDNodes;
    1263             : 
    1264             :   DenseMap<Type *, std::unique_ptr<ConstantAggregateZero>> CAZConstants;
    1265             : 
    1266             :   using ArrayConstantsTy = ConstantUniqueMap<ConstantArray>;
    1267             :   ArrayConstantsTy ArrayConstants;
    1268             :   
    1269             :   using StructConstantsTy = ConstantUniqueMap<ConstantStruct>;
    1270             :   StructConstantsTy StructConstants;
    1271             :   
    1272             :   using VectorConstantsTy = ConstantUniqueMap<ConstantVector>;
    1273             :   VectorConstantsTy VectorConstants;
    1274             : 
    1275             :   DenseMap<PointerType *, std::unique_ptr<ConstantPointerNull>> CPNConstants;
    1276             : 
    1277             :   DenseMap<Type *, std::unique_ptr<UndefValue>> UVConstants;
    1278             : 
    1279             :   StringMap<ConstantDataSequential*> CDSConstants;
    1280             : 
    1281             :   DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *>
    1282             :     BlockAddresses;
    1283             :   ConstantUniqueMap<ConstantExpr> ExprConstants;
    1284             : 
    1285             :   ConstantUniqueMap<InlineAsm> InlineAsms;
    1286             : 
    1287             :   ConstantInt *TheTrueVal = nullptr;
    1288             :   ConstantInt *TheFalseVal = nullptr;
    1289             : 
    1290             :   std::unique_ptr<ConstantTokenNone> TheNoneToken;
    1291             : 
    1292             :   // Basic type instances.
    1293             :   Type VoidTy, LabelTy, HalfTy, FloatTy, DoubleTy, MetadataTy, TokenTy;
    1294             :   Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
    1295             :   IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty, Int128Ty;
    1296             :   
    1297             :   /// TypeAllocator - All dynamically allocated types are allocated from this.
    1298             :   /// They live forever until the context is torn down.
    1299             :   BumpPtrAllocator TypeAllocator;
    1300             :   
    1301             :   DenseMap<unsigned, IntegerType*> IntegerTypes;
    1302             : 
    1303             :   using FunctionTypeSet = DenseSet<FunctionType *, FunctionTypeKeyInfo>;
    1304             :   FunctionTypeSet FunctionTypes;
    1305             :   using StructTypeSet = DenseSet<StructType *, AnonStructTypeKeyInfo>;
    1306             :   StructTypeSet AnonStructTypes;
    1307             :   StringMap<StructType*> NamedStructTypes;
    1308             :   unsigned NamedStructTypesUniqueID = 0;
    1309             :     
    1310             :   DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes;
    1311             :   DenseMap<std::pair<Type *, unsigned>, VectorType*> VectorTypes;
    1312             :   DenseMap<Type*, PointerType*> PointerTypes;  // Pointers in AddrSpace = 0
    1313             :   DenseMap<std::pair<Type*, unsigned>, PointerType*> ASPointerTypes;
    1314             : 
    1315             :   /// ValueHandles - This map keeps track of all of the value handles that are
    1316             :   /// watching a Value*.  The Value::HasValueHandle bit is used to know
    1317             :   /// whether or not a value has an entry in this map.
    1318             :   using ValueHandlesTy = DenseMap<Value *, ValueHandleBase *>;
    1319             :   ValueHandlesTy ValueHandles;
    1320             :   
    1321             :   /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
    1322             :   StringMap<unsigned> CustomMDKindNames;
    1323             : 
    1324             :   /// Collection of per-instruction metadata used in this context.
    1325             :   DenseMap<const Instruction *, MDAttachmentMap> InstructionMetadata;
    1326             : 
    1327             :   /// Collection of per-GlobalObject metadata used in this context.
    1328             :   DenseMap<const GlobalObject *, MDGlobalAttachmentMap> GlobalObjectMetadata;
    1329             : 
    1330             :   /// Collection of per-GlobalObject sections used in this context.
    1331             :   DenseMap<const GlobalObject *, StringRef> GlobalObjectSections;
    1332             : 
    1333             :   /// Stable collection of section strings.
    1334             :   StringSet<> SectionStrings;
    1335             : 
    1336             :   /// DiscriminatorTable - This table maps file:line locations to an
    1337             :   /// integer representing the next DWARF path discriminator to assign to
    1338             :   /// instructions in different blocks at the same location.
    1339             :   DenseMap<std::pair<const char *, unsigned>, unsigned> DiscriminatorTable;
    1340             : 
    1341             :   int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx);
    1342             :   int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx);
    1343             : 
    1344             :   /// A set of interned tags for operand bundles.  The StringMap maps
    1345             :   /// bundle tags to their IDs.
    1346             :   ///
    1347             :   /// \see LLVMContext::getOperandBundleTagID
    1348             :   StringMap<uint32_t> BundleTagCache;
    1349             : 
    1350             :   StringMapEntry<uint32_t> *getOrInsertBundleTag(StringRef Tag);
    1351             :   void getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const;
    1352             :   uint32_t getOperandBundleTagID(StringRef Tag) const;
    1353             : 
    1354             :   /// A set of interned synchronization scopes.  The StringMap maps
    1355             :   /// synchronization scope names to their respective synchronization scope IDs.
    1356             :   StringMap<SyncScope::ID> SSC;
    1357             : 
    1358             :   /// getOrInsertSyncScopeID - Maps synchronization scope name to
    1359             :   /// synchronization scope ID.  Every synchronization scope registered with
    1360             :   /// LLVMContext has unique ID except pre-defined ones.
    1361             :   SyncScope::ID getOrInsertSyncScopeID(StringRef SSN);
    1362             : 
    1363             :   /// getSyncScopeNames - Populates client supplied SmallVector with
    1364             :   /// synchronization scope names registered with LLVMContext.  Synchronization
    1365             :   /// scope names are ordered by increasing synchronization scope IDs.
    1366             :   void getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const;
    1367             : 
    1368             :   /// Maintain the GC name for each function.
    1369             :   ///
    1370             :   /// This saves allocating an additional word in Function for programs which
    1371             :   /// do not use GC (i.e., most programs) at the cost of increased overhead for
    1372             :   /// clients which do use GC.
    1373             :   DenseMap<const Function*, std::string> GCNames;
    1374             : 
    1375             :   /// Flag to indicate if Value (other than GlobalValue) retains their name or
    1376             :   /// not.
    1377             :   bool DiscardValueNames = false;
    1378             : 
    1379             :   LLVMContextImpl(LLVMContext &C);
    1380             :   ~LLVMContextImpl();
    1381             : 
    1382             :   /// Destroy the ConstantArrays if they are not used.
    1383             :   void dropTriviallyDeadConstantArrays();
    1384             : 
    1385             :   mutable OptPassGate *OPG = nullptr;
    1386             : 
    1387             :   /// Access the object which can disable optional passes and individual
    1388             :   /// optimizations at compile time.
    1389             :   OptPassGate &getOptPassGate() const;
    1390             : 
    1391             :   /// Set the object which can disable optional passes and individual
    1392             :   /// optimizations at compile time.
    1393             :   ///
    1394             :   /// The lifetime of the object must be guaranteed to extend as long as the
    1395             :   /// LLVMContext is used by compilation.
    1396             :   void setOptPassGate(OptPassGate&);
    1397             : };
    1398             : 
    1399             : } // end namespace llvm
    1400             : 
    1401             : #endif // LLVM_LIB_IR_LLVMCONTEXTIMPL_H

Generated by: LCOV version 1.13