LCOV - code coverage report
Current view: top level - lib/IR - DebugInfoMetadata.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 281 292 96.2 %
Date: 2018-02-18 16:14:26 Functions: 54 54 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DebugInfoMetadata.cpp - Implement debug info metadata --------------===//
       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 implements the debug info Metadata classes.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/IR/DebugInfoMetadata.h"
      15             : #include "LLVMContextImpl.h"
      16             : #include "MetadataImpl.h"
      17             : #include "llvm/ADT/SmallPtrSet.h"
      18             : #include "llvm/ADT/StringSwitch.h"
      19             : #include "llvm/IR/DIBuilder.h"
      20             : #include "llvm/IR/Function.h"
      21             : #include "llvm/IR/Instructions.h"
      22             : 
      23             : using namespace llvm;
      24             : 
      25     1340154 : DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
      26     1340154 :                        unsigned Column, ArrayRef<Metadata *> MDs)
      27     2680308 :     : MDNode(C, DILocationKind, Storage, MDs) {
      28             :   assert((MDs.size() == 1 || MDs.size() == 2) &&
      29             :          "Expected a scope and optional inlined-at");
      30             : 
      31             :   // Set line and column.
      32             :   assert(Column < (1u << 16) && "Expected 16-bit column");
      33             : 
      34     1340154 :   SubclassData32 = Line;
      35     1340154 :   SubclassData16 = Column;
      36     1340154 : }
      37             : 
      38             : static void adjustColumn(unsigned &Column) {
      39             :   // Set to unknown on overflow.  We only have 16 bits to play with here.
      40     3306958 :   if (Column >= (1u << 16))
      41             :     Column = 0;
      42             : }
      43             : 
      44     3280237 : DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
      45             :                                 unsigned Column, Metadata *Scope,
      46             :                                 Metadata *InlinedAt, StorageType Storage,
      47             :                                 bool ShouldCreate) {
      48             :   // Fixup column.
      49             :   adjustColumn(Column);
      50             : 
      51     3280237 :   if (Storage == Uniqued) {
      52     1940083 :     if (auto *N =
      53     3124451 :             getUniqued(Context.pImpl->DILocations,
      54     6248902 :                        DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
      55             :       return N;
      56     1184368 :     if (!ShouldCreate)
      57             :       return nullptr;
      58             :   } else {
      59             :     assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
      60             :   }
      61             : 
      62             :   SmallVector<Metadata *, 2> Ops;
      63     1340154 :   Ops.push_back(Scope);
      64     1340154 :   if (InlinedAt)
      65      475368 :     Ops.push_back(InlinedAt);
      66     4020462 :   return storeImpl(new (Ops.size())
      67     1340154 :                        DILocation(Context, Storage, Line, Column, Ops),
      68     2680308 :                    Storage, Context.pImpl->DILocations);
      69             : }
      70             : 
      71             : const DILocation *
      72      102045 : DILocation::getMergedLocation(const DILocation *LocA, const DILocation *LocB,
      73             :                               const Instruction *ForInst) {
      74      102045 :   if (!LocA || !LocB)
      75             :     return nullptr;
      76             : 
      77       67894 :   if (LocA == LocB || !LocA->canDiscriminate(*LocB))
      78             :     return LocA;
      79             : 
      80             :   if (!dyn_cast_or_null<CallInst>(ForInst))
      81             :     return nullptr;
      82             : 
      83             :   SmallPtrSet<DILocation *, 5> InlinedLocationsA;
      84         140 :   for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
      85           0 :     InlinedLocationsA.insert(L);
      86             :   const DILocation *Result = LocB;
      87         140 :   for (DILocation *L = LocB->getInlinedAt(); L; L = L->getInlinedAt()) {
      88             :     Result = L;
      89           0 :     if (InlinedLocationsA.count(L))
      90             :       break;
      91             :   }
      92             :   return DILocation::get(Result->getContext(), 0, 0, Result->getScope(),
      93             :                          Result->getInlinedAt());
      94             : }
      95             : 
      96        3173 : DINode::DIFlags DINode::getFlag(StringRef Flag) {
      97             :   return StringSwitch<DIFlags>(Flag)
      98             : #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
      99             : #include "llvm/IR/DebugInfoFlags.def"
     100        3173 :       .Default(DINode::FlagZero);
     101             : }
     102             : 
     103        8095 : StringRef DINode::getFlagString(DIFlags Flag) {
     104        8095 :   switch (Flag) {
     105             : #define HANDLE_DI_FLAG(ID, NAME)                                               \
     106             :   case Flag##NAME:                                                             \
     107             :     return "DIFlag" #NAME;
     108             : #include "llvm/IR/DebugInfoFlags.def"
     109             :   }
     110           3 :   return "";
     111             : }
     112             : 
     113        6556 : DINode::DIFlags DINode::splitFlags(DIFlags Flags,
     114             :                                    SmallVectorImpl<DIFlags> &SplitFlags) {
     115             :   // Flags that are packed together need to be specially handled, so
     116             :   // that, for example, we emit "DIFlagPublic" and not
     117             :   // "DIFlagPrivate | DIFlagProtected".
     118        6556 :   if (DIFlags A = Flags & FlagAccessibility) {
     119         443 :     if (A == FlagPrivate)
     120          39 :       SplitFlags.push_back(FlagPrivate);
     121         404 :     else if (A == FlagProtected)
     122          57 :       SplitFlags.push_back(FlagProtected);
     123             :     else
     124         347 :       SplitFlags.push_back(FlagPublic);
     125             :     Flags &= ~A;
     126             :   }
     127        6556 :   if (DIFlags R = Flags & FlagPtrToMemberRep) {
     128          10 :     if (R == FlagSingleInheritance)
     129           6 :       SplitFlags.push_back(FlagSingleInheritance);
     130           4 :     else if (R == FlagMultipleInheritance)
     131           2 :       SplitFlags.push_back(FlagMultipleInheritance);
     132             :     else
     133           2 :       SplitFlags.push_back(FlagVirtualInheritance);
     134             :     Flags &= ~R;
     135             :   }
     136        6556 :   if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
     137             :     Flags &= ~FlagIndirectVirtualBase;
     138           1 :     SplitFlags.push_back(FlagIndirectVirtualBase);
     139             :   }
     140             : 
     141             : #define HANDLE_DI_FLAG(ID, NAME)                                               \
     142             :   if (DIFlags Bit = Flags & Flag##NAME) {                                      \
     143             :     SplitFlags.push_back(Bit);                                                 \
     144             :     Flags &= ~Bit;                                                             \
     145             :   }
     146             : #include "llvm/IR/DebugInfoFlags.def"
     147        6556 :   return Flags;
     148             : }
     149             : 
     150      133973 : DIScopeRef DIScope::getScope() const {
     151             :   if (auto *T = dyn_cast<DIType>(this))
     152             :     return T->getScope();
     153             : 
     154             :   if (auto *SP = dyn_cast<DISubprogram>(this))
     155             :     return SP->getScope();
     156             : 
     157             :   if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
     158        8027 :     return LB->getScope();
     159             : 
     160             :   if (auto *NS = dyn_cast<DINamespace>(this))
     161       71748 :     return NS->getScope();
     162             : 
     163             :   if (auto *M = dyn_cast<DIModule>(this))
     164          20 :     return M->getScope();
     165             : 
     166             :   assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
     167             :          "Unhandled type of scope.");
     168        4301 :   return nullptr;
     169             : }
     170             : 
     171       96881 : StringRef DIScope::getName() const {
     172             :   if (auto *T = dyn_cast<DIType>(this))
     173             :     return T->getName();
     174             :   if (auto *SP = dyn_cast<DISubprogram>(this))
     175             :     return SP->getName();
     176             :   if (auto *NS = dyn_cast<DINamespace>(this))
     177             :     return NS->getName();
     178             :   if (auto *M = dyn_cast<DIModule>(this))
     179             :     return M->getName();
     180             :   assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
     181             :           isa<DICompileUnit>(this)) &&
     182             :          "Unhandled type of scope.");
     183        4297 :   return "";
     184             : }
     185             : 
     186             : #ifndef NDEBUG
     187             : static bool isCanonical(const MDString *S) {
     188             :   return !S || !S->getString().empty();
     189             : }
     190             : #endif
     191             : 
     192          61 : GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
     193             :                                       MDString *Header,
     194             :                                       ArrayRef<Metadata *> DwarfOps,
     195             :                                       StorageType Storage, bool ShouldCreate) {
     196             :   unsigned Hash = 0;
     197          61 :   if (Storage == Uniqued) {
     198             :     GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
     199          62 :     if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
     200          13 :       return N;
     201          36 :     if (!ShouldCreate)
     202             :       return nullptr;
     203             :     Hash = Key.getHash();
     204             :   } else {
     205             :     assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
     206             :   }
     207             : 
     208             :   // Use a nullptr for empty headers.
     209             :   assert(isCanonical(Header) && "Expected canonical MDString");
     210          48 :   Metadata *PreOps[] = {Header};
     211          48 :   return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
     212          48 :                        Context, Storage, Hash, Tag, PreOps, DwarfOps),
     213          96 :                    Storage, Context.pImpl->GenericDINodes);
     214             : }
     215             : 
     216          15 : void GenericDINode::recalculateHash() {
     217             :   setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
     218          15 : }
     219             : 
     220             : #define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
     221             : #define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
     222             : #define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS)                                     \
     223             :   do {                                                                         \
     224             :     if (Storage == Uniqued) {                                                  \
     225             :       if (auto *N = getUniqued(Context.pImpl->CLASS##s,                        \
     226             :                                CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS))))         \
     227             :         return N;                                                              \
     228             :       if (!ShouldCreate)                                                       \
     229             :         return nullptr;                                                        \
     230             :     } else {                                                                   \
     231             :       assert(ShouldCreate &&                                                   \
     232             :              "Expected non-uniqued nodes to always be created");               \
     233             :     }                                                                          \
     234             :   } while (false)
     235             : #define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS)                                 \
     236             :   return storeImpl(new (array_lengthof(OPS))                                   \
     237             :                        CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS),        \
     238             :                    Storage, Context.pImpl->CLASS##s)
     239             : #define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS)                               \
     240             :   return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)),        \
     241             :                    Storage, Context.pImpl->CLASS##s)
     242             : #define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS)                   \
     243             :   return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS),     \
     244             :                    Storage, Context.pImpl->CLASS##s)
     245             : #define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS)                      \
     246             :   return storeImpl(new (NUM_OPS)                                               \
     247             :                        CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS),        \
     248             :                    Storage, Context.pImpl->CLASS##s)
     249             : 
     250        4117 : DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
     251             :                                 StorageType Storage, bool ShouldCreate) {
     252             :   auto *CountNode = ConstantAsMetadata::get(
     253        4117 :       ConstantInt::getSigned(Type::getInt64Ty(Context), Count));
     254        4117 :   return getImpl(Context, CountNode, Lo, Storage, ShouldCreate);
     255             : }
     256             : 
     257        4194 : DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
     258             :                                 int64_t Lo, StorageType Storage,
     259             :                                 bool ShouldCreate) {
     260       12580 :   DEFINE_GETIMPL_LOOKUP(DISubrange, (CountNode, Lo));
     261        3517 :   Metadata *Ops[] = { CountNode };
     262        7034 :   DEFINE_GETIMPL_STORE(DISubrange, (CountNode, Lo), Ops);
     263             : }
     264             : 
     265       19879 : DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
     266             :                                     bool IsUnsigned, MDString *Name,
     267             :                                     StorageType Storage, bool ShouldCreate) {
     268             :   assert(isCanonical(Name) && "Expected canonical MDString");
     269       59635 :   DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, IsUnsigned, Name));
     270       19868 :   Metadata *Ops[] = {Name};
     271       39736 :   DEFINE_GETIMPL_STORE(DIEnumerator, (Value, IsUnsigned), Ops);
     272             : }
     273             : 
     274       13480 : DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
     275             :                                   MDString *Name, uint64_t SizeInBits,
     276             :                                   uint32_t AlignInBits, unsigned Encoding,
     277             :                                   StorageType Storage, bool ShouldCreate) {
     278             :   assert(isCanonical(Name) && "Expected canonical MDString");
     279       40436 :   DEFINE_GETIMPL_LOOKUP(DIBasicType,
     280             :                         (Tag, Name, SizeInBits, AlignInBits, Encoding));
     281       13435 :   Metadata *Ops[] = {nullptr, nullptr, Name};
     282       26870 :   DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),
     283             :                        Ops);
     284             : }
     285             : 
     286      636967 : DIDerivedType *DIDerivedType::getImpl(
     287             :     LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
     288             :     unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
     289             :     uint32_t AlignInBits, uint64_t OffsetInBits,
     290             :     Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Metadata *ExtraData,
     291             :     StorageType Storage, bool ShouldCreate) {
     292             :   assert(isCanonical(Name) && "Expected canonical MDString");
     293     1500771 :   DEFINE_GETIMPL_LOOKUP(DIDerivedType,
     294             :                         (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
     295             :                          AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
     296             :                          ExtraData));
     297      471519 :   Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
     298     1414557 :   DEFINE_GETIMPL_STORE(
     299             :       DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
     300             :                       DWARFAddressSpace, Flags), Ops);
     301             : }
     302             : 
     303       48794 : DICompositeType *DICompositeType::getImpl(
     304             :     LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
     305             :     unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
     306             :     uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
     307             :     Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
     308             :     Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator,
     309             :     StorageType Storage, bool ShouldCreate) {
     310             :   assert(isCanonical(Name) && "Expected canonical MDString");
     311             : 
     312             :   // Keep this in sync with buildODRType.
     313       61832 :   DEFINE_GETIMPL_LOOKUP(
     314             :       DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
     315             :                         AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
     316             :                         VTableHolder, TemplateParams, Identifier, Discriminator));
     317             :   Metadata *Ops[] = {File,     Scope,        Name,           BaseType,
     318             :                      Elements, VTableHolder, TemplateParams, Identifier,
     319       48651 :                      Discriminator};
     320       97302 :   DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,
     321             :                                          AlignInBits, OffsetInBits, Flags),
     322             :                        Ops);
     323             : }
     324             : 
     325         587 : DICompositeType *DICompositeType::buildODRType(
     326             :     LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
     327             :     Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
     328             :     uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
     329             :     DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
     330             :     Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
     331             :   assert(!Identifier.getString().empty() && "Expected valid identifier");
     332         587 :   if (!Context.isODRUniquingDebugTypes())
     333             :     return nullptr;
     334         308 :   auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
     335         154 :   if (!CT)
     336         116 :     return CT = DICompositeType::getDistinct(
     337             :                Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
     338             :                AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
     339         116 :                VTableHolder, TemplateParams, &Identifier, Discriminator);
     340             : 
     341             :   // Only mutate CT if it's a forward declaration and the new operands aren't.
     342             :   assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?");
     343          49 :   if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
     344             :     return CT;
     345             : 
     346             :   // Mutate CT in place.  Keep this in sync with getImpl.
     347             :   CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
     348             :              Flags);
     349             :   Metadata *Ops[] = {File,     Scope,        Name,           BaseType,
     350             :                      Elements, VTableHolder, TemplateParams, &Identifier,
     351           4 :                      Discriminator};
     352             :   assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&
     353             :          "Mismatched number of operands");
     354          76 :   for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
     355          72 :     if (Ops[I] != CT->getOperand(I))
     356           9 :       CT->setOperand(I, Ops[I]);
     357           4 :   return CT;
     358             : }
     359             : 
     360           4 : DICompositeType *DICompositeType::getODRType(
     361             :     LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
     362             :     Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
     363             :     uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
     364             :     DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
     365             :     Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
     366             :   assert(!Identifier.getString().empty() && "Expected valid identifier");
     367           4 :   if (!Context.isODRUniquingDebugTypes())
     368             :     return nullptr;
     369           6 :   auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
     370           3 :   if (!CT)
     371           1 :     CT = DICompositeType::getDistinct(
     372             :         Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
     373             :         AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
     374             :         TemplateParams, &Identifier, Discriminator);
     375           3 :   return CT;
     376             : }
     377             : 
     378           5 : DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
     379             :                                                      MDString &Identifier) {
     380             :   assert(!Identifier.getString().empty() && "Expected valid identifier");
     381           5 :   if (!Context.isODRUniquingDebugTypes())
     382             :     return nullptr;
     383           8 :   return Context.pImpl->DITypeMap->lookup(&Identifier);
     384             : }
     385             : 
     386      434280 : DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
     387             :                                             uint8_t CC, Metadata *TypeArray,
     388             :                                             StorageType Storage,
     389             :                                             bool ShouldCreate) {
     390     1302826 :   DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray));
     391      325141 :   Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
     392      650282 :   DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops);
     393             : }
     394             : 
     395             : // FIXME: Implement this string-enum correspondence with a .def file and macros,
     396             : // so that the association is explicit rather than implied.
     397             : static const char *ChecksumKindName[DIFile::CSK_Last] = {
     398             :   "CSK_MD5",
     399             :   "CSK_SHA1"
     400             : };
     401             : 
     402          51 : StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
     403             :   assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind");
     404             :   // The first space was originally the CSK_None variant, which is now
     405             :   // obsolete, but the space is still reserved in ChecksumKind, so we account
     406             :   // for it here.
     407         102 :   return ChecksumKindName[CSKind - 1];
     408             : }
     409             : 
     410         112 : Optional<DIFile::ChecksumKind> DIFile::getChecksumKind(StringRef CSKindStr) {
     411             :   return StringSwitch<Optional<DIFile::ChecksumKind>>(CSKindStr)
     412         112 :       .Case("CSK_MD5", DIFile::CSK_MD5)
     413         112 :       .Case("CSK_SHA1", DIFile::CSK_SHA1)
     414         224 :       .Default(None);
     415             : }
     416             : 
     417       58006 : DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
     418             :                         MDString *Directory,
     419             :                         Optional<DIFile::ChecksumInfo<MDString *>> CS,
     420             :                         StorageType Storage, bool ShouldCreate) {
     421             :   assert(isCanonical(Filename) && "Expected canonical MDString");
     422             :   assert(isCanonical(Directory) && "Expected canonical MDString");
     423             :   assert((!CS || isCanonical(CS->Value)) && "Expected canonical MDString");
     424      173946 :   DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS));
     425       31866 :   Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr};
     426       63732 :   DEFINE_GETIMPL_STORE(DIFile, (CS), Ops);
     427             : }
     428             : 
     429        4780 : DICompileUnit *DICompileUnit::getImpl(
     430             :     LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
     431             :     MDString *Producer, bool IsOptimized, MDString *Flags,
     432             :     unsigned RuntimeVersion, MDString *SplitDebugFilename,
     433             :     unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
     434             :     Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
     435             :     uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
     436             :     bool GnuPubnames, StorageType Storage, bool ShouldCreate) {
     437             :   assert(Storage != Uniqued && "Cannot unique DICompileUnit");
     438             :   assert(isCanonical(Producer) && "Expected canonical MDString");
     439             :   assert(isCanonical(Flags) && "Expected canonical MDString");
     440             :   assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString");
     441             : 
     442             :   Metadata *Ops[] = {
     443             :       File,      Producer,      Flags,           SplitDebugFilename,
     444             :       EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
     445        4780 :       Macros};
     446             :   return storeImpl(new (array_lengthof(Ops)) DICompileUnit(
     447             :                        Context, Storage, SourceLanguage, IsOptimized,
     448             :                        RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
     449        4780 :                        DebugInfoForProfiling, GnuPubnames, Ops),
     450        4780 :                    Storage);
     451             : }
     452             : 
     453             : Optional<DICompileUnit::DebugEmissionKind>
     454        1405 : DICompileUnit::getEmissionKind(StringRef Str) {
     455             :   return StringSwitch<Optional<DebugEmissionKind>>(Str)
     456        1405 :       .Case("NoDebug", NoDebug)
     457        1405 :       .Case("FullDebug", FullDebug)
     458        1405 :       .Case("LineTablesOnly", LineTablesOnly)
     459        2810 :       .Default(None);
     460             : }
     461             : 
     462        1013 : const char *DICompileUnit::EmissionKindString(DebugEmissionKind EK) {
     463        1013 :   switch (EK) {
     464             :   case NoDebug:        return "NoDebug";
     465         710 :   case FullDebug:      return "FullDebug";
     466         193 :   case LineTablesOnly: return "LineTablesOnly";
     467             :   }
     468           0 :   return nullptr;
     469             : }
     470             : 
     471     1468332 : DISubprogram *DILocalScope::getSubprogram() const {
     472             :   if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
     473       89763 :     return Block->getScope()->getSubprogram();
     474             :   return const_cast<DISubprogram *>(cast<DISubprogram>(this));
     475             : }
     476             : 
     477     3420234 : DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const {
     478             :   if (auto *File = dyn_cast<DILexicalBlockFile>(this))
     479         361 :     return File->getScope()->getNonLexicalBlockFileScope();
     480             :   return const_cast<DILocalScope *>(this);
     481             : }
     482             : 
     483      362529 : DISubprogram *DISubprogram::getImpl(
     484             :     LLVMContext &Context, Metadata *Scope, MDString *Name,
     485             :     MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
     486             :     bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
     487             :     Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
     488             :     int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
     489             :     Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
     490             :     Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate) {
     491             :   assert(isCanonical(Name) && "Expected canonical MDString");
     492             :   assert(isCanonical(LinkageName) && "Expected canonical MDString");
     493      776029 :   DEFINE_GETIMPL_LOOKUP(
     494             :       DISubprogram, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
     495             :                      IsDefinition, ScopeLine, ContainingType, Virtuality,
     496             :                      VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,
     497             :                      TemplateParams, Declaration, Variables, ThrownTypes));
     498             :   SmallVector<Metadata *, 11> Ops = {
     499             :       File,        Scope,     Name,           LinkageName,    Type,       Unit,
     500      725042 :       Declaration, Variables, ContainingType, TemplateParams, ThrownTypes};
     501      362521 :   if (!ThrownTypes) {
     502             :     Ops.pop_back();
     503      362486 :     if (!TemplateParams) {
     504             :       Ops.pop_back();
     505      343481 :       if (!ContainingType)
     506             :         Ops.pop_back();
     507             :     }
     508             :   }
     509     1087563 :   DEFINE_GETIMPL_STORE_N(DISubprogram,
     510             :                          (Line, ScopeLine, Virtuality, VirtualIndex,
     511             :                           ThisAdjustment, Flags, IsLocalToUnit, IsDefinition,
     512             :                           IsOptimized),
     513             :                          Ops, Ops.size());
     514             : }
     515             : 
     516       20231 : bool DISubprogram::describes(const Function *F) const {
     517             :   assert(F && "Invalid function");
     518       20231 :   if (F->getSubprogram() == this)
     519             :     return true;
     520             :   StringRef Name = getLinkageName();
     521       10873 :   if (Name.empty())
     522             :     Name = getName();
     523       10873 :   return F->getName() == Name;
     524             : }
     525             : 
     526       26721 : DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
     527             :                                         Metadata *File, unsigned Line,
     528             :                                         unsigned Column, StorageType Storage,
     529             :                                         bool ShouldCreate) {
     530             :   // Fixup column.
     531             :   adjustColumn(Column);
     532             : 
     533             :   assert(Scope && "Expected scope");
     534       26803 :   DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column));
     535       26717 :   Metadata *Ops[] = {File, Scope};
     536       53434 :   DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops);
     537             : }
     538             : 
     539         891 : DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
     540             :                                                 Metadata *Scope, Metadata *File,
     541             :                                                 unsigned Discriminator,
     542             :                                                 StorageType Storage,
     543             :                                                 bool ShouldCreate) {
     544             :   assert(Scope && "Expected scope");
     545        2671 :   DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator));
     546         437 :   Metadata *Ops[] = {File, Scope};
     547         874 :   DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops);
     548             : }
     549             : 
     550       20410 : DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
     551             :                                   MDString *Name, bool ExportSymbols,
     552             :                                   StorageType Storage, bool ShouldCreate) {
     553             :   assert(isCanonical(Name) && "Expected canonical MDString");
     554       61228 :   DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols));
     555             :   // The nullptr is for DIScope's File operand. This should be refactored.
     556        3865 :   Metadata *Ops[] = {nullptr, Scope, Name};
     557        7730 :   DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops);
     558             : }
     559             : 
     560         194 : DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
     561             :                             MDString *Name, MDString *ConfigurationMacros,
     562             :                             MDString *IncludePath, MDString *ISysRoot,
     563             :                             StorageType Storage, bool ShouldCreate) {
     564             :   assert(isCanonical(Name) && "Expected canonical MDString");
     565         580 :   DEFINE_GETIMPL_LOOKUP(
     566             :       DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot));
     567         187 :   Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot};
     568         374 :   DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops);
     569             : }
     570             : 
     571       60027 : DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
     572             :                                                           MDString *Name,
     573             :                                                           Metadata *Type,
     574             :                                                           StorageType Storage,
     575             :                                                           bool ShouldCreate) {
     576             :   assert(isCanonical(Name) && "Expected canonical MDString");
     577      180077 :   DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type));
     578       22247 :   Metadata *Ops[] = {Name, Type};
     579       44494 :   DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops);
     580             : }
     581             : 
     582       24513 : DITemplateValueParameter *DITemplateValueParameter::getImpl(
     583             :     LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
     584             :     Metadata *Value, StorageType Storage, bool ShouldCreate) {
     585             :   assert(isCanonical(Name) && "Expected canonical MDString");
     586       73535 :   DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter, (Tag, Name, Type, Value));
     587        7774 :   Metadata *Ops[] = {Name, Type, Value};
     588       15548 :   DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops);
     589             : }
     590             : 
     591             : DIGlobalVariable *
     592        4788 : DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
     593             :                           MDString *LinkageName, Metadata *File, unsigned Line,
     594             :                           Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
     595             :                           Metadata *StaticDataMemberDeclaration,
     596             :                           uint32_t AlignInBits, StorageType Storage,
     597             :                           bool ShouldCreate) {
     598             :   assert(isCanonical(Name) && "Expected canonical MDString");
     599             :   assert(isCanonical(LinkageName) && "Expected canonical MDString");
     600        5892 :   DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,
     601             :                         (Scope, Name, LinkageName, File, Line, Type,
     602             :                          IsLocalToUnit, IsDefinition,
     603             :                          StaticDataMemberDeclaration, AlignInBits));
     604             :   Metadata *Ops[] = {
     605        4787 :       Scope, Name, File, Type, Name, LinkageName, StaticDataMemberDeclaration};
     606        9574 :   DEFINE_GETIMPL_STORE(DIGlobalVariable,
     607             :                        (Line, IsLocalToUnit, IsDefinition, AlignInBits),
     608             :                        Ops);
     609             : }
     610             : 
     611       78708 : DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
     612             :                                           MDString *Name, Metadata *File,
     613             :                                           unsigned Line, Metadata *Type,
     614             :                                           unsigned Arg, DIFlags Flags,
     615             :                                           uint32_t AlignInBits,
     616             :                                           StorageType Storage,
     617             :                                           bool ShouldCreate) {
     618             :   // 64K ought to be enough for any frontend.
     619             :   assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
     620             : 
     621             :   assert(Scope && "Expected scope");
     622             :   assert(isCanonical(Name) && "Expected canonical MDString");
     623      236076 :   DEFINE_GETIMPL_LOOKUP(DILocalVariable,
     624             :                         (Scope, Name, File, Line, Type, Arg, Flags,
     625             :                          AlignInBits));
     626       78613 :   Metadata *Ops[] = {Scope, Name, File, Type};
     627      157226 :   DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops);
     628             : }
     629             : 
     630        9847 : Optional<uint64_t> DIVariable::getSizeInBits() const {
     631             :   // This is used by the Verifier so be mindful of broken types.
     632             :   const Metadata *RawType = getRawType();
     633       17951 :   while (RawType) {
     634             :     // Try to get the size directly.
     635             :     if (auto *T = dyn_cast<DIType>(RawType))
     636       13899 :       if (uint64_t Size = T->getSizeInBits())
     637             :         return Size;
     638             : 
     639        4052 :     if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
     640             :       // Look at the base type.
     641             :       RawType = DT->getRawBaseType();
     642             :       continue;
     643             :     }
     644             : 
     645             :     // Missing type or size.
     646             :     break;
     647             :   }
     648             : 
     649             :   // Fail gracefully.
     650             :   return None;
     651             : }
     652             : 
     653       90819 : DIExpression *DIExpression::getImpl(LLVMContext &Context,
     654             :                                     ArrayRef<uint64_t> Elements,
     655             :                                     StorageType Storage, bool ShouldCreate) {
     656      272455 :   DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements));
     657        4466 :   DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements));
     658             : }
     659             : 
     660      218137 : unsigned DIExpression::ExprOperand::getSize() const {
     661      218137 :   switch (getOp()) {
     662             :   case dwarf::DW_OP_LLVM_fragment:
     663             :     return 3;
     664      178629 :   case dwarf::DW_OP_constu:
     665             :   case dwarf::DW_OP_plus_uconst:
     666      178629 :     return 2;
     667       37255 :   default:
     668       37255 :     return 1;
     669             :   }
     670             : }
     671             : 
     672       26003 : bool DIExpression::isValid() const {
     673       54788 :   for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
     674             :     // Check that there's space for the operand.
     675        3644 :     if (I->get() + I->getSize() > E->get())
     676         862 :       return false;
     677             : 
     678             :     // Check that the operand is valid.
     679        3641 :     switch (I->getOp()) {
     680             :     default:
     681             :       return false;
     682             :     case dwarf::DW_OP_LLVM_fragment:
     683             :       // A fragment operator must appear at the end.
     684         852 :       return I->get() + I->getSize() == E->get();
     685             :     case dwarf::DW_OP_stack_value: {
     686             :       // Must be the last one or followed by a DW_OP_LLVM_fragment.
     687         330 :       if (I->get() + I->getSize() == E->get())
     688             :         break;
     689          71 :       auto J = I;
     690          71 :       if ((++J)->getOp() != dwarf::DW_OP_LLVM_fragment)
     691           0 :         return false;
     692             :       break;
     693             :     }
     694             :     case dwarf::DW_OP_swap: {
     695             :       // Must be more than one implicit element on the stack.
     696             : 
     697             :       // FIXME: A better way to implement this would be to add a local variable
     698             :       // that keeps track of the stack depth and introduce something like a
     699             :       // DW_LLVM_OP_implicit_location as a placeholder for the location this
     700             :       // DIExpression is attached to, or else pass the number of implicit stack
     701             :       // elements into isValid.
     702         224 :       if (getNumElements() == 1)
     703             :         return false;
     704             :       break;
     705             :     }
     706             :     case dwarf::DW_OP_constu:
     707             :     case dwarf::DW_OP_plus_uconst:
     708             :     case dwarf::DW_OP_plus:
     709             :     case dwarf::DW_OP_minus:
     710             :     case dwarf::DW_OP_mul:
     711             :     case dwarf::DW_OP_div:
     712             :     case dwarf::DW_OP_mod:
     713             :     case dwarf::DW_OP_or:
     714             :     case dwarf::DW_OP_and:
     715             :     case dwarf::DW_OP_xor:
     716             :     case dwarf::DW_OP_shl:
     717             :     case dwarf::DW_OP_shr:
     718             :     case dwarf::DW_OP_shra:
     719             :     case dwarf::DW_OP_deref:
     720             :     case dwarf::DW_OP_xderef:
     721             :       break;
     722             :     }
     723             :   }
     724       25141 :   return true;
     725             : }
     726             : 
     727             : Optional<DIExpression::FragmentInfo>
     728      293705 : DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) {
     729      712541 :   for (auto I = Start; I != End; ++I)
     730      129038 :     if (I->getOp() == dwarf::DW_OP_LLVM_fragment) {
     731             :       DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)};
     732             :       return Info;
     733             :     }
     734             :   return None;
     735             : }
     736             : 
     737        7867 : void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
     738             :                                 int64_t Offset) {
     739        7867 :   if (Offset > 0) {
     740        3461 :     Ops.push_back(dwarf::DW_OP_plus_uconst);
     741        3461 :     Ops.push_back(Offset);
     742        4406 :   } else if (Offset < 0) {
     743         211 :     Ops.push_back(dwarf::DW_OP_constu);
     744         211 :     Ops.push_back(-Offset);
     745         211 :     Ops.push_back(dwarf::DW_OP_minus);
     746             :   }
     747        7867 : }
     748             : 
     749         141 : bool DIExpression::extractIfOffset(int64_t &Offset) const {
     750         141 :   if (getNumElements() == 0) {
     751         135 :     Offset = 0;
     752         135 :     return true;
     753             :   }
     754             : 
     755           6 :   if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) {
     756           6 :     Offset = Elements[1];
     757           6 :     return true;
     758             :   }
     759             : 
     760           0 :   if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) {
     761           0 :     if (Elements[2] == dwarf::DW_OP_plus) {
     762           0 :       Offset = Elements[1];
     763           0 :       return true;
     764             :     }
     765           0 :     if (Elements[2] == dwarf::DW_OP_minus) {
     766           0 :       Offset = -Elements[1];
     767           0 :       return true;
     768             :     }
     769             :   }
     770             : 
     771             :   return false;
     772             : }
     773             : 
     774        4178 : DIExpression *DIExpression::prepend(const DIExpression *Expr, bool DerefBefore,
     775             :                                     int64_t Offset, bool DerefAfter,
     776             :                                     bool StackValue) {
     777             :   SmallVector<uint64_t, 8> Ops;
     778        4178 :   if (DerefBefore)
     779         492 :     Ops.push_back(dwarf::DW_OP_deref);
     780             :   
     781        4178 :   appendOffset(Ops, Offset);
     782        4178 :   if (DerefAfter)
     783           1 :     Ops.push_back(dwarf::DW_OP_deref);
     784             : 
     785        8356 :   return doPrepend(Expr, Ops, StackValue);
     786             : }
     787             : 
     788        8055 : DIExpression *DIExpression::doPrepend(const DIExpression *Expr,
     789             :                                       SmallVectorImpl<uint64_t> &Ops,
     790             :                                       bool StackValue) {
     791        8055 :   if (Expr)
     792       18944 :     for (auto Op : Expr->expr_ops()) {
     793             :       // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
     794        2834 :       if (StackValue) {
     795        2362 :         if (Op.getOp() == dwarf::DW_OP_stack_value)
     796             :           StackValue = false;
     797        1152 :         else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
     798           2 :           Ops.push_back(dwarf::DW_OP_stack_value);
     799             :           StackValue = false;
     800             :         }
     801             :       }
     802        5668 :       Ops.push_back(Op.getOp());
     803        4338 :       for (unsigned I = 0; I < Op.getNumArgs(); ++I)
     804         752 :         Ops.push_back(Op.getArg(I));
     805             :     }
     806        8055 :   if (StackValue)
     807        3711 :     Ops.push_back(dwarf::DW_OP_stack_value);
     808        8055 :   return DIExpression::get(Expr->getContext(), Ops);
     809             : }
     810             : 
     811         159 : Optional<DIExpression *> DIExpression::createFragmentExpression(
     812             :     const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) {
     813             :   SmallVector<uint64_t, 8> Ops;
     814             :   // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
     815         159 :   if (Expr) {
     816         338 :     for (auto Op : Expr->expr_ops()) {
     817          24 :       switch (Op.getOp()) {
     818             :       default: break;
     819             :       case dwarf::DW_OP_plus:
     820             :       case dwarf::DW_OP_minus:
     821             :         // We can't safely split arithmetic into multiple fragments because we
     822             :         // can't express carry-over between fragments.
     823             :         //
     824             :         // FIXME: We *could* preserve the lowest fragment of a constant offset
     825             :         // operation if the offset fits into SizeInBits.
     826           4 :         return None;
     827             :       case dwarf::DW_OP_LLVM_fragment: {
     828             :         // Make the new offset point into the existing fragment.
     829             :         uint64_t FragmentOffsetInBits = Op.getArg(0);
     830             :         // Op.getArg(0) is FragmentOffsetInBits.
     831             :         // Op.getArg(1) is FragmentSizeInBits.
     832             :         assert((OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) &&
     833             :                "new fragment outside of original fragment");
     834          16 :         OffsetInBits += FragmentOffsetInBits;
     835          16 :         continue;
     836             :       }
     837             :       }
     838           4 :       Ops.push_back(Op.getOp());
     839          12 :       for (unsigned I = 0; I < Op.getNumArgs(); ++I)
     840           4 :         Ops.push_back(Op.getArg(I));
     841             :     }
     842             :   }
     843         155 :   Ops.push_back(dwarf::DW_OP_LLVM_fragment);
     844         155 :   Ops.push_back(OffsetInBits);
     845         155 :   Ops.push_back(SizeInBits);
     846             :   return DIExpression::get(Expr->getContext(), Ops);
     847             : }
     848             : 
     849        7446 : bool DIExpression::isConstant() const {
     850             :   // Recognize DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment Len Ofs)?.
     851        7446 :   if (getNumElements() != 3 && getNumElements() != 6)
     852             :     return false;
     853          43 :   if (getElement(0) != dwarf::DW_OP_constu ||
     854             :       getElement(2) != dwarf::DW_OP_stack_value)
     855             :     return false;
     856          31 :   if (getNumElements() == 6 && getElement(3) != dwarf::DW_OP_LLVM_fragment)
     857             :     return false;
     858             :   return true;
     859             : }
     860             : 
     861             : DIGlobalVariableExpression *
     862        4510 : DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
     863             :                                     Metadata *Expression, StorageType Storage,
     864             :                                     bool ShouldCreate) {
     865       13348 :   DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression, (Variable, Expression));
     866        4508 :   Metadata *Ops[] = {Variable, Expression};
     867        9016 :   DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression, Ops);
     868             : }
     869             : 
     870         122 : DIObjCProperty *DIObjCProperty::getImpl(
     871             :     LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
     872             :     MDString *GetterName, MDString *SetterName, unsigned Attributes,
     873             :     Metadata *Type, StorageType Storage, bool ShouldCreate) {
     874             :   assert(isCanonical(Name) && "Expected canonical MDString");
     875             :   assert(isCanonical(GetterName) && "Expected canonical MDString");
     876             :   assert(isCanonical(SetterName) && "Expected canonical MDString");
     877         364 :   DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,
     878             :                                          SetterName, Attributes, Type));
     879          90 :   Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
     880         180 :   DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
     881             : }
     882             : 
     883      107743 : DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
     884             :                                             Metadata *Scope, Metadata *Entity,
     885             :                                             Metadata *File, unsigned Line,
     886             :                                             MDString *Name, StorageType Storage,
     887             :                                             bool ShouldCreate) {
     888             :   assert(isCanonical(Name) && "Expected canonical MDString");
     889      323227 :   DEFINE_GETIMPL_LOOKUP(DIImportedEntity,
     890             :                         (Tag, Scope, Entity, File, Line, Name));
     891      107737 :   Metadata *Ops[] = {Scope, Entity, Name, File};
     892      215474 :   DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
     893             : }
     894             : 
     895        1106 : DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType,
     896             :                           unsigned Line, MDString *Name, MDString *Value,
     897             :                           StorageType Storage, bool ShouldCreate) {
     898             :   assert(isCanonical(Name) && "Expected canonical MDString");
     899        3318 :   DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value));
     900        1097 :   Metadata *Ops[] = { Name, Value };
     901        2194 :   DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops);
     902             : }
     903             : 
     904          84 : DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
     905             :                                   unsigned Line, Metadata *File,
     906             :                                   Metadata *Elements, StorageType Storage,
     907             :                                   bool ShouldCreate) {
     908         216 :   DEFINE_GETIMPL_LOOKUP(DIMacroFile,
     909             :                         (MIType, Line, File, Elements));
     910          82 :   Metadata *Ops[] = { File, Elements };
     911         164 :   DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops);
     912             : }

Generated by: LCOV version 1.13