LLVM  4.0.0
LLVMContextImpl.h
Go to the documentation of this file.
1 //===-- LLVMContextImpl.h - The LLVMContextImpl opaque class ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares LLVMContextImpl, the opaque implementation
11 // of LLVMContext.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_IR_LLVMCONTEXTIMPL_H
16 #define LLVM_LIB_IR_LLVMCONTEXTIMPL_H
17 
18 #include "AttributeImpl.h"
19 #include "ConstantsContext.h"
20 #include "llvm/ADT/APFloat.h"
21 #include "llvm/ADT/APInt.h"
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/DenseMap.h"
24 #include "llvm/ADT/DenseSet.h"
25 #include "llvm/ADT/FoldingSet.h"
26 #include "llvm/ADT/Hashing.h"
27 #include "llvm/ADT/SmallPtrSet.h"
28 #include "llvm/ADT/StringMap.h"
29 #include "llvm/ADT/StringSet.h"
30 #include "llvm/IR/Constants.h"
32 #include "llvm/IR/DerivedTypes.h"
33 #include "llvm/IR/LLVMContext.h"
34 #include "llvm/IR/Metadata.h"
35 #include "llvm/IR/ValueHandle.h"
36 #include "llvm/Support/Dwarf.h"
38 #include <vector>
39 
40 namespace llvm {
41 
42 class ConstantInt;
43 class ConstantFP;
44 class DiagnosticInfoOptimizationRemark;
45 class DiagnosticInfoOptimizationRemarkMissed;
46 class DiagnosticInfoOptimizationRemarkAnalysis;
47 class GCStrategy;
48 class LLVMContext;
49 class Type;
50 class Value;
51 
53  static inline APInt getEmptyKey() {
54  APInt V(nullptr, 0);
55  V.VAL = 0;
56  return V;
57  }
58  static inline APInt getTombstoneKey() {
59  APInt V(nullptr, 0);
60  V.VAL = 1;
61  return V;
62  }
63  static unsigned getHashValue(const APInt &Key) {
64  return static_cast<unsigned>(hash_value(Key));
65  }
66  static bool isEqual(const APInt &LHS, const APInt &RHS) {
67  return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
68  }
69 };
70 
72  static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); }
73  static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus(), 2); }
74  static unsigned getHashValue(const APFloat &Key) {
75  return static_cast<unsigned>(hash_value(Key));
76  }
77  static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
78  return LHS.bitwiseIsEqual(RHS);
79  }
80 };
81 
83  struct KeyTy {
85  bool isPacked;
86  KeyTy(const ArrayRef<Type*>& E, bool P) :
87  ETypes(E), isPacked(P) {}
89  : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
90  bool operator==(const KeyTy& that) const {
91  if (isPacked != that.isPacked)
92  return false;
93  if (ETypes != that.ETypes)
94  return false;
95  return true;
96  }
97  bool operator!=(const KeyTy& that) const {
98  return !this->operator==(that);
99  }
100  };
101  static inline StructType* getEmptyKey() {
103  }
104  static inline StructType* getTombstoneKey() {
106  }
107  static unsigned getHashValue(const KeyTy& Key) {
108  return hash_combine(hash_combine_range(Key.ETypes.begin(),
109  Key.ETypes.end()),
110  Key.isPacked);
111  }
112  static unsigned getHashValue(const StructType *ST) {
113  return getHashValue(KeyTy(ST));
114  }
115  static bool isEqual(const KeyTy& LHS, const StructType *RHS) {
116  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
117  return false;
118  return LHS == KeyTy(RHS);
119  }
120  static bool isEqual(const StructType *LHS, const StructType *RHS) {
121  return LHS == RHS;
122  }
123 };
124 
126  struct KeyTy {
127  const Type *ReturnType;
129  bool isVarArg;
130  KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) :
131  ReturnType(R), Params(P), isVarArg(V) {}
132  KeyTy(const FunctionType *FT)
133  : ReturnType(FT->getReturnType()), Params(FT->params()),
134  isVarArg(FT->isVarArg()) {}
135  bool operator==(const KeyTy& that) const {
136  if (ReturnType != that.ReturnType)
137  return false;
138  if (isVarArg != that.isVarArg)
139  return false;
140  if (Params != that.Params)
141  return false;
142  return true;
143  }
144  bool operator!=(const KeyTy& that) const {
145  return !this->operator==(that);
146  }
147  };
148  static inline FunctionType* getEmptyKey() {
150  }
151  static inline FunctionType* getTombstoneKey() {
153  }
154  static unsigned getHashValue(const KeyTy& Key) {
155  return hash_combine(Key.ReturnType,
156  hash_combine_range(Key.Params.begin(),
157  Key.Params.end()),
158  Key.isVarArg);
159  }
160  static unsigned getHashValue(const FunctionType *FT) {
161  return getHashValue(KeyTy(FT));
162  }
163  static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) {
164  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
165  return false;
166  return LHS == KeyTy(RHS);
167  }
168  static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
169  return LHS == RHS;
170  }
171 };
172 
173 /// \brief Structure for hashing arbitrary MDNode operands.
175  ArrayRef<Metadata *> RawOps;
177 
178  unsigned Hash;
179 
180 protected:
182  : RawOps(Ops), Hash(calculateHash(Ops)) {}
183 
184  template <class NodeTy>
185  MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
186  : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
187 
188  template <class NodeTy>
189  bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
190  if (getHash() != RHS->getHash())
191  return false;
192 
193  assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
194  return RawOps.empty() ? compareOps(Ops, RHS, Offset)
195  : compareOps(RawOps, RHS, Offset);
196  }
197 
198  static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
199 
200 private:
201  template <class T>
202  static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
203  if (Ops.size() != RHS->getNumOperands() - Offset)
204  return false;
205  return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
206  }
207 
208  static unsigned calculateHash(ArrayRef<Metadata *> Ops);
209 
210 public:
211  unsigned getHash() const { return Hash; }
212 };
213 
214 template <class NodeTy> struct MDNodeKeyImpl;
215 template <class NodeTy> struct MDNodeInfo;
216 
217 /// Configuration point for MDNodeInfo::isEqual().
218 template <class NodeTy> struct MDNodeSubsetEqualImpl {
220  static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) {
221  return false;
222  }
223  static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) {
224  return false;
225  }
226 };
227 
228 /// \brief DenseMapInfo for MDTuple.
229 ///
230 /// Note that we don't need the is-function-local bit, since that's implicit in
231 /// the operands.
232 template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
235 
236  bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
237 
238  unsigned getHashValue() const { return getHash(); }
239 
240  static unsigned calculateHash(MDTuple *N) {
241  return MDNodeOpsKey::calculateHash(N);
242  }
243 };
244 
245 /// \brief DenseMapInfo for DILocation.
246 template <> struct MDNodeKeyImpl<DILocation> {
247  unsigned Line;
248  unsigned Column;
251 
252  MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
253  Metadata *InlinedAt)
254  : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {}
255 
257  : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()),
258  InlinedAt(L->getRawInlinedAt()) {}
259 
260  bool isKeyOf(const DILocation *RHS) const {
261  return Line == RHS->getLine() && Column == RHS->getColumn() &&
262  Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt();
263  }
264  unsigned getHashValue() const {
265  return hash_combine(Line, Column, Scope, InlinedAt);
266  }
267 };
268 
269 /// \brief DenseMapInfo for GenericDINode.
270 template <> struct MDNodeKeyImpl<GenericDINode> : MDNodeOpsKey {
271  unsigned Tag;
273  MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef<Metadata *> DwarfOps)
274  : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
276  : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {}
277 
278  bool isKeyOf(const GenericDINode *RHS) const {
279  return Tag == RHS->getTag() && Header == RHS->getRawHeader() &&
280  compareOps(RHS, 1);
281  }
282 
283  unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
284 
285  static unsigned calculateHash(GenericDINode *N) {
286  return MDNodeOpsKey::calculateHash(N, 1);
287  }
288 };
289 
290 template <> struct MDNodeKeyImpl<DISubrange> {
291  int64_t Count;
292  int64_t LowerBound;
293 
294  MDNodeKeyImpl(int64_t Count, int64_t LowerBound)
295  : Count(Count), LowerBound(LowerBound) {}
297  : Count(N->getCount()), LowerBound(N->getLowerBound()) {}
298 
299  bool isKeyOf(const DISubrange *RHS) const {
300  return Count == RHS->getCount() && LowerBound == RHS->getLowerBound();
301  }
302  unsigned getHashValue() const { return hash_combine(Count, LowerBound); }
303 };
304 
305 template <> struct MDNodeKeyImpl<DIEnumerator> {
306  int64_t Value;
308 
309  MDNodeKeyImpl(int64_t Value, MDString *Name) : Value(Value), Name(Name) {}
311  : Value(N->getValue()), Name(N->getRawName()) {}
312 
313  bool isKeyOf(const DIEnumerator *RHS) const {
314  return Value == RHS->getValue() && Name == RHS->getRawName();
315  }
316  unsigned getHashValue() const { return hash_combine(Value, Name); }
317 };
318 
319 template <> struct MDNodeKeyImpl<DIBasicType> {
320  unsigned Tag;
322  uint64_t SizeInBits;
324  unsigned Encoding;
325 
326  MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits,
327  uint32_t AlignInBits, unsigned Encoding)
328  : Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
329  Encoding(Encoding) {}
331  : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()),
332  AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {}
333 
334  bool isKeyOf(const DIBasicType *RHS) const {
335  return Tag == RHS->getTag() && Name == RHS->getRawName() &&
336  SizeInBits == RHS->getSizeInBits() &&
337  AlignInBits == RHS->getAlignInBits() &&
338  Encoding == RHS->getEncoding();
339  }
340  unsigned getHashValue() const {
341  return hash_combine(Tag, Name, SizeInBits, AlignInBits, Encoding);
342  }
343 };
344 
345 template <> struct MDNodeKeyImpl<DIDerivedType> {
346  unsigned Tag;
349  unsigned Line;
352  uint64_t SizeInBits;
353  uint64_t OffsetInBits;
355  unsigned Flags;
357 
358  MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
359  Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
360  uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
361  Metadata *ExtraData)
362  : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
363  BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
364  AlignInBits(AlignInBits), Flags(Flags), ExtraData(ExtraData) {}
366  : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
367  Line(N->getLine()), Scope(N->getRawScope()),
368  BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
369  OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
370  Flags(N->getFlags()), ExtraData(N->getRawExtraData()) {}
371 
372  bool isKeyOf(const DIDerivedType *RHS) const {
373  return Tag == RHS->getTag() && Name == RHS->getRawName() &&
374  File == RHS->getRawFile() && Line == RHS->getLine() &&
375  Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
376  SizeInBits == RHS->getSizeInBits() &&
377  AlignInBits == RHS->getAlignInBits() &&
378  OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() &&
379  ExtraData == RHS->getRawExtraData();
380  }
381  unsigned getHashValue() const {
382  // If this is a member inside an ODR type, only hash the type and the name.
383  // Otherwise the hash will be stronger than
384  // MDNodeSubsetEqualImpl::isODRMember().
385  if (Tag == dwarf::DW_TAG_member && Name)
386  if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
387  if (CT->getRawIdentifier())
388  return hash_combine(Name, Scope);
389 
390  // Intentionally computes the hash on a subset of the operands for
391  // performance reason. The subset has to be significant enough to avoid
392  // collision "most of the time". There is no correctness issue in case of
393  // collision because of the full check above.
394  return hash_combine(Tag, Name, File, Line, Scope, BaseType, Flags);
395  }
396 };
397 
400  static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS) {
401  return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
402  }
403  static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS) {
404  return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
405  RHS);
406  }
407 
408  /// Subprograms compare equal if they declare the same function in an ODR
409  /// type.
410  static bool isODRMember(unsigned Tag, const Metadata *Scope,
411  const MDString *Name, const DIDerivedType *RHS) {
412  // Check whether the LHS is eligible.
413  if (Tag != dwarf::DW_TAG_member || !Name)
414  return false;
415 
416  auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
417  if (!CT || !CT->getRawIdentifier())
418  return false;
419 
420  // Compare to the RHS.
421  return Tag == RHS->getTag() && Name == RHS->getRawName() &&
422  Scope == RHS->getRawScope();
423  }
424 };
425 
426 template <> struct MDNodeKeyImpl<DICompositeType> {
427  unsigned Tag;
430  unsigned Line;
433  uint64_t SizeInBits;
434  uint64_t OffsetInBits;
436  unsigned Flags;
438  unsigned RuntimeLang;
442 
443  MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
444  Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
445  uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
446  Metadata *Elements, unsigned RuntimeLang,
447  Metadata *VTableHolder, Metadata *TemplateParams,
448  MDString *Identifier)
449  : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
450  BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
451  AlignInBits(AlignInBits), Flags(Flags), Elements(Elements),
452  RuntimeLang(RuntimeLang), VTableHolder(VTableHolder),
453  TemplateParams(TemplateParams), Identifier(Identifier) {}
455  : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
456  Line(N->getLine()), Scope(N->getRawScope()),
457  BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
458  OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
459  Flags(N->getFlags()), Elements(N->getRawElements()),
460  RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()),
461  TemplateParams(N->getRawTemplateParams()),
462  Identifier(N->getRawIdentifier()) {}
463 
464  bool isKeyOf(const DICompositeType *RHS) const {
465  return Tag == RHS->getTag() && Name == RHS->getRawName() &&
466  File == RHS->getRawFile() && Line == RHS->getLine() &&
467  Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
468  SizeInBits == RHS->getSizeInBits() &&
469  AlignInBits == RHS->getAlignInBits() &&
470  OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() &&
471  Elements == RHS->getRawElements() &&
472  RuntimeLang == RHS->getRuntimeLang() &&
473  VTableHolder == RHS->getRawVTableHolder() &&
474  TemplateParams == RHS->getRawTemplateParams() &&
475  Identifier == RHS->getRawIdentifier();
476  }
477  unsigned getHashValue() const {
478  // Intentionally computes the hash on a subset of the operands for
479  // performance reason. The subset has to be significant enough to avoid
480  // collision "most of the time". There is no correctness issue in case of
481  // collision because of the full check above.
482  return hash_combine(Name, File, Line, BaseType, Scope, Elements,
483  TemplateParams);
484  }
485 };
486 
487 template <> struct MDNodeKeyImpl<DISubroutineType> {
488  unsigned Flags;
489  uint8_t CC;
491 
492  MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray)
493  : Flags(Flags), CC(CC), TypeArray(TypeArray) {}
495  : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {}
496 
497  bool isKeyOf(const DISubroutineType *RHS) const {
498  return Flags == RHS->getFlags() && CC == RHS->getCC() &&
499  TypeArray == RHS->getRawTypeArray();
500  }
501  unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); }
502 };
503 
504 template <> struct MDNodeKeyImpl<DIFile> {
509 
510  MDNodeKeyImpl(MDString *Filename, MDString *Directory,
511  DIFile::ChecksumKind CSKind, MDString *Checksum)
512  : Filename(Filename), Directory(Directory), CSKind(CSKind),
513  Checksum(Checksum) {}
515  : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
516  CSKind(N->getChecksumKind()), Checksum(N->getRawChecksum()) {}
517 
518  bool isKeyOf(const DIFile *RHS) const {
519  return Filename == RHS->getRawFilename() &&
520  Directory == RHS->getRawDirectory() &&
521  CSKind == RHS->getChecksumKind() &&
522  Checksum == RHS->getRawChecksum();
523  }
524  unsigned getHashValue() const {
525  return hash_combine(Filename, Directory, CSKind, Checksum);
526  }
527 };
528 
529 template <> struct MDNodeKeyImpl<DISubprogram> {
534  unsigned Line;
538  unsigned ScopeLine;
540  unsigned Virtuality;
541  unsigned VirtualIndex;
543  unsigned Flags;
549 
551  Metadata *File, unsigned Line, Metadata *Type,
552  bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
553  Metadata *ContainingType, unsigned Virtuality,
554  unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
555  bool IsOptimized, Metadata *Unit, Metadata *TemplateParams,
556  Metadata *Declaration, Metadata *Variables)
557  : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
558  Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
559  IsDefinition(IsDefinition), ScopeLine(ScopeLine),
560  ContainingType(ContainingType), Virtuality(Virtuality),
561  VirtualIndex(VirtualIndex), ThisAdjustment(ThisAdjustment),
562  Flags(Flags), IsOptimized(IsOptimized), Unit(Unit),
563  TemplateParams(TemplateParams), Declaration(Declaration),
564  Variables(Variables) {}
566  : Scope(N->getRawScope()), Name(N->getRawName()),
567  LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
568  Line(N->getLine()), Type(N->getRawType()),
569  IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
570  ScopeLine(N->getScopeLine()), ContainingType(N->getRawContainingType()),
571  Virtuality(N->getVirtuality()), VirtualIndex(N->getVirtualIndex()),
572  ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()),
573  IsOptimized(N->isOptimized()), Unit(N->getRawUnit()),
574  TemplateParams(N->getRawTemplateParams()),
575  Declaration(N->getRawDeclaration()), Variables(N->getRawVariables()) {}
576 
577  bool isKeyOf(const DISubprogram *RHS) const {
578  return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
579  LinkageName == RHS->getRawLinkageName() &&
580  File == RHS->getRawFile() && Line == RHS->getLine() &&
581  Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
582  IsDefinition == RHS->isDefinition() &&
583  ScopeLine == RHS->getScopeLine() &&
584  ContainingType == RHS->getRawContainingType() &&
585  Virtuality == RHS->getVirtuality() &&
586  VirtualIndex == RHS->getVirtualIndex() &&
587  ThisAdjustment == RHS->getThisAdjustment() &&
588  Flags == RHS->getFlags() && IsOptimized == RHS->isOptimized() &&
589  Unit == RHS->getUnit() &&
590  TemplateParams == RHS->getRawTemplateParams() &&
591  Declaration == RHS->getRawDeclaration() &&
592  Variables == RHS->getRawVariables();
593  }
594  unsigned getHashValue() const {
595  // If this is a declaration inside an ODR type, only hash the type and the
596  // name. Otherwise the hash will be stronger than
597  // MDNodeSubsetEqualImpl::isDeclarationOfODRMember().
598  if (!IsDefinition && LinkageName)
599  if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope))
600  if (CT->getRawIdentifier())
601  return hash_combine(LinkageName, Scope);
602 
603  // Intentionally computes the hash on a subset of the operands for
604  // performance reason. The subset has to be significant enough to avoid
605  // collision "most of the time". There is no correctness issue in case of
606  // collision because of the full check above.
607  return hash_combine(Name, Scope, File, Type, Line);
608  }
609 };
610 
611 template <> struct MDNodeSubsetEqualImpl<DISubprogram> {
613  static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
614  return isDeclarationOfODRMember(LHS.IsDefinition, LHS.Scope,
615  LHS.LinkageName, RHS);
616  }
617  static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) {
618  return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(),
619  LHS->getRawLinkageName(), RHS);
620  }
621 
622  /// Subprograms compare equal if they declare the same function in an ODR
623  /// type.
624  static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope,
625  const MDString *LinkageName,
626  const DISubprogram *RHS) {
627  // Check whether the LHS is eligible.
628  if (IsDefinition || !Scope || !LinkageName)
629  return false;
630 
631  auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
632  if (!CT || !CT->getRawIdentifier())
633  return false;
634 
635  // Compare to the RHS.
636  return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() &&
637  LinkageName == RHS->getRawLinkageName();
638  }
639 };
640 
641 template <> struct MDNodeKeyImpl<DILexicalBlock> {
644  unsigned Line;
645  unsigned Column;
646 
647  MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
648  : Scope(Scope), File(File), Line(Line), Column(Column) {}
650  : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
651  Column(N->getColumn()) {}
652 
653  bool isKeyOf(const DILexicalBlock *RHS) const {
654  return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
655  Line == RHS->getLine() && Column == RHS->getColumn();
656  }
657  unsigned getHashValue() const {
658  return hash_combine(Scope, File, Line, Column);
659  }
660 };
661 
662 template <> struct MDNodeKeyImpl<DILexicalBlockFile> {
665  unsigned Discriminator;
666 
667  MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
668  : Scope(Scope), File(File), Discriminator(Discriminator) {}
670  : Scope(N->getRawScope()), File(N->getRawFile()),
671  Discriminator(N->getDiscriminator()) {}
672 
673  bool isKeyOf(const DILexicalBlockFile *RHS) const {
674  return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
675  Discriminator == RHS->getDiscriminator();
676  }
677  unsigned getHashValue() const {
678  return hash_combine(Scope, File, Discriminator);
679  }
680 };
681 
682 template <> struct MDNodeKeyImpl<DINamespace> {
686  unsigned Line;
688 
689  MDNodeKeyImpl(Metadata *Scope, Metadata *File, MDString *Name, unsigned Line,
690  bool ExportSymbols)
691  : Scope(Scope), File(File), Name(Name), Line(Line),
692  ExportSymbols(ExportSymbols) {}
694  : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getRawName()),
695  Line(N->getLine()), ExportSymbols(N->getExportSymbols()) {}
696 
697  bool isKeyOf(const DINamespace *RHS) const {
698  return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
699  Name == RHS->getRawName() && Line == RHS->getLine() &&
700  ExportSymbols == RHS->getExportSymbols();
701  }
702  unsigned getHashValue() const {
703  return hash_combine(Scope, File, Name, Line);
704  }
705 };
706 
707 template <> struct MDNodeKeyImpl<DIModule> {
713  MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *ConfigurationMacros,
714  MDString *IncludePath, MDString *ISysRoot)
715  : Scope(Scope), Name(Name), ConfigurationMacros(ConfigurationMacros),
716  IncludePath(IncludePath), ISysRoot(ISysRoot) {}
718  : Scope(N->getRawScope()), Name(N->getRawName()),
719  ConfigurationMacros(N->getRawConfigurationMacros()),
720  IncludePath(N->getRawIncludePath()), ISysRoot(N->getRawISysRoot()) {}
721 
722  bool isKeyOf(const DIModule *RHS) const {
723  return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
724  ConfigurationMacros == RHS->getRawConfigurationMacros() &&
725  IncludePath == RHS->getRawIncludePath() &&
726  ISysRoot == RHS->getRawISysRoot();
727  }
728  unsigned getHashValue() const {
729  return hash_combine(Scope, Name,
730  ConfigurationMacros, IncludePath, ISysRoot);
731  }
732 };
733 
737 
738  MDNodeKeyImpl(MDString *Name, Metadata *Type) : Name(Name), Type(Type) {}
740  : Name(N->getRawName()), Type(N->getRawType()) {}
741 
742  bool isKeyOf(const DITemplateTypeParameter *RHS) const {
743  return Name == RHS->getRawName() && Type == RHS->getRawType();
744  }
745  unsigned getHashValue() const { return hash_combine(Name, Type); }
746 };
747 
749  unsigned Tag;
753 
755  : Tag(Tag), Name(Name), Type(Type), Value(Value) {}
757  : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
758  Value(N->getValue()) {}
759 
760  bool isKeyOf(const DITemplateValueParameter *RHS) const {
761  return Tag == RHS->getTag() && Name == RHS->getRawName() &&
762  Type == RHS->getRawType() && Value == RHS->getValue();
763  }
764  unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
765 };
766 
767 template <> struct MDNodeKeyImpl<DIGlobalVariable> {
772  unsigned Line;
778 
780  Metadata *File, unsigned Line, Metadata *Type,
781  bool IsLocalToUnit, bool IsDefinition,
782  Metadata *StaticDataMemberDeclaration, uint32_t AlignInBits)
783  : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
784  Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
785  IsDefinition(IsDefinition),
786  StaticDataMemberDeclaration(StaticDataMemberDeclaration),
787  AlignInBits(AlignInBits) {}
789  : Scope(N->getRawScope()), Name(N->getRawName()),
790  LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
791  Line(N->getLine()), Type(N->getRawType()),
792  IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
793  StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
794  AlignInBits(N->getAlignInBits()) {}
795 
796  bool isKeyOf(const DIGlobalVariable *RHS) const {
797  return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
798  LinkageName == RHS->getRawLinkageName() &&
799  File == RHS->getRawFile() && Line == RHS->getLine() &&
800  Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
801  IsDefinition == RHS->isDefinition() &&
802  StaticDataMemberDeclaration ==
804  AlignInBits == RHS->getAlignInBits();
805  }
806  unsigned getHashValue() const {
807  // We do not use AlignInBits in hashing function here on purpose:
808  // in most cases this param for local variable is zero (for function param
809  // it is always zero). This leads to lots of hash collisions and errors on
810  // cases with lots of similar variables.
811  // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
812  // generated IR is random for each run and test fails with Align included.
813  // TODO: make hashing work fine with such situations
814  return hash_combine(Scope, Name, LinkageName, File, Line, Type,
815  IsLocalToUnit, IsDefinition, /* AlignInBits, */
816  StaticDataMemberDeclaration);
817  }
818 };
819 
820 template <> struct MDNodeKeyImpl<DILocalVariable> {
824  unsigned Line;
826  unsigned Arg;
827  unsigned Flags;
829 
830  MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
831  Metadata *Type, unsigned Arg, unsigned Flags,
832  uint32_t AlignInBits)
833  : Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
834  Flags(Flags), AlignInBits(AlignInBits) {}
836  : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
837  Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
838  Flags(N->getFlags()), AlignInBits(N->getAlignInBits()) {}
839 
840  bool isKeyOf(const DILocalVariable *RHS) const {
841  return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
842  File == RHS->getRawFile() && Line == RHS->getLine() &&
843  Type == RHS->getRawType() && Arg == RHS->getArg() &&
844  Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits();
845  }
846  unsigned getHashValue() const {
847  // We do not use AlignInBits in hashing function here on purpose:
848  // in most cases this param for local variable is zero (for function param
849  // it is always zero). This leads to lots of hash collisions and errors on
850  // cases with lots of similar variables.
851  // clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
852  // generated IR is random for each run and test fails with Align included.
853  // TODO: make hashing work fine with such situations
854  return hash_combine(Scope, Name, File, Line, Type, Arg, Flags);
855  }
856 };
857 
858 template <> struct MDNodeKeyImpl<DIExpression> {
860 
861  MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
862  MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
863 
864  bool isKeyOf(const DIExpression *RHS) const {
865  return Elements == RHS->getElements();
866  }
867  unsigned getHashValue() const {
868  return hash_combine_range(Elements.begin(), Elements.end());
869  }
870 };
871 
875 
876  MDNodeKeyImpl(Metadata *Variable, Metadata *Expression)
877  : Variable(Variable), Expression(Expression) {}
879  : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {}
880 
881  bool isKeyOf(const DIGlobalVariableExpression *RHS) const {
882  return Variable == RHS->getRawVariable() &&
883  Expression == RHS->getRawExpression();
884  }
885  unsigned getHashValue() const { return hash_combine(Variable, Expression); }
886 };
887 
888 template <> struct MDNodeKeyImpl<DIObjCProperty> {
891  unsigned Line;
894  unsigned Attributes;
896 
898  MDString *GetterName, MDString *SetterName, unsigned Attributes,
899  Metadata *Type)
900  : Name(Name), File(File), Line(Line), GetterName(GetterName),
901  SetterName(SetterName), Attributes(Attributes), Type(Type) {}
903  : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
904  GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()),
905  Attributes(N->getAttributes()), Type(N->getRawType()) {}
906 
907  bool isKeyOf(const DIObjCProperty *RHS) const {
908  return Name == RHS->getRawName() && File == RHS->getRawFile() &&
909  Line == RHS->getLine() && GetterName == RHS->getRawGetterName() &&
910  SetterName == RHS->getRawSetterName() &&
911  Attributes == RHS->getAttributes() && Type == RHS->getRawType();
912  }
913  unsigned getHashValue() const {
914  return hash_combine(Name, File, Line, GetterName, SetterName, Attributes,
915  Type);
916  }
917 };
918 
919 template <> struct MDNodeKeyImpl<DIImportedEntity> {
920  unsigned Tag;
923  unsigned Line;
925 
926  MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line,
927  MDString *Name)
928  : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {}
930  : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
931  Line(N->getLine()), Name(N->getRawName()) {}
932 
933  bool isKeyOf(const DIImportedEntity *RHS) const {
934  return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
935  Entity == RHS->getRawEntity() && Line == RHS->getLine() &&
936  Name == RHS->getRawName();
937  }
938  unsigned getHashValue() const {
939  return hash_combine(Tag, Scope, Entity, Line, Name);
940  }
941 };
942 
943 template <> struct MDNodeKeyImpl<DIMacro> {
944  unsigned MIType;
945  unsigned Line;
948 
949  MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value)
950  : MIType(MIType), Line(Line), Name(Name), Value(Value) {}
952  : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()),
953  Value(N->getRawValue()) {}
954 
955  bool isKeyOf(const DIMacro *RHS) const {
956  return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
957  Name == RHS->getRawName() && Value == RHS->getRawValue();
958  }
959  unsigned getHashValue() const {
960  return hash_combine(MIType, Line, Name, Value);
961  }
962 };
963 
964 template <> struct MDNodeKeyImpl<DIMacroFile> {
965  unsigned MIType;
966  unsigned Line;
969 
970  MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File,
971  Metadata *Elements)
972  : MIType(MIType), Line(Line), File(File), Elements(Elements) {}
974  : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()),
975  Elements(N->getRawElements()) {}
976 
977  bool isKeyOf(const DIMacroFile *RHS) const {
978  return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
979  File == RHS->getRawFile() && Elements == RHS->getRawElements();
980  }
981  unsigned getHashValue() const {
982  return hash_combine(MIType, Line, File, Elements);
983  }
984 };
985 
986 /// \brief DenseMapInfo for MDNode subclasses.
987 template <class NodeTy> struct MDNodeInfo {
990  static inline NodeTy *getEmptyKey() {
992  }
993  static inline NodeTy *getTombstoneKey() {
995  }
996  static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
997  static unsigned getHashValue(const NodeTy *N) {
998  return KeyTy(N).getHashValue();
999  }
1000  static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
1001  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1002  return false;
1003  return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS);
1004  }
1005  static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
1006  if (LHS == RHS)
1007  return true;
1008  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1009  return false;
1010  return SubsetEqualTy::isSubsetEqual(LHS, RHS);
1011  }
1012 };
1013 
1014 #define HANDLE_MDNODE_LEAF(CLASS) typedef MDNodeInfo<CLASS> CLASS##Info;
1015 #include "llvm/IR/Metadata.def"
1016 
1017 /// \brief Map-like storage for metadata attachments.
1020 
1021 public:
1022  bool empty() const { return Attachments.empty(); }
1023  size_t size() const { return Attachments.size(); }
1024 
1025  /// \brief Get a particular attachment (if any).
1026  MDNode *lookup(unsigned ID) const;
1027 
1028  /// \brief Set an attachment to a particular node.
1029  ///
1030  /// Set the \c ID attachment to \c MD, replacing the current attachment at \c
1031  /// ID (if anyway).
1032  void set(unsigned ID, MDNode &MD);
1033 
1034  /// \brief Remove an attachment.
1035  ///
1036  /// Remove the attachment at \c ID, if any.
1037  void erase(unsigned ID);
1038 
1039  /// \brief Copy out all the attachments.
1040  ///
1041  /// Copies all the current attachments into \c Result, sorting by attachment
1042  /// ID. This function does \em not clear \c Result.
1043  void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
1044 
1045  /// \brief Erase matching attachments.
1046  ///
1047  /// Erases all attachments matching the \c shouldRemove predicate.
1048  template <class PredTy> void remove_if(PredTy shouldRemove) {
1049  Attachments.erase(llvm::remove_if(Attachments, shouldRemove),
1050  Attachments.end());
1051  }
1052 };
1053 
1054 /// Multimap-like storage for metadata attachments for globals. This differs
1055 /// from MDAttachmentMap in that it allows multiple attachments per metadata
1056 /// kind.
1058  struct Attachment {
1059  unsigned MDKind;
1060  TrackingMDNodeRef Node;
1061  };
1062  SmallVector<Attachment, 1> Attachments;
1063 
1064 public:
1065  bool empty() const { return Attachments.empty(); }
1066 
1067  /// Appends all attachments with the given ID to \c Result in insertion order.
1068  /// If the global has no attachments with the given ID, or if ID is invalid,
1069  /// leaves Result unchanged.
1070  void get(unsigned ID, SmallVectorImpl<MDNode *> &Result);
1071 
1072  void insert(unsigned ID, MDNode &MD);
1073  void erase(unsigned ID);
1074 
1075  /// Appends all attachments for the global to \c Result, sorting by attachment
1076  /// ID. Attachments with the same ID appear in insertion order. This function
1077  /// does \em not clear \c Result.
1078  void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
1079 };
1080 
1082 public:
1083  /// OwnedModules - The set of modules instantiated in this context, and which
1084  /// will be automatically deleted if this context is deleted.
1086 
1089 
1094  std::unique_ptr<yaml::Output> DiagnosticsOutputFile;
1095 
1098 
1102 
1106 
1110 
1114 
1116 
1117 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
1118  DenseSet<CLASS *, CLASS##Info> CLASS##s;
1119 #include "llvm/IR/Metadata.def"
1120 
1121  // Optional map for looking up composite types by identifier.
1123 
1124  // MDNodes may be uniqued or not uniqued. When they're not uniqued, they
1125  // aren't in the MDNodeSet, but they're still shared between objects, so no
1126  // one object can destroy them. Keep track of them here so we can delete
1127  // them on context teardown.
1128  std::vector<MDNode *> DistinctMDNodes;
1129 
1131 
1134 
1137 
1140 
1142 
1144 
1146 
1150 
1152 
1155 
1156  std::unique_ptr<ConstantTokenNone> TheNoneToken;
1157 
1158  // Basic type instances.
1162 
1163 
1164  /// TypeAllocator - All dynamically allocated types are allocated from this.
1165  /// They live forever until the context is torn down.
1167 
1169 
1176 
1179  DenseMap<Type*, PointerType*> PointerTypes; // Pointers in AddrSpace = 0
1181 
1182 
1183  /// ValueHandles - This map keeps track of all of the value handles that are
1184  /// watching a Value*. The Value::HasValueHandle bit is used to know
1185  /// whether or not a value has an entry in this map.
1188 
1189  /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
1191 
1192  /// Collection of per-instruction metadata used in this context.
1194 
1195  /// Collection of per-GlobalObject metadata used in this context.
1197 
1198  /// Collection of per-GlobalObject sections used in this context.
1200 
1201  /// Stable collection of section strings.
1203 
1204  /// DiscriminatorTable - This table maps file:line locations to an
1205  /// integer representing the next DWARF path discriminator to assign to
1206  /// instructions in different blocks at the same location.
1208 
1209  int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx);
1210  int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx);
1211 
1212  /// \brief A set of interned tags for operand bundles. The StringMap maps
1213  /// bundle tags to their IDs.
1214  ///
1215  /// \see LLVMContext::getOperandBundleTagID
1217 
1221 
1222  /// Maintain the GC name for each function.
1223  ///
1224  /// This saves allocating an additional word in Function for programs which
1225  /// do not use GC (i.e., most programs) at the cost of increased overhead for
1226  /// clients which do use GC.
1228 
1229  /// Flag to indicate if Value (other than GlobalValue) retains their name or
1230  /// not.
1231  bool DiscardValueNames = false;
1232 
1234  ~LLVMContextImpl();
1235 
1236  /// Destroy the ConstantArrays if they are not used.
1238 
1239  /// \brief Access the object which manages optimization bisection for failure
1240  /// analysis.
1242 };
1243 
1244 }
1245 
1246 #endif
MDString * getRawGetterName() const
MachineLoop * L
static unsigned calculateHash(MDNode *N, unsigned Offset=0)
Metadata * getRawScope() const
bool operator!=(const KeyTy &that) const
static APInt getTombstoneKey()
static bool isEqual(const KeyTy &LHS, const FunctionType *RHS)
static APFloat getTombstoneKey()
bool isKeyOf(const GenericDINode *RHS) const
DenseMap< unsigned, IntegerType * > IntegerTypes
MDString * getRawIncludePath() const
static bool isEqual(const NodeTy *LHS, const NodeTy *RHS)
bool isKeyOf(const DILexicalBlock *RHS) const
StringMap< MDString, BumpPtrAllocator > MDStringCache
static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS)
Metadata * getRawTemplateParams() const
MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line, Metadata *Type, unsigned Arg, unsigned Flags, uint32_t AlignInBits)
unsigned getLine() const
static unsigned getHashValue(const KeyTy &Key)
FoldingSet< AttributeImpl > AttrsSet
KeyTy(const Type *R, const ArrayRef< Type * > &P, bool V)
static unsigned getHashValue(const KeyTy &Key)
bool isKeyOf(const MDTuple *RHS) const
Structure for hashing arbitrary MDNode operands.
MDNodeOpsKey(ArrayRef< Metadata * > Ops)
DenseMap< std::pair< const Function *, const BasicBlock * >, BlockAddress * > BlockAddresses
uint32_t getAlignInBits() const
KeyTy(const ArrayRef< Type * > &E, bool P)
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:776
bool compareOps(const NodeTy *RHS, unsigned Offset=0) const
void(* DiagnosticHandlerTy)(const DiagnosticInfo &DI, void *Context)
Defines the type of a diagnostic handler.
Definition: LLVMContext.h:142
static StructType * getTombstoneKey()
MDString * getRawName() const
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1040
Configuration point for MDNodeInfo::isEqual().
DenseMap< Value *, ValueAsMetadata * > ValuesAsMetadata
iterator end() const
Definition: ArrayRef.h:130
int64_t getCount() const
MDNodeKeyImpl(const GenericDINode *N)
Metadata * getRawFile() const
Return the raw underlying file.
bool operator==(const KeyTy &that) const
static bool isEqual(const KeyTy &LHS, const StructType *RHS)
Metadata * getRawType() const
This file contains the declarations for metadata subclasses.
bool isKeyOf(const DIMacro *RHS) const
static unsigned getHashValue(const StructType *ST)
MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line, MDString *GetterName, MDString *SetterName, unsigned Attributes, Metadata *Type)
op_iterator op_begin() const
Definition: Metadata.h:1024
static const fltSemantics & Bogus()
A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real...
Definition: APFloat.cpp:112
Metadata node.
Definition: Metadata.h:830
MDNodeOpsKey(const NodeTy *N, unsigned Offset=0)
bool isKeyOf(const DINamespace *RHS) const
DenseMap< std::pair< Type *, unsigned >, PointerType * > ASPointerTypes
MDNodeKeyImpl(const DISubrange *N)
LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler
MDNodeKeyImpl(const DITemplateTypeParameter *N)
unsigned getVirtuality(StringRef VirtualityString)
Definition: Dwarf.cpp:160
Metadata * getRawScope() const
MDNodeKeyImpl< NodeTy > KeyTy
void dropTriviallyDeadConstantArrays()
Destroy the ConstantArrays if they are not used.
MDNodeKeyImpl(ArrayRef< uint64_t > Elements)
MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
Multimap-like storage for metadata attachments for globals.
static unsigned calculateHash(GenericDINode *N)
Tuple of metadata.
Definition: Metadata.h:1072
unsigned getColumn() const
MDNodeKeyImpl(const DIEnumerator *N)
MDString * getRawName() const
bool isKeyOf(const DIBasicType *RHS) const
Metadata * getRawType() const
MDString * getRawName() const
static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS)
ConstantUniqueMap< ConstantVector > VectorConstantsTy
static NodeTy * getEmptyKey()
MDString * getRawDirectory() const
void set(unsigned ID, MDNode &MD)
Set an attachment to a particular node.
Definition: Metadata.cpp:1064
The address of a basic block.
Definition: Constants.h:822
DenseMap< const Instruction *, MDAttachmentMap > InstructionMetadata
Collection of per-instruction metadata used in this context.
MDString * getRawHeader() const
MDNodeKeyImpl(const DIGlobalVariable *N)
static unsigned getHashValue(const APFloat &Key)
MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File, Metadata *Elements)
struct fuzzer::@269 Flags
static bool isEqual(const APInt &LHS, const APInt &RHS)
OptBisect & getOptBisect()
Access the object which manages optimization bisection for failure analysis.
unsigned getTag() const
Class to represent struct types.
Definition: DerivedTypes.h:199
MDString * getRawName() const
Array subrange.
KeyTy(const FunctionType *FT)
FoldingSet< AttributeSetImpl > AttrsLists
bool isKeyOf(const DIGlobalVariableExpression *RHS) const
uint64_t VAL
Used to store the <= 64 bits integer value.
Definition: APInt.h:83
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams, MDString *Identifier)
MDNodeKeyImpl(const DIBasicType *N)
MDString * getRawConfigurationMacros() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:32
unsigned getLine() const
ConstantUniqueMap< ConstantArray > ArrayConstantsTy
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
bool DiscardValueNames
Flag to indicate if Value (other than GlobalValue) retains their name or not.
std::vector< MDNode * > DistinctMDNodes
unsigned getMacinfoType() const
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, Metadata *ExtraData)
DenseMap< const Value *, ValueName * > ValueNames
bool getExportSymbols() const
DIFile::ChecksumKind CSKind
BumpPtrAllocator TypeAllocator
TypeAllocator - All dynamically allocated types are allocated from this.
This file implements a class to represent arbitrary precision integral constant values and operations...
static unsigned getHashValue(const FunctionType *FT)
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:60
static StructType * getEmptyKey()
ConstantUniqueMap< InlineAsm > InlineAsms
Metadata * getRawFile() const
MDNodeKeyImpl(const DISubprogram *N)
Metadata * getRawStaticDataMemberDeclaration() const
MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *ConfigurationMacros, MDString *IncludePath, MDString *ISysRoot)
void erase(unsigned ID)
Definition: Metadata.cpp:1120
Subprogram description.
Class to represent function types.
Definition: DerivedTypes.h:102
int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA, int ExistingIdx)
bool isKeyOf(const DIObjCProperty *RHS) const
MDNodeSubsetEqualImpl< NodeTy > SubsetEqualTy
LLVMContextImpl(LLVMContext &C)
MDNodeKeyImpl(const DIMacroFile *N)
Class to represent array types.
Definition: DerivedTypes.h:345
Enumeration value.
std::unique_ptr< ConstantTokenNone > TheNoneToken
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4132
ArrayConstantsTy ArrayConstants
unsigned getLine() const
MDString * getRawName() const
Debug location.
DenseMap< std::pair< Type *, unsigned >, VectorType * > VectorTypes
MDNodeKeyImpl(MDString *Name, Metadata *Type)
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:141
unsigned getLine() const
DenseSet< FunctionType *, FunctionTypeKeyInfo > FunctionTypeSet
Class to represent pointers.
Definition: DerivedTypes.h:443
MDString * getRawChecksum() const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
MDNodeKeyImpl(ArrayRef< Metadata * > Ops)
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * >> &Result) const
Copy out all the attachments.
Definition: Metadata.cpp:1100
MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line, MDString *Name)
LLVMContext::YieldCallbackTy YieldCallback
Metadata * getRawScope() const
MDString * getRawName() const
unsigned getLine() const
unsigned getRuntimeLang() const
static ChecksumKind getChecksumKind(StringRef CSKindStr)
DenseMap< PointerType *, std::unique_ptr< ConstantPointerNull > > CPNConstants
This class implements a mechanism to disable passes and individual optimizations at compile time base...
Definition: OptBisect.h:28
#define P(N)
StringMap< unsigned > CustomMDKindNames
CustomMDKindNames - Map to hold the metadata string to ID mapping.
MDString * getRawFilename() const
Metadata * getRawFile() const
MDNodeKeyImpl< NodeTy > KeyTy
static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS)
MDNodeKeyImpl(Metadata *Variable, Metadata *Expression)
MDString * getRawValue() const
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:48
StringMapEntry< uint32_t > * getOrInsertBundleTag(StringRef Tag)
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
ConstantUniqueMap< ConstantStruct > StructConstantsTy
bool isKeyOf(const DIExpression *RHS) const
static unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI)
Get the size in bits of Reg.
bool bitwiseIsEqual(const APFloat &RHS) const
Definition: APFloat.h:1022
Metadata * getRawType() const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
unsigned getHash() const
bool isKeyOf(const DILocalVariable *RHS) const
MDNodeKeyImpl(const DIExpression *N)
static unsigned calculateHash(MDTuple *N)
MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value)
DIFlags getFlags() const
StringMap< uint32_t > BundleTagCache
A set of interned tags for operand bundles.
unsigned getLine() const
static bool isEqual(const FunctionType *LHS, const FunctionType *RHS)
MDNodeKeyImpl(const DIObjCProperty *N)
MDNodeKeyImpl(const DISubroutineType *N)
A pair of DIGlobalVariable and DIExpression.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
uint32_t Offset
bool operator!=(const KeyTy &that) const
Metadata * getRawElements() const
MDString * getRawISysRoot() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1255
This file defines various helper methods and classes used by LLVMContextImpl for creating and managin...
ValueHandlesTy ValueHandles
iterator begin() const
Definition: ArrayRef.h:129
MDNodeKeyImpl(const DILexicalBlockFile *N)
MDNodeKeyImpl(const DICompositeType *N)
static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS)
uint32_t getAlignInBits() const
bool isKeyOf(const DIMacroFile *RHS) const
unsigned getEncoding() const
unsigned getArg() const
Class to represent integer types.
Definition: DerivedTypes.h:39
uint64_t getOffsetInBits() const
static FunctionType * getEmptyKey()
MDNodeKeyImpl(const DIDerivedType *N)
unsigned getAttributes() const
static unsigned getHashValue(const NodeTy *N)
bool isKeyOf(const DIImportedEntity *RHS) const
DenseSet< StructType *, AnonStructTypeKeyInfo > StructTypeSet
DenseMap< APInt, std::unique_ptr< ConstantInt >, DenseMapAPIntKeyInfo > IntMapTy
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
static bool isEqual(const APFloat &LHS, const APFloat &RHS)
uint32_t getOperandBundleTagID(StringRef Tag) const
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
Definition: FoldingSet.h:419
VectorConstantsTy VectorConstants
bool isKeyOf(const DIModule *RHS) const
static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope, const MDString *LinkageName, const DISubprogram *RHS)
Subprograms compare equal if they declare the same function in an ODR type.
MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex, int ThisAdjustment, unsigned Flags, bool IsOptimized, Metadata *Unit, Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables)
An imported module (C++ using directive or similar).
unsigned getTag(StringRef TagString)
Definition: Dwarf.cpp:32
static bool isEqual(const KeyTy &LHS, const NodeTy *RHS)
bool isKeyOf(const DISubprogram *RHS) const
Metadata * getRawScope() const
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
ArrayRef< uint64_t > getElements() const
static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS)
DenseMap< const GlobalObject *, MDGlobalAttachmentMap > GlobalObjectMetadata
Collection of per-GlobalObject metadata used in this context.
Metadata * getRawBaseType() const
unsigned getTag() const
This is the shared class of boolean and integer constants.
Definition: Constants.h:88
MDString * getRawName() const
DIFlags getFlags() const
static NodeTy * getTombstoneKey()
MDNodeKeyImpl(const DIGlobalVariableExpression *N)
Metadata * getRawInlinedAt() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
MDNodeKeyImpl(MDString *Filename, MDString *Directory, DIFile::ChecksumKind CSKind, MDString *Checksum)
MDNode * lookup(unsigned ID) const
Get a particular attachment (if any).
Definition: Metadata.cpp:1093
MDString * getRawLinkageName() const
FunctionTypeSet FunctionTypes
int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx)
int64_t getValue() const
bool isKeyOf(const DILocation *RHS) const
MDNodeKeyImpl(int64_t Value, MDString *Name)
Metadata * getRawEntity() const
DWARF expression.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
SmallPtrSet< Module *, 4 > OwnedModules
OwnedModules - The set of modules instantiated in this context, and which will be automatically delet...
MDNodeKeyImpl(const DITemplateValueParameter *N)
void(* InlineAsmDiagHandlerTy)(const SMDiagnostic &, void *Context, unsigned LocCookie)
Definition: LLVMContext.h:136
bool isKeyOf(const DITemplateTypeParameter *RHS) const
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:223
MDNodeKeyImpl(const DINamespace *N)
Class to represent vector types.
Definition: DerivedTypes.h:369
static bool isEqual(const StructType *LHS, const StructType *RHS)
Class for arbitrary precision integers.
Definition: APInt.h:77
unsigned getDiscriminator() const
void erase(unsigned ID)
Remove an attachment.
Definition: Metadata.cpp:1074
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:602
DenseMap< APFloat, std::unique_ptr< ConstantFP >, DenseMapAPFloatKeyInfo > FPMapTy
void insert(unsigned ID, MDNode &MD)
Definition: Metadata.cpp:1109
A (clang) module that has been imported by the compile unit.
MDNodeKeyImpl(int64_t Count, int64_t LowerBound)
DenseMapInfo for MDNode subclasses.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:480
static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS)
Generic tagged DWARF-like metadata node.
MDNodeKeyImpl(const DILocalVariable *N)
bool isKeyOf(const DIDerivedType *RHS) const
bool isKeyOf(const DIEnumerator *RHS) const
MDNodeKeyImpl(const DIImportedEntity *N)
static FunctionType * getTombstoneKey()
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, Metadata *Value)
MDNodeKeyImpl(const DILocation *L)
Type array for a subprogram.
StructTypeSet AnonStructTypes
Metadata * getRawScope() const
DenseMap< Value *, ValueHandleBase * > ValueHandlesTy
ValueHandles - This map keeps track of all of the value handles that are watching a Value*...
Metadata * getRawScope() const
static unsigned getHashValue(const APInt &Key)
DenseMap< std::pair< const char *, unsigned >, unsigned > DiscriminatorTable
DiscriminatorTable - This table maps file:line locations to an integer representing the next DWARF pa...
StringMap< StructType * > NamedStructTypes
static bool isODRMember(unsigned Tag, const Metadata *Scope, const MDString *Name, const DIDerivedType *RHS)
Subprograms compare equal if they declare the same function in an ODR type.
std::unique_ptr< yaml::Output > DiagnosticsOutputFile
#define N
bool isKeyOf(const DICompositeType *RHS) const
MDNodeKeyImpl< DIDerivedType > KeyTy
DenseMap< const Function *, std::string > GCNames
Maintain the GC name for each function.
Metadata * getRawElements() const
MDString * getRawIdentifier() const
bool isKeyOf(const DIGlobalVariable *RHS) const
uint64_t getSizeInBits() const
DenseMap< Type *, std::unique_ptr< ConstantAggregateZero > > CAZConstants
MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding)
bool operator==(const KeyTy &that) const
bool isKeyOf(const DITemplateValueParameter *RHS) const
MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt)
ConstantUniqueMap< ConstantExpr > ExprConstants
AttributeSet getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef< Metadata * > DwarfOps)
Metadata * getRawFile() const
Metadata * getRawScope() const
std::vector< uint8_t > Unit
Definition: FuzzerDefs.h:71
bool isKeyOf(const DIFile *RHS) const
MDNodeKeyImpl(Metadata *Scope, Metadata *File, MDString *Name, unsigned Line, bool ExportSymbols)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * >> &Result) const
Appends all attachments for the global to Result, sorting by attachment ID.
Definition: Metadata.cpp:1133
MDString * getRawName() const
MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, Metadata *StaticDataMemberDeclaration, uint32_t AlignInBits)
StructConstantsTy StructConstants
LLVM Value Representation.
Definition: Value.h:71
DenseMap< Type *, std::unique_ptr< UndefValue > > UVConstants
void remove_if(PredTy shouldRemove)
Erase matching attachments.
unsigned getLine() const
MDNodeKeyImpl(const DILexicalBlock *N)
unsigned getLine() const
bool isKeyOf(const DILexicalBlockFile *RHS) const
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:23
FoldingSet< AttributeSetNode > AttrsSetNodes
LLVMContext::DiagnosticHandlerTy DiagnosticHandler
void(* YieldCallbackTy)(LLVMContext *Context, void *OpaqueHandle)
Defines the type of a yield callback.
Definition: LLVMContext.h:146
void getOperandBundleTags(SmallVectorImpl< StringRef > &Tags) const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
A single uniqued string.
Definition: Metadata.h:586
MDString * getRawName() const
int64_t getLowerBound() const
DenseMap< Type *, PointerType * > PointerTypes
MDString * getRawSetterName() const
bool isKeyOf(const DISubrange *RHS) const
Map-like storage for metadata attachments.
StringMap< ConstantDataSequential * > CDSConstants
Optional< DenseMap< const MDString *, DICompositeType * > > DITypeMap
Root of the metadata hierarchy.
Definition: Metadata.h:55
MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
bool isKeyOf(const DISubroutineType *RHS) const
StringSet SectionStrings
Stable collection of section strings.
static unsigned getHashValue(const KeyTy &Key)
Basic type, like 'int' or 'float'.
Metadata * getRawTypeArray() const
MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray)
Metadata * getRawVTableHolder() const