LLVM  8.0.0svn
DebugInfoMetadata.cpp
Go to the documentation of this file.
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 
15 #include "LLVMContextImpl.h"
16 #include "MetadataImpl.h"
17 #include "llvm/ADT/SmallSet.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 DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
26  unsigned Column, ArrayRef<Metadata *> MDs,
27  bool ImplicitCode)
28  : MDNode(C, DILocationKind, Storage, MDs) {
29  assert((MDs.size() == 1 || MDs.size() == 2) &&
30  "Expected a scope and optional inlined-at");
31 
32  // Set line and column.
33  assert(Column < (1u << 16) && "Expected 16-bit column");
34 
35  SubclassData32 = Line;
36  SubclassData16 = Column;
37 
38  setImplicitCode(ImplicitCode);
39 }
40 
41 static void adjustColumn(unsigned &Column) {
42  // Set to unknown on overflow. We only have 16 bits to play with here.
43  if (Column >= (1u << 16))
44  Column = 0;
45 }
46 
48  unsigned Column, Metadata *Scope,
49  Metadata *InlinedAt, bool ImplicitCode,
50  StorageType Storage, bool ShouldCreate) {
51  // Fixup column.
52  adjustColumn(Column);
53 
54  if (Storage == Uniqued) {
55  if (auto *N = getUniqued(Context.pImpl->DILocations,
56  DILocationInfo::KeyTy(Line, Column, Scope,
57  InlinedAt, ImplicitCode)))
58  return N;
59  if (!ShouldCreate)
60  return nullptr;
61  } else {
62  assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
63  }
64 
66  Ops.push_back(Scope);
67  if (InlinedAt)
68  Ops.push_back(InlinedAt);
69  return storeImpl(new (Ops.size()) DILocation(Context, Storage, Line, Column,
70  Ops, ImplicitCode),
71  Storage, Context.pImpl->DILocations);
72 }
73 
75  const DILocation *LocB) {
76  if (!LocA || !LocB)
77  return nullptr;
78 
79  if (LocA == LocB)
80  return LocA;
81 
82  SmallPtrSet<DILocation *, 5> InlinedLocationsA;
83  for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
84  InlinedLocationsA.insert(L);
86  DIScope *S = LocA->getScope();
87  DILocation *L = LocA->getInlinedAt();
88  while (S) {
89  Locations.insert(std::make_pair(S, L));
90  S = S->getScope().resolve();
91  if (!S && L) {
92  S = L->getScope();
93  L = L->getInlinedAt();
94  }
95  }
96  const DILocation *Result = LocB;
97  S = LocB->getScope();
98  L = LocB->getInlinedAt();
99  while (S) {
100  if (Locations.count(std::make_pair(S, L)))
101  break;
102  S = S->getScope().resolve();
103  if (!S && L) {
104  S = L->getScope();
105  L = L->getInlinedAt();
106  }
107  }
108 
109  // If the two locations are irreconsilable, just pick one. This is misleading,
110  // but on the other hand, it's a "line 0" location.
111  if (!S || !isa<DILocalScope>(S))
112  S = LocA->getScope();
113  return DILocation::get(Result->getContext(), 0, 0, S, L);
114 }
115 
118 #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
119 #include "llvm/IR/DebugInfoFlags.def"
120  .Default(DINode::FlagZero);
121 }
122 
124  switch (Flag) {
125 #define HANDLE_DI_FLAG(ID, NAME) \
126  case Flag##NAME: \
127  return "DIFlag" #NAME;
128 #include "llvm/IR/DebugInfoFlags.def"
129  }
130  return "";
131 }
132 
134  SmallVectorImpl<DIFlags> &SplitFlags) {
135  // Flags that are packed together need to be specially handled, so
136  // that, for example, we emit "DIFlagPublic" and not
137  // "DIFlagPrivate | DIFlagProtected".
138  if (DIFlags A = Flags & FlagAccessibility) {
139  if (A == FlagPrivate)
140  SplitFlags.push_back(FlagPrivate);
141  else if (A == FlagProtected)
142  SplitFlags.push_back(FlagProtected);
143  else
144  SplitFlags.push_back(FlagPublic);
145  Flags &= ~A;
146  }
147  if (DIFlags R = Flags & FlagPtrToMemberRep) {
148  if (R == FlagSingleInheritance)
149  SplitFlags.push_back(FlagSingleInheritance);
150  else if (R == FlagMultipleInheritance)
151  SplitFlags.push_back(FlagMultipleInheritance);
152  else
153  SplitFlags.push_back(FlagVirtualInheritance);
154  Flags &= ~R;
155  }
156  if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
157  Flags &= ~FlagIndirectVirtualBase;
158  SplitFlags.push_back(FlagIndirectVirtualBase);
159  }
160 
161 #define HANDLE_DI_FLAG(ID, NAME) \
162  if (DIFlags Bit = Flags & Flag##NAME) { \
163  SplitFlags.push_back(Bit); \
164  Flags &= ~Bit; \
165  }
166 #include "llvm/IR/DebugInfoFlags.def"
167  return Flags;
168 }
169 
171  if (auto *T = dyn_cast<DIType>(this))
172  return T->getScope();
173 
174  if (auto *SP = dyn_cast<DISubprogram>(this))
175  return SP->getScope();
176 
177  if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
178  return LB->getScope();
179 
180  if (auto *NS = dyn_cast<DINamespace>(this))
181  return NS->getScope();
182 
183  if (auto *M = dyn_cast<DIModule>(this))
184  return M->getScope();
185 
186  assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
187  "Unhandled type of scope.");
188  return nullptr;
189 }
190 
192  if (auto *T = dyn_cast<DIType>(this))
193  return T->getName();
194  if (auto *SP = dyn_cast<DISubprogram>(this))
195  return SP->getName();
196  if (auto *NS = dyn_cast<DINamespace>(this))
197  return NS->getName();
198  if (auto *M = dyn_cast<DIModule>(this))
199  return M->getName();
200  assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
201  isa<DICompileUnit>(this)) &&
202  "Unhandled type of scope.");
203  return "";
204 }
205 
206 #ifndef NDEBUG
207 static bool isCanonical(const MDString *S) {
208  return !S || !S->getString().empty();
209 }
210 #endif
211 
212 GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
213  MDString *Header,
214  ArrayRef<Metadata *> DwarfOps,
215  StorageType Storage, bool ShouldCreate) {
216  unsigned Hash = 0;
217  if (Storage == Uniqued) {
218  GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
219  if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
220  return N;
221  if (!ShouldCreate)
222  return nullptr;
223  Hash = Key.getHash();
224  } else {
225  assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
226  }
227 
228  // Use a nullptr for empty headers.
229  assert(isCanonical(Header) && "Expected canonical MDString");
230  Metadata *PreOps[] = {Header};
231  return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
232  Context, Storage, Hash, Tag, PreOps, DwarfOps),
233  Storage, Context.pImpl->GenericDINodes);
234 }
235 
236 void GenericDINode::recalculateHash() {
237  setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
238 }
239 
240 #define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
241 #define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
242 #define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
243  do { \
244  if (Storage == Uniqued) { \
245  if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
246  CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
247  return N; \
248  if (!ShouldCreate) \
249  return nullptr; \
250  } else { \
251  assert(ShouldCreate && \
252  "Expected non-uniqued nodes to always be created"); \
253  } \
254  } while (false)
255 #define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
256  return storeImpl(new (array_lengthof(OPS)) \
257  CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
258  Storage, Context.pImpl->CLASS##s)
259 #define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
260  return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
261  Storage, Context.pImpl->CLASS##s)
262 #define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
263  return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
264  Storage, Context.pImpl->CLASS##s)
265 #define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS) \
266  return storeImpl(new (NUM_OPS) \
267  CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
268  Storage, Context.pImpl->CLASS##s)
269 
270 DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
271  StorageType Storage, bool ShouldCreate) {
272  auto *CountNode = ConstantAsMetadata::get(
273  ConstantInt::getSigned(Type::getInt64Ty(Context), Count));
274  return getImpl(Context, CountNode, Lo, Storage, ShouldCreate);
275 }
276 
277 DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
278  int64_t Lo, StorageType Storage,
279  bool ShouldCreate) {
280  DEFINE_GETIMPL_LOOKUP(DISubrange, (CountNode, Lo));
281  Metadata *Ops[] = { CountNode };
282  DEFINE_GETIMPL_STORE(DISubrange, (CountNode, Lo), Ops);
283 }
284 
285 DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
286  bool IsUnsigned, MDString *Name,
287  StorageType Storage, bool ShouldCreate) {
288  assert(isCanonical(Name) && "Expected canonical MDString");
289  DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, IsUnsigned, Name));
290  Metadata *Ops[] = {Name};
291  DEFINE_GETIMPL_STORE(DIEnumerator, (Value, IsUnsigned), Ops);
292 }
293 
294 DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
295  MDString *Name, uint64_t SizeInBits,
296  uint32_t AlignInBits, unsigned Encoding,
297  DIFlags Flags, StorageType Storage,
298  bool ShouldCreate) {
299  assert(isCanonical(Name) && "Expected canonical MDString");
301  (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags));
302  Metadata *Ops[] = {nullptr, nullptr, Name};
303  DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding,
304  Flags), Ops);
305 }
306 
308  switch (getEncoding()) {
309  case dwarf::DW_ATE_signed:
310  case dwarf::DW_ATE_signed_char:
311  return Signedness::Signed;
312  case dwarf::DW_ATE_unsigned:
313  case dwarf::DW_ATE_unsigned_char:
314  return Signedness::Unsigned;
315  default:
316  return None;
317  }
318 }
319 
320 DIDerivedType *DIDerivedType::getImpl(
321  LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
322  unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
323  uint32_t AlignInBits, uint64_t OffsetInBits,
324  Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Metadata *ExtraData,
325  StorageType Storage, bool ShouldCreate) {
326  assert(isCanonical(Name) && "Expected canonical MDString");
328  (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
329  AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
330  ExtraData));
331  Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
333  DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
334  DWARFAddressSpace, Flags), Ops);
335 }
336 
337 DICompositeType *DICompositeType::getImpl(
338  LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
339  unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
340  uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
341  Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
342  Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator,
343  StorageType Storage, bool ShouldCreate) {
344  assert(isCanonical(Name) && "Expected canonical MDString");
345 
346  // Keep this in sync with buildODRType.
348  DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
349  AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
350  VTableHolder, TemplateParams, Identifier, Discriminator));
351  Metadata *Ops[] = {File, Scope, Name, BaseType,
352  Elements, VTableHolder, TemplateParams, Identifier,
353  Discriminator};
354  DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,
355  AlignInBits, OffsetInBits, Flags),
356  Ops);
357 }
358 
360  LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
361  Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
362  uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
363  DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
364  Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
365  assert(!Identifier.getString().empty() && "Expected valid identifier");
366  if (!Context.isODRUniquingDebugTypes())
367  return nullptr;
368  auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
369  if (!CT)
370  return CT = DICompositeType::getDistinct(
371  Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
372  AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
373  VTableHolder, TemplateParams, &Identifier, Discriminator);
374 
375  // Only mutate CT if it's a forward declaration and the new operands aren't.
376  assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?");
377  if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
378  return CT;
379 
380  // Mutate CT in place. Keep this in sync with getImpl.
381  CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
382  Flags);
383  Metadata *Ops[] = {File, Scope, Name, BaseType,
384  Elements, VTableHolder, TemplateParams, &Identifier,
385  Discriminator};
386  assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&
387  "Mismatched number of operands");
388  for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
389  if (Ops[I] != CT->getOperand(I))
390  CT->setOperand(I, Ops[I]);
391  return CT;
392 }
393 
394 DICompositeType *DICompositeType::getODRType(
395  LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
396  Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
397  uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
398  DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
399  Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
400  assert(!Identifier.getString().empty() && "Expected valid identifier");
401  if (!Context.isODRUniquingDebugTypes())
402  return nullptr;
403  auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
404  if (!CT)
406  Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
407  AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
408  TemplateParams, &Identifier, Discriminator);
409  return CT;
410 }
411 
413  MDString &Identifier) {
414  assert(!Identifier.getString().empty() && "Expected valid identifier");
415  if (!Context.isODRUniquingDebugTypes())
416  return nullptr;
417  return Context.pImpl->DITypeMap->lookup(&Identifier);
418 }
419 
420 DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
421  uint8_t CC, Metadata *TypeArray,
422  StorageType Storage,
423  bool ShouldCreate) {
424  DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray));
425  Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
426  DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops);
427 }
428 
429 // FIXME: Implement this string-enum correspondence with a .def file and macros,
430 // so that the association is explicit rather than implied.
431 static const char *ChecksumKindName[DIFile::CSK_Last] = {
432  "CSK_MD5",
433  "CSK_SHA1"
434 };
435 
436 StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
437  assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind");
438  // The first space was originally the CSK_None variant, which is now
439  // obsolete, but the space is still reserved in ChecksumKind, so we account
440  // for it here.
441  return ChecksumKindName[CSKind - 1];
442 }
443 
446  .Case("CSK_MD5", DIFile::CSK_MD5)
447  .Case("CSK_SHA1", DIFile::CSK_SHA1)
448  .Default(None);
449 }
450 
451 DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
452  MDString *Directory,
455  bool ShouldCreate) {
456  assert(isCanonical(Filename) && "Expected canonical MDString");
457  assert(isCanonical(Directory) && "Expected canonical MDString");
458  assert((!CS || isCanonical(CS->Value)) && "Expected canonical MDString");
459  assert((!Source || isCanonical(*Source)) && "Expected canonical MDString");
460  DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS, Source));
461  Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr,
462  Source.getValueOr(nullptr)};
463  DEFINE_GETIMPL_STORE(DIFile, (CS, Source), Ops);
464 }
465 
466 DICompileUnit *DICompileUnit::getImpl(
467  LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
468  MDString *Producer, bool IsOptimized, MDString *Flags,
469  unsigned RuntimeVersion, MDString *SplitDebugFilename,
470  unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
471  Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
472  uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
473  unsigned NameTableKind, bool RangesBaseAddress, StorageType Storage,
474  bool ShouldCreate) {
475  assert(Storage != Uniqued && "Cannot unique DICompileUnit");
476  assert(isCanonical(Producer) && "Expected canonical MDString");
477  assert(isCanonical(Flags) && "Expected canonical MDString");
478  assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString");
479 
480  Metadata *Ops[] = {
481  File, Producer, Flags, SplitDebugFilename,
482  EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
483  Macros};
484  return storeImpl(new (array_lengthof(Ops)) DICompileUnit(
485  Context, Storage, SourceLanguage, IsOptimized,
486  RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
487  DebugInfoForProfiling, NameTableKind, RangesBaseAddress,
488  Ops),
489  Storage);
490 }
491 
495  .Case("NoDebug", NoDebug)
496  .Case("FullDebug", FullDebug)
497  .Case("LineTablesOnly", LineTablesOnly)
498  .Case("DebugDirectivesOnly", DebugDirectivesOnly)
499  .Default(None);
500 }
501 
505  .Case("Default", DebugNameTableKind::Default)
508  .Default(None);
509 }
510 
512  switch (EK) {
513  case NoDebug: return "NoDebug";
514  case FullDebug: return "FullDebug";
515  case LineTablesOnly: return "LineTablesOnly";
516  case DebugDirectivesOnly: return "DebugDirectivesOnly";
517  }
518  return nullptr;
519 }
520 
522  switch (NTK) {
524  return nullptr;
526  return "GNU";
528  return "None";
529  }
530  return nullptr;
531 }
532 
534  if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
535  return Block->getScope()->getSubprogram();
536  return const_cast<DISubprogram *>(cast<DISubprogram>(this));
537 }
538 
540  if (auto *File = dyn_cast<DILexicalBlockFile>(this))
541  return File->getScope()->getNonLexicalBlockFileScope();
542  return const_cast<DILocalScope *>(this);
543 }
544 
547 #define HANDLE_DISP_FLAG(ID, NAME) .Case("DISPFlag" #NAME, SPFlag##NAME)
548 #include "llvm/IR/DebugInfoFlags.def"
549  .Default(SPFlagZero);
550 }
551 
553  switch (Flag) {
554  // Appease a warning.
555  case SPFlagVirtuality:
556  return "";
557 #define HANDLE_DISP_FLAG(ID, NAME) \
558  case SPFlag##NAME: \
559  return "DISPFlag" #NAME;
560 #include "llvm/IR/DebugInfoFlags.def"
561  }
562  return "";
563 }
564 
567  SmallVectorImpl<DISPFlags> &SplitFlags) {
568  // Multi-bit fields can require special handling. In our case, however, the
569  // only multi-bit field is virtuality, and all its values happen to be
570  // single-bit values, so the right behavior just falls out.
571 #define HANDLE_DISP_FLAG(ID, NAME) \
572  if (DISPFlags Bit = Flags & SPFlag##NAME) { \
573  SplitFlags.push_back(Bit); \
574  Flags &= ~Bit; \
575  }
576 #include "llvm/IR/DebugInfoFlags.def"
577  return Flags;
578 }
579 
580 DISubprogram *DISubprogram::getImpl(
581  LLVMContext &Context, Metadata *Scope, MDString *Name,
582  MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
583  unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
584  int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
585  Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes,
586  Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate) {
587  assert(isCanonical(Name) && "Expected canonical MDString");
588  assert(isCanonical(LinkageName) && "Expected canonical MDString");
590  (Scope, Name, LinkageName, File, Line, Type, ScopeLine,
591  ContainingType, VirtualIndex, ThisAdjustment, Flags,
592  SPFlags, Unit, TemplateParams, Declaration,
593  RetainedNodes, ThrownTypes));
595  File, Scope, Name, LinkageName, Type, Unit,
596  Declaration, RetainedNodes, ContainingType, TemplateParams, ThrownTypes};
597  if (!ThrownTypes) {
598  Ops.pop_back();
599  if (!TemplateParams) {
600  Ops.pop_back();
601  if (!ContainingType)
602  Ops.pop_back();
603  }
604  }
606  DISubprogram,
607  (Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags), Ops,
608  Ops.size());
609 }
610 
611 bool DISubprogram::describes(const Function *F) const {
612  assert(F && "Invalid function");
613  if (F->getSubprogram() == this)
614  return true;
615  StringRef Name = getLinkageName();
616  if (Name.empty())
617  Name = getName();
618  return F->getName() == Name;
619 }
620 
621 DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
622  Metadata *File, unsigned Line,
623  unsigned Column, StorageType Storage,
624  bool ShouldCreate) {
625  // Fixup column.
626  adjustColumn(Column);
627 
628  assert(Scope && "Expected scope");
629  DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column));
630  Metadata *Ops[] = {File, Scope};
631  DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops);
632 }
633 
634 DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
635  Metadata *Scope, Metadata *File,
636  unsigned Discriminator,
637  StorageType Storage,
638  bool ShouldCreate) {
639  assert(Scope && "Expected scope");
640  DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator));
641  Metadata *Ops[] = {File, Scope};
642  DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops);
643 }
644 
645 DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
646  MDString *Name, bool ExportSymbols,
647  StorageType Storage, bool ShouldCreate) {
648  assert(isCanonical(Name) && "Expected canonical MDString");
649  DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols));
650  // The nullptr is for DIScope's File operand. This should be refactored.
651  Metadata *Ops[] = {nullptr, Scope, Name};
652  DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops);
653 }
654 
655 DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
656  MDString *Name, MDString *ConfigurationMacros,
657  MDString *IncludePath, MDString *ISysRoot,
658  StorageType Storage, bool ShouldCreate) {
659  assert(isCanonical(Name) && "Expected canonical MDString");
661  DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot));
662  Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot};
664 }
665 
666 DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
667  MDString *Name,
668  Metadata *Type,
669  StorageType Storage,
670  bool ShouldCreate) {
671  assert(isCanonical(Name) && "Expected canonical MDString");
673  Metadata *Ops[] = {Name, Type};
675 }
676 
677 DITemplateValueParameter *DITemplateValueParameter::getImpl(
678  LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
679  Metadata *Value, StorageType Storage, bool ShouldCreate) {
680  assert(isCanonical(Name) && "Expected canonical MDString");
681  DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter, (Tag, Name, Type, Value));
682  Metadata *Ops[] = {Name, Type, Value};
684 }
685 
687 DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
688  MDString *LinkageName, Metadata *File, unsigned Line,
689  Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
690  Metadata *StaticDataMemberDeclaration,
691  Metadata *TemplateParams, uint32_t AlignInBits,
692  StorageType Storage, bool ShouldCreate) {
693  assert(isCanonical(Name) && "Expected canonical MDString");
694  assert(isCanonical(LinkageName) && "Expected canonical MDString");
695  DEFINE_GETIMPL_LOOKUP(DIGlobalVariable, (Scope, Name, LinkageName, File, Line,
696  Type, IsLocalToUnit, IsDefinition,
697  StaticDataMemberDeclaration,
698  TemplateParams, AlignInBits));
699  Metadata *Ops[] = {Scope,
700  Name,
701  File,
702  Type,
703  Name,
704  LinkageName,
705  StaticDataMemberDeclaration,
706  TemplateParams};
708  (Line, IsLocalToUnit, IsDefinition, AlignInBits), Ops);
709 }
710 
711 DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
712  MDString *Name, Metadata *File,
713  unsigned Line, Metadata *Type,
714  unsigned Arg, DIFlags Flags,
715  uint32_t AlignInBits,
716  StorageType Storage,
717  bool ShouldCreate) {
718  // 64K ought to be enough for any frontend.
719  assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
720 
721  assert(Scope && "Expected scope");
722  assert(isCanonical(Name) && "Expected canonical MDString");
724  (Scope, Name, File, Line, Type, Arg, Flags,
725  AlignInBits));
726  Metadata *Ops[] = {Scope, Name, File, Type};
727  DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops);
728 }
729 
731  // This is used by the Verifier so be mindful of broken types.
732  const Metadata *RawType = getRawType();
733  while (RawType) {
734  // Try to get the size directly.
735  if (auto *T = dyn_cast<DIType>(RawType))
736  if (uint64_t Size = T->getSizeInBits())
737  return Size;
738 
739  if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
740  // Look at the base type.
741  RawType = DT->getRawBaseType();
742  continue;
743  }
744 
745  // Missing type or size.
746  break;
747  }
748 
749  // Fail gracefully.
750  return None;
751 }
752 
753 DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope,
754  MDString *Name, Metadata *File, unsigned Line,
755  StorageType Storage,
756  bool ShouldCreate) {
757  assert(Scope && "Expected scope");
758  assert(isCanonical(Name) && "Expected canonical MDString");
760  (Scope, Name, File, Line));
761  Metadata *Ops[] = {Scope, Name, File};
762  DEFINE_GETIMPL_STORE(DILabel, (Line), Ops);
763 }
764 
765 DIExpression *DIExpression::getImpl(LLVMContext &Context,
766  ArrayRef<uint64_t> Elements,
767  StorageType Storage, bool ShouldCreate) {
768  DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements));
770 }
771 
773  switch (getOp()) {
775  return 3;
776  case dwarf::DW_OP_constu:
777  case dwarf::DW_OP_plus_uconst:
778  return 2;
779  default:
780  return 1;
781  }
782 }
783 
784 bool DIExpression::isValid() const {
785  for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
786  // Check that there's space for the operand.
787  if (I->get() + I->getSize() > E->get())
788  return false;
789 
790  // Check that the operand is valid.
791  switch (I->getOp()) {
792  default:
793  return false;
795  // A fragment operator must appear at the end.
796  return I->get() + I->getSize() == E->get();
797  case dwarf::DW_OP_stack_value: {
798  // Must be the last one or followed by a DW_OP_LLVM_fragment.
799  if (I->get() + I->getSize() == E->get())
800  break;
801  auto J = I;
802  if ((++J)->getOp() != dwarf::DW_OP_LLVM_fragment)
803  return false;
804  break;
805  }
806  case dwarf::DW_OP_swap: {
807  // Must be more than one implicit element on the stack.
808 
809  // FIXME: A better way to implement this would be to add a local variable
810  // that keeps track of the stack depth and introduce something like a
811  // DW_LLVM_OP_implicit_location as a placeholder for the location this
812  // DIExpression is attached to, or else pass the number of implicit stack
813  // elements into isValid.
814  if (getNumElements() == 1)
815  return false;
816  break;
817  }
818  case dwarf::DW_OP_constu:
819  case dwarf::DW_OP_plus_uconst:
820  case dwarf::DW_OP_plus:
821  case dwarf::DW_OP_minus:
822  case dwarf::DW_OP_mul:
823  case dwarf::DW_OP_div:
824  case dwarf::DW_OP_mod:
825  case dwarf::DW_OP_or:
826  case dwarf::DW_OP_and:
827  case dwarf::DW_OP_xor:
828  case dwarf::DW_OP_shl:
829  case dwarf::DW_OP_shr:
830  case dwarf::DW_OP_shra:
831  case dwarf::DW_OP_deref:
832  case dwarf::DW_OP_xderef:
833  case dwarf::DW_OP_lit0:
834  case dwarf::DW_OP_not:
835  case dwarf::DW_OP_dup:
836  break;
837  }
838  }
839  return true;
840 }
841 
844  for (auto I = Start; I != End; ++I)
845  if (I->getOp() == dwarf::DW_OP_LLVM_fragment) {
846  DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)};
847  return Info;
848  }
849  return None;
850 }
851 
853  int64_t Offset) {
854  if (Offset > 0) {
855  Ops.push_back(dwarf::DW_OP_plus_uconst);
856  Ops.push_back(Offset);
857  } else if (Offset < 0) {
858  Ops.push_back(dwarf::DW_OP_constu);
859  Ops.push_back(-Offset);
860  Ops.push_back(dwarf::DW_OP_minus);
861  }
862 }
863 
864 bool DIExpression::extractIfOffset(int64_t &Offset) const {
865  if (getNumElements() == 0) {
866  Offset = 0;
867  return true;
868  }
869 
870  if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) {
871  Offset = Elements[1];
872  return true;
873  }
874 
875  if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) {
876  if (Elements[2] == dwarf::DW_OP_plus) {
877  Offset = Elements[1];
878  return true;
879  }
880  if (Elements[2] == dwarf::DW_OP_minus) {
881  Offset = -Elements[1];
882  return true;
883  }
884  }
885 
886  return false;
887 }
888 
889 DIExpression *DIExpression::prepend(const DIExpression *Expr, bool DerefBefore,
890  int64_t Offset, bool DerefAfter,
891  bool StackValue) {
893  if (DerefBefore)
894  Ops.push_back(dwarf::DW_OP_deref);
895 
896  appendOffset(Ops, Offset);
897  if (DerefAfter)
898  Ops.push_back(dwarf::DW_OP_deref);
899 
900  return prependOpcodes(Expr, Ops, StackValue);
901 }
902 
905  bool StackValue) {
906  assert(Expr && "Can't prepend ops to this expression");
907 
908  // If there are no ops to prepend, do not even add the DW_OP_stack_value.
909  if (Ops.empty())
910  StackValue = false;
911  for (auto Op : Expr->expr_ops()) {
912  // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
913  if (StackValue) {
914  if (Op.getOp() == dwarf::DW_OP_stack_value)
915  StackValue = false;
916  else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
917  Ops.push_back(dwarf::DW_OP_stack_value);
918  StackValue = false;
919  }
920  }
921  Op.appendToVector(Ops);
922  }
923  if (StackValue)
924  Ops.push_back(dwarf::DW_OP_stack_value);
925  return DIExpression::get(Expr->getContext(), Ops);
926 }
927 
929  ArrayRef<uint64_t> Ops) {
930  assert(Expr && !Ops.empty() && "Can't append ops to this expression");
931 
932  // Copy Expr's current op list.
934  for (auto Op : Expr->expr_ops()) {
935  // Append new opcodes before DW_OP_{stack_value, LLVM_fragment}.
936  if (Op.getOp() == dwarf::DW_OP_stack_value ||
937  Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
938  NewOps.append(Ops.begin(), Ops.end());
939 
940  // Ensure that the new opcodes are only appended once.
941  Ops = None;
942  }
943  Op.appendToVector(NewOps);
944  }
945 
946  NewOps.append(Ops.begin(), Ops.end());
947  return DIExpression::get(Expr->getContext(), NewOps);
948 }
949 
951  ArrayRef<uint64_t> Ops) {
952  assert(Expr && !Ops.empty() && "Can't append ops to this expression");
953  assert(none_of(Ops,
954  [](uint64_t Op) {
955  return Op == dwarf::DW_OP_stack_value ||
957  }) &&
958  "Can't append this op");
959 
960  // Append a DW_OP_deref after Expr's current op list if it's non-empty and
961  // has no DW_OP_stack_value.
962  //
963  // Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?.
965  unsigned DropUntilStackValue = FI.hasValue() ? 3 : 0;
966  ArrayRef<uint64_t> ExprOpsBeforeFragment =
967  Expr->getElements().drop_back(DropUntilStackValue);
968  bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) &&
969  (ExprOpsBeforeFragment.back() != dwarf::DW_OP_stack_value);
970  bool NeedsStackValue = NeedsDeref || ExprOpsBeforeFragment.empty();
971 
972  // Append a DW_OP_deref after Expr's current op list if needed, then append
973  // the new ops, and finally ensure that a single DW_OP_stack_value is present.
975  if (NeedsDeref)
976  NewOps.push_back(dwarf::DW_OP_deref);
977  NewOps.append(Ops.begin(), Ops.end());
978  if (NeedsStackValue)
979  NewOps.push_back(dwarf::DW_OP_stack_value);
980  return DIExpression::append(Expr, NewOps);
981 }
982 
984  const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) {
986  // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
987  if (Expr) {
988  for (auto Op : Expr->expr_ops()) {
989  switch (Op.getOp()) {
990  default: break;
991  case dwarf::DW_OP_plus:
992  case dwarf::DW_OP_minus:
993  // We can't safely split arithmetic into multiple fragments because we
994  // can't express carry-over between fragments.
995  //
996  // FIXME: We *could* preserve the lowest fragment of a constant offset
997  // operation if the offset fits into SizeInBits.
998  return None;
1000  // Make the new offset point into the existing fragment.
1001  uint64_t FragmentOffsetInBits = Op.getArg(0);
1002  uint64_t FragmentSizeInBits = Op.getArg(1);
1003  (void)FragmentSizeInBits;
1004  assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&
1005  "new fragment outside of original fragment");
1006  OffsetInBits += FragmentOffsetInBits;
1007  continue;
1008  }
1009  }
1010  Op.appendToVector(Ops);
1011  }
1012  }
1014  Ops.push_back(OffsetInBits);
1015  Ops.push_back(SizeInBits);
1016  return DIExpression::get(Expr->getContext(), Ops);
1017 }
1018 
1020  // Recognize DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment Len Ofs)?.
1021  if (getNumElements() != 3 && getNumElements() != 6)
1022  return false;
1023  if (getElement(0) != dwarf::DW_OP_constu ||
1024  getElement(2) != dwarf::DW_OP_stack_value)
1025  return false;
1026  if (getNumElements() == 6 && getElement(3) != dwarf::DW_OP_LLVM_fragment)
1027  return false;
1028  return true;
1029 }
1030 
1032 DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
1033  Metadata *Expression, StorageType Storage,
1034  bool ShouldCreate) {
1035  DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression, (Variable, Expression));
1036  Metadata *Ops[] = {Variable, Expression};
1038 }
1039 
1040 DIObjCProperty *DIObjCProperty::getImpl(
1041  LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
1042  MDString *GetterName, MDString *SetterName, unsigned Attributes,
1043  Metadata *Type, StorageType Storage, bool ShouldCreate) {
1044  assert(isCanonical(Name) && "Expected canonical MDString");
1045  assert(isCanonical(GetterName) && "Expected canonical MDString");
1046  assert(isCanonical(SetterName) && "Expected canonical MDString");
1047  DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,
1048  SetterName, Attributes, Type));
1049  Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
1050  DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
1051 }
1052 
1053 DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
1054  Metadata *Scope, Metadata *Entity,
1055  Metadata *File, unsigned Line,
1056  MDString *Name, StorageType Storage,
1057  bool ShouldCreate) {
1058  assert(isCanonical(Name) && "Expected canonical MDString");
1060  (Tag, Scope, Entity, File, Line, Name));
1061  Metadata *Ops[] = {Scope, Entity, Name, File};
1062  DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
1063 }
1064 
1065 DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType,
1066  unsigned Line, MDString *Name, MDString *Value,
1067  StorageType Storage, bool ShouldCreate) {
1068  assert(isCanonical(Name) && "Expected canonical MDString");
1069  DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value));
1070  Metadata *Ops[] = { Name, Value };
1071  DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops);
1072 }
1073 
1074 DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
1075  unsigned Line, Metadata *File,
1076  Metadata *Elements, StorageType Storage,
1077  bool ShouldCreate) {
1079  (MIType, Line, File, Elements));
1080  Metadata *Ops[] = { File, Elements };
1081  DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops);
1082 }
static void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
uint64_t CallInst * C
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:259
unsigned char Storage
Storage flag for non-uniqued, otherwise unowned, metadata.
Definition: Metadata.h:69
ArrayRef< uint64_t > getElements() const
bool isConstant() const
Determine whether this represents a standalone constant value.
static std::string getLinkageName(GlobalValue::LinkageTypes LT)
Definition: AsmWriter.cpp:2848
LLVMContext & Context
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:158
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:250
static DICompositeType * getODRTypeIfExists(LLVMContext &Context, MDString &Identifier)
This class represents lattice values for constants.
Definition: AllocatorList.h:24
iterator begin() const
Definition: ArrayRef.h:137
static const DILocation * getMergedLocation(const DILocation *LocA, const DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
Definition: Optional.h:172
#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS)
unsigned getSize() const
Return the size of the operand.
static bool isCanonical(const MDString *S)
Optional< Signedness > getSignedness() const
Return the signedness of this type, or None if this type is neither signed nor unsigned.
Metadata node.
Definition: Metadata.h:864
F(f)
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
Definition: MetadataImpl.h:43
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:177
static Optional< ChecksumKind > getChecksumKind(StringRef CSKindStr)
A scope for locals.
#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS)
static DIExpression * prepend(const DIExpression *Expr, bool DerefBefore, int64_t Offset=0, bool DerefAfter=false, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
static DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
static DISPFlags splitFlags(DISPFlags Flags, SmallVectorImpl< DISPFlags > &SplitFlags)
Split up a flags bitfield for easier printing.
static StringRef getFlagString(DISPFlags Flag)
Array subrange.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1190
static StringRef getName(Value *V)
Only used in LLVM metadata.
Definition: Dwarf.h:132
Holds a subclass of DINode.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
Definition: StringSwitch.h:203
Subprogram description.
Key
PAL metadata keys.
#define HANDLE_DISP_FLAG(ID, NAME)
Holds the characteristics of one fragment of a larger variable.
static DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
LLVMContext & getContext() const
Definition: Metadata.h:924
Enumeration value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
Debug location.
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:410
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:118
StringRef getString() const
Definition: Metadata.cpp:464
static StringRef getFlagString(DIFlags Flag)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1166
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:43
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
Definition: MetadataImpl.h:23
A single checksum, represented by a Kind and a Value (a string).
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition: Metadata.cpp:1508
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
struct UnitT Unit
#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS)
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1174
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
static void adjustColumn(unsigned &Column)
SourceLanguage
Definition: Dwarf.h:185
static const char * nameTableKindString(DebugNameTableKind PK)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:371
StorageType
Active type of storage.
Definition: Metadata.h:66
bool isODRUniquingDebugTypes() const
Whether there is a string map for uniquing debug info identifiers across the context.
A pair of DIGlobalVariable and DIExpression.
static DIExpression * appendToStack(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Convert DIExpr into a stack value if it isn&#39;t one already by appending DW_OP_deref if needed...
Optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn&#39;t already there.
Definition: SmallSet.h:181
DebugNameTableKind getNameTableKind() const
size_t size() const
Definition: SmallVector.h:53
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:71
An imported module (C++ using directive or similar).
DILocalScope * getNonLexicalBlockFileScope() const
Get the first non DILexicalBlockFile scope of this scope.
Base class for scope-like contexts.
iterator_range< expr_op_iterator > expr_ops() const
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:418
static DISPFlags getFlag(StringRef Flag)
StringRef getName() const
Optional< uint64_t > getSizeInBits() const
Determines the size of the variable&#39;s type.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:1034
static DIFlags splitFlags(DIFlags Flags, SmallVectorImpl< DIFlags > &SplitFlags)
Split up a flags bitfield.
iterator end() const
Definition: ArrayRef.h:138
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition: Constants.cpp:632
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition: ArrayRef.h:194
DWARF expression.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
DebugEmissionKind getEmissionKind() const
static DIFlags getFlag(StringRef Flag)
A (clang) module that has been imported by the compile unit.
unsigned unsigned DILocalScope * Scope
Generic tagged DWARF-like metadata node.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:70
unsigned getNumElements() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:394
amdgpu Simplify well known AMD library false Value Value * Arg
#define HANDLE_DI_FLAG(ID, NAME)
Type array for a subprogram.
bool hasValue() const
Definition: Optional.h:165
static const char * ChecksumKindName[DIFile::CSK_Last]
DIFlags
Debug info flags.
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:56
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:215
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
uint32_t Size
Definition: Profile.cpp:47
bool extractIfOffset(int64_t &Offset) const
If this is a constant offset, extract it.
DISPFlags
Debug info subprogram flags.
static DICompositeType * buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator)
Build a DICompositeType with the given ODR identifier.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Definition: Value.h:73
#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS)
An iterator for expression operands.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
A single uniqued string.
Definition: Metadata.h:604
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
This lazily constructs the LazyValueInfoImpl.
Optional< DenseMap< const MDString *, DICompositeType * > > DITypeMap
Root of the metadata hierarchy.
Definition: Metadata.h:58
static const char * emissionKindString(DebugEmissionKind EK)
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:144
static Optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
Basic type, like &#39;int&#39; or &#39;float&#39;.
DIScopeRef getScope() const
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
Definition: SmallSet.h:165