1 //===-- LLVMContextImpl.h - The LLVMContextImpl opaque class ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares LLVMContextImpl, the opaque implementation
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_IR_LLVMCONTEXTIMPL_H
16 #define LLVM_LIB_IR_LLVMCONTEXTIMPL_H
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"
31 #include "llvm/IR/DebugInfoMetadata.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"
37 #include "llvm/Support/YAMLTraits.h"
44 class DiagnosticInfoOptimizationRemark;
45 class DiagnosticInfoOptimizationRemarkMissed;
46 class DiagnosticInfoOptimizationRemarkAnalysis;
52 struct DenseMapAPIntKeyInfo {
53 static inline APInt getEmptyKey() {
58 static inline APInt getTombstoneKey() {
63 static unsigned getHashValue(const APInt &Key) {
64 return static_cast<unsigned>(hash_value(Key));
66 static bool isEqual(const APInt &LHS, const APInt &RHS) {
67 return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
71 struct DenseMapAPFloatKeyInfo {
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));
77 static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
78 return LHS.bitwiseIsEqual(RHS);
82 struct AnonStructTypeKeyInfo {
84 ArrayRef<Type*> ETypes;
86 KeyTy(const ArrayRef<Type*>& E, bool P) :
87 ETypes(E), isPacked(P) {}
88 KeyTy(const StructType *ST)
89 : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
90 bool operator==(const KeyTy& that) const {
91 if (isPacked != that.isPacked)
93 if (ETypes != that.ETypes)
97 bool operator!=(const KeyTy& that) const {
98 return !this->operator==(that);
101 static inline StructType* getEmptyKey() {
102 return DenseMapInfo<StructType*>::getEmptyKey();
104 static inline StructType* getTombstoneKey() {
105 return DenseMapInfo<StructType*>::getTombstoneKey();
107 static unsigned getHashValue(const KeyTy& Key) {
108 return hash_combine(hash_combine_range(Key.ETypes.begin(),
112 static unsigned getHashValue(const StructType *ST) {
113 return getHashValue(KeyTy(ST));
115 static bool isEqual(const KeyTy& LHS, const StructType *RHS) {
116 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
118 return LHS == KeyTy(RHS);
120 static bool isEqual(const StructType *LHS, const StructType *RHS) {
125 struct FunctionTypeKeyInfo {
127 const Type *ReturnType;
128 ArrayRef<Type*> Params;
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)
138 if (isVarArg != that.isVarArg)
140 if (Params != that.Params)
144 bool operator!=(const KeyTy& that) const {
145 return !this->operator==(that);
148 static inline FunctionType* getEmptyKey() {
149 return DenseMapInfo<FunctionType*>::getEmptyKey();
151 static inline FunctionType* getTombstoneKey() {
152 return DenseMapInfo<FunctionType*>::getTombstoneKey();
154 static unsigned getHashValue(const KeyTy& Key) {
155 return hash_combine(Key.ReturnType,
156 hash_combine_range(Key.Params.begin(),
160 static unsigned getHashValue(const FunctionType *FT) {
161 return getHashValue(KeyTy(FT));
163 static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) {
164 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
166 return LHS == KeyTy(RHS);
168 static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
173 /// \brief Structure for hashing arbitrary MDNode operands.
175 ArrayRef<Metadata *> RawOps;
176 ArrayRef<MDOperand> Ops;
181 MDNodeOpsKey(ArrayRef<Metadata *> Ops)
182 : RawOps(Ops), Hash(calculateHash(Ops)) {}
184 template <class NodeTy>
185 MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
186 : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
188 template <class NodeTy>
189 bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
190 if (getHash() != RHS->getHash())
193 assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
194 return RawOps.empty() ? compareOps(Ops, RHS, Offset)
195 : compareOps(RawOps, RHS, Offset);
198 static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
202 static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
203 if (Ops.size() != RHS->getNumOperands() - Offset)
205 return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
208 static unsigned calculateHash(ArrayRef<Metadata *> Ops);
211 unsigned getHash() const { return Hash; }
214 template <class NodeTy> struct MDNodeKeyImpl;
215 template <class NodeTy> struct MDNodeInfo;
217 /// Configuration point for MDNodeInfo::isEqual().
218 template <class NodeTy> struct MDNodeSubsetEqualImpl {
219 typedef MDNodeKeyImpl<NodeTy> KeyTy;
220 static bool isSubsetEqual(const KeyTy &LHS, const NodeTy *RHS) {
223 static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) {
228 /// \brief DenseMapInfo for MDTuple.
230 /// Note that we don't need the is-function-local bit, since that's implicit in
232 template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
233 MDNodeKeyImpl(ArrayRef<Metadata *> Ops) : MDNodeOpsKey(Ops) {}
234 MDNodeKeyImpl(const MDTuple *N) : MDNodeOpsKey(N) {}
236 bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
238 unsigned getHashValue() const { return getHash(); }
240 static unsigned calculateHash(MDTuple *N) {
241 return MDNodeOpsKey::calculateHash(N);
245 /// \brief DenseMapInfo for DILocation.
246 template <> struct MDNodeKeyImpl<DILocation> {
252 MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
254 : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {}
256 MDNodeKeyImpl(const DILocation *L)
257 : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()),
258 InlinedAt(L->getRawInlinedAt()) {}
260 bool isKeyOf(const DILocation *RHS) const {
261 return Line == RHS->getLine() && Column == RHS->getColumn() &&
262 Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt();
264 unsigned getHashValue() const {
265 return hash_combine(Line, Column, Scope, InlinedAt);
269 /// \brief DenseMapInfo for GenericDINode.
270 template <> struct MDNodeKeyImpl<GenericDINode> : MDNodeOpsKey {
273 MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef<Metadata *> DwarfOps)
274 : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
275 MDNodeKeyImpl(const GenericDINode *N)
276 : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {}
278 bool isKeyOf(const GenericDINode *RHS) const {
279 return Tag == RHS->getTag() && Header == RHS->getRawHeader() &&
283 unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
285 static unsigned calculateHash(GenericDINode *N) {
286 return MDNodeOpsKey::calculateHash(N, 1);
290 template <> struct MDNodeKeyImpl<DISubrange> {
294 MDNodeKeyImpl(int64_t Count, int64_t LowerBound)
295 : Count(Count), LowerBound(LowerBound) {}
296 MDNodeKeyImpl(const DISubrange *N)
297 : Count(N->getCount()), LowerBound(N->getLowerBound()) {}
299 bool isKeyOf(const DISubrange *RHS) const {
300 return Count == RHS->getCount() && LowerBound == RHS->getLowerBound();
302 unsigned getHashValue() const { return hash_combine(Count, LowerBound); }
305 template <> struct MDNodeKeyImpl<DIEnumerator> {
309 MDNodeKeyImpl(int64_t Value, MDString *Name) : Value(Value), Name(Name) {}
310 MDNodeKeyImpl(const DIEnumerator *N)
311 : Value(N->getValue()), Name(N->getRawName()) {}
313 bool isKeyOf(const DIEnumerator *RHS) const {
314 return Value == RHS->getValue() && Name == RHS->getRawName();
316 unsigned getHashValue() const { return hash_combine(Value, Name); }
319 template <> struct MDNodeKeyImpl<DIBasicType> {
323 uint32_t AlignInBits;
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) {}
330 MDNodeKeyImpl(const DIBasicType *N)
331 : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()),
332 AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {}
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();
340 unsigned getHashValue() const {
341 return hash_combine(Tag, Name, SizeInBits, AlignInBits, Encoding);
345 template <> struct MDNodeKeyImpl<DIDerivedType> {
353 uint64_t OffsetInBits;
354 uint32_t AlignInBits;
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,
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) {}
365 MDNodeKeyImpl(const DIDerivedType *N)
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()) {}
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();
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);
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);
398 template <> struct MDNodeSubsetEqualImpl<DIDerivedType> {
399 typedef MDNodeKeyImpl<DIDerivedType> KeyTy;
400 static bool isSubsetEqual(const KeyTy &LHS, const DIDerivedType *RHS) {
401 return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
403 static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS) {
404 return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
408 /// Subprograms compare equal if they declare the same function in an ODR
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)
416 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
417 if (!CT || !CT->getRawIdentifier())
420 // Compare to the RHS.
421 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
422 Scope == RHS->getRawScope();
426 template <> struct MDNodeKeyImpl<DICompositeType> {
434 uint64_t OffsetInBits;
435 uint32_t AlignInBits;
438 unsigned RuntimeLang;
439 Metadata *VTableHolder;
440 Metadata *TemplateParams;
441 MDString *Identifier;
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) {}
454 MDNodeKeyImpl(const DICompositeType *N)
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()) {}
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();
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,
487 template <> struct MDNodeKeyImpl<DISubroutineType> {
492 MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray)
493 : Flags(Flags), CC(CC), TypeArray(TypeArray) {}
494 MDNodeKeyImpl(const DISubroutineType *N)
495 : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {}
497 bool isKeyOf(const DISubroutineType *RHS) const {
498 return Flags == RHS->getFlags() && CC == RHS->getCC() &&
499 TypeArray == RHS->getRawTypeArray();
501 unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); }
504 template <> struct MDNodeKeyImpl<DIFile> {
507 DIFile::ChecksumKind CSKind;
510 MDNodeKeyImpl(MDString *Filename, MDString *Directory,
511 DIFile::ChecksumKind CSKind, MDString *Checksum)
512 : Filename(Filename), Directory(Directory), CSKind(CSKind),
513 Checksum(Checksum) {}
514 MDNodeKeyImpl(const DIFile *N)
515 : Filename(N->getRawFilename()), Directory(N->getRawDirectory()),
516 CSKind(N->getChecksumKind()), Checksum(N->getRawChecksum()) {}
518 bool isKeyOf(const DIFile *RHS) const {
519 return Filename == RHS->getRawFilename() &&
520 Directory == RHS->getRawDirectory() &&
521 CSKind == RHS->getChecksumKind() &&
522 Checksum == RHS->getRawChecksum();
524 unsigned getHashValue() const {
525 return hash_combine(Filename, Directory, CSKind, Checksum);
529 template <> struct MDNodeKeyImpl<DISubprogram> {
532 MDString *LinkageName;
539 Metadata *ContainingType;
541 unsigned VirtualIndex;
546 Metadata *TemplateParams;
547 Metadata *Declaration;
550 MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
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) {}
565 MDNodeKeyImpl(const DISubprogram *N)
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()) {}
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();
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);
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);
611 template <> struct MDNodeSubsetEqualImpl<DISubprogram> {
612 typedef MDNodeKeyImpl<DISubprogram> KeyTy;
613 static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
614 return isDeclarationOfODRMember(LHS.IsDefinition, LHS.Scope,
615 LHS.LinkageName, RHS);
617 static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) {
618 return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(),
619 LHS->getRawLinkageName(), RHS);
622 /// Subprograms compare equal if they declare the same function in an ODR
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)
631 auto *CT = dyn_cast_or_null<DICompositeType>(Scope);
632 if (!CT || !CT->getRawIdentifier())
635 // Compare to the RHS.
636 return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() &&
637 LinkageName == RHS->getRawLinkageName();
641 template <> struct MDNodeKeyImpl<DILexicalBlock> {
647 MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
648 : Scope(Scope), File(File), Line(Line), Column(Column) {}
649 MDNodeKeyImpl(const DILexicalBlock *N)
650 : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
651 Column(N->getColumn()) {}
653 bool isKeyOf(const DILexicalBlock *RHS) const {
654 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
655 Line == RHS->getLine() && Column == RHS->getColumn();
657 unsigned getHashValue() const {
658 return hash_combine(Scope, File, Line, Column);
662 template <> struct MDNodeKeyImpl<DILexicalBlockFile> {
665 unsigned Discriminator;
667 MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
668 : Scope(Scope), File(File), Discriminator(Discriminator) {}
669 MDNodeKeyImpl(const DILexicalBlockFile *N)
670 : Scope(N->getRawScope()), File(N->getRawFile()),
671 Discriminator(N->getDiscriminator()) {}
673 bool isKeyOf(const DILexicalBlockFile *RHS) const {
674 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
675 Discriminator == RHS->getDiscriminator();
677 unsigned getHashValue() const {
678 return hash_combine(Scope, File, Discriminator);
682 template <> struct MDNodeKeyImpl<DINamespace> {
689 MDNodeKeyImpl(Metadata *Scope, Metadata *File, MDString *Name, unsigned Line,
691 : Scope(Scope), File(File), Name(Name), Line(Line),
692 ExportSymbols(ExportSymbols) {}
693 MDNodeKeyImpl(const DINamespace *N)
694 : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getRawName()),
695 Line(N->getLine()), ExportSymbols(N->getExportSymbols()) {}
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();
702 unsigned getHashValue() const {
703 return hash_combine(Scope, File, Name, Line);
707 template <> struct MDNodeKeyImpl<DIModule> {
710 MDString *ConfigurationMacros;
711 MDString *IncludePath;
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) {}
717 MDNodeKeyImpl(const DIModule *N)
718 : Scope(N->getRawScope()), Name(N->getRawName()),
719 ConfigurationMacros(N->getRawConfigurationMacros()),
720 IncludePath(N->getRawIncludePath()), ISysRoot(N->getRawISysRoot()) {}
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();
728 unsigned getHashValue() const {
729 return hash_combine(Scope, Name,
730 ConfigurationMacros, IncludePath, ISysRoot);
734 template <> struct MDNodeKeyImpl<DITemplateTypeParameter> {
738 MDNodeKeyImpl(MDString *Name, Metadata *Type) : Name(Name), Type(Type) {}
739 MDNodeKeyImpl(const DITemplateTypeParameter *N)
740 : Name(N->getRawName()), Type(N->getRawType()) {}
742 bool isKeyOf(const DITemplateTypeParameter *RHS) const {
743 return Name == RHS->getRawName() && Type == RHS->getRawType();
745 unsigned getHashValue() const { return hash_combine(Name, Type); }
748 template <> struct MDNodeKeyImpl<DITemplateValueParameter> {
754 MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, Metadata *Value)
755 : Tag(Tag), Name(Name), Type(Type), Value(Value) {}
756 MDNodeKeyImpl(const DITemplateValueParameter *N)
757 : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
758 Value(N->getValue()) {}
760 bool isKeyOf(const DITemplateValueParameter *RHS) const {
761 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
762 Type == RHS->getRawType() && Value == RHS->getValue();
764 unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
767 template <> struct MDNodeKeyImpl<DIGlobalVariable> {
770 MDString *LinkageName;
776 Metadata *StaticDataMemberDeclaration;
777 uint32_t AlignInBits;
779 MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
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) {}
788 MDNodeKeyImpl(const DIGlobalVariable *N)
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()) {}
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 ==
803 RHS->getRawStaticDataMemberDeclaration() &&
804 AlignInBits == RHS->getAlignInBits();
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);
820 template <> struct MDNodeKeyImpl<DILocalVariable> {
828 uint32_t AlignInBits;
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) {}
835 MDNodeKeyImpl(const DILocalVariable *N)
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()) {}
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();
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);
858 template <> struct MDNodeKeyImpl<DIExpression> {
859 ArrayRef<uint64_t> Elements;
861 MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
862 MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
864 bool isKeyOf(const DIExpression *RHS) const {
865 return Elements == RHS->getElements();
867 unsigned getHashValue() const {
868 return hash_combine_range(Elements.begin(), Elements.end());
872 template <> struct MDNodeKeyImpl<DIGlobalVariableExpression> {
874 Metadata *Expression;
876 MDNodeKeyImpl(Metadata *Variable, Metadata *Expression)
877 : Variable(Variable), Expression(Expression) {}
878 MDNodeKeyImpl(const DIGlobalVariableExpression *N)
879 : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {}
881 bool isKeyOf(const DIGlobalVariableExpression *RHS) const {
882 return Variable == RHS->getRawVariable() &&
883 Expression == RHS->getRawExpression();
885 unsigned getHashValue() const { return hash_combine(Variable, Expression); }
888 template <> struct MDNodeKeyImpl<DIObjCProperty> {
892 MDString *GetterName;
893 MDString *SetterName;
897 MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line,
898 MDString *GetterName, MDString *SetterName, unsigned Attributes,
900 : Name(Name), File(File), Line(Line), GetterName(GetterName),
901 SetterName(SetterName), Attributes(Attributes), Type(Type) {}
902 MDNodeKeyImpl(const DIObjCProperty *N)
903 : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()),
904 GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()),
905 Attributes(N->getAttributes()), Type(N->getRawType()) {}
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();
913 unsigned getHashValue() const {
914 return hash_combine(Name, File, Line, GetterName, SetterName, Attributes,
919 template <> struct MDNodeKeyImpl<DIImportedEntity> {
926 MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line,
928 : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {}
929 MDNodeKeyImpl(const DIImportedEntity *N)
930 : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
931 Line(N->getLine()), Name(N->getRawName()) {}
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();
938 unsigned getHashValue() const {
939 return hash_combine(Tag, Scope, Entity, Line, Name);
943 template <> struct MDNodeKeyImpl<DIMacro> {
949 MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value)
950 : MIType(MIType), Line(Line), Name(Name), Value(Value) {}
951 MDNodeKeyImpl(const DIMacro *N)
952 : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()),
953 Value(N->getRawValue()) {}
955 bool isKeyOf(const DIMacro *RHS) const {
956 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
957 Name == RHS->getRawName() && Value == RHS->getRawValue();
959 unsigned getHashValue() const {
960 return hash_combine(MIType, Line, Name, Value);
964 template <> struct MDNodeKeyImpl<DIMacroFile> {
970 MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File,
972 : MIType(MIType), Line(Line), File(File), Elements(Elements) {}
973 MDNodeKeyImpl(const DIMacroFile *N)
974 : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()),
975 Elements(N->getRawElements()) {}
977 bool isKeyOf(const DIMacroFile *RHS) const {
978 return MIType == RHS->getMacinfoType() && Line == RHS->getLine() &&
979 File == RHS->getRawFile() && Elements == RHS->getRawElements();
981 unsigned getHashValue() const {
982 return hash_combine(MIType, Line, File, Elements);
986 /// \brief DenseMapInfo for MDNode subclasses.
987 template <class NodeTy> struct MDNodeInfo {
988 typedef MDNodeKeyImpl<NodeTy> KeyTy;
989 typedef MDNodeSubsetEqualImpl<NodeTy> SubsetEqualTy;
990 static inline NodeTy *getEmptyKey() {
991 return DenseMapInfo<NodeTy *>::getEmptyKey();
993 static inline NodeTy *getTombstoneKey() {
994 return DenseMapInfo<NodeTy *>::getTombstoneKey();
996 static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
997 static unsigned getHashValue(const NodeTy *N) {
998 return KeyTy(N).getHashValue();
1000 static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
1001 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1003 return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS);
1005 static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
1008 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1010 return SubsetEqualTy::isSubsetEqual(LHS, RHS);
1014 #define HANDLE_MDNODE_LEAF(CLASS) typedef MDNodeInfo<CLASS> CLASS##Info;
1015 #include "llvm/IR/Metadata.def"
1017 /// \brief Map-like storage for metadata attachments.
1018 class MDAttachmentMap {
1019 SmallVector<std::pair<unsigned, TrackingMDNodeRef>, 2> Attachments;
1022 bool empty() const { return Attachments.empty(); }
1023 size_t size() const { return Attachments.size(); }
1025 /// \brief Get a particular attachment (if any).
1026 MDNode *lookup(unsigned ID) const;
1028 /// \brief Set an attachment to a particular node.
1030 /// Set the \c ID attachment to \c MD, replacing the current attachment at \c
1032 void set(unsigned ID, MDNode &MD);
1034 /// \brief Remove an attachment.
1036 /// Remove the attachment at \c ID, if any.
1037 void erase(unsigned ID);
1039 /// \brief Copy out all the attachments.
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;
1045 /// \brief Erase matching attachments.
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),
1054 /// Multimap-like storage for metadata attachments for globals. This differs
1055 /// from MDAttachmentMap in that it allows multiple attachments per metadata
1057 class MDGlobalAttachmentMap {
1060 TrackingMDNodeRef Node;
1062 SmallVector<Attachment, 1> Attachments;
1065 bool empty() const { return Attachments.empty(); }
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);
1072 void insert(unsigned ID, MDNode &MD);
1073 void erase(unsigned ID);
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;
1081 class LLVMContextImpl {
1083 /// OwnedModules - The set of modules instantiated in this context, and which
1084 /// will be automatically deleted if this context is deleted.
1085 SmallPtrSet<Module*, 4> OwnedModules;
1087 LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler;
1088 void *InlineAsmDiagContext;
1090 LLVMContext::DiagnosticHandlerTy DiagnosticHandler;
1091 void *DiagnosticContext;
1092 bool RespectDiagnosticFilters;
1093 bool DiagnosticHotnessRequested;
1094 std::unique_ptr<yaml::Output> DiagnosticsOutputFile;
1096 LLVMContext::YieldCallbackTy YieldCallback;
1097 void *YieldOpaqueHandle;
1099 typedef DenseMap<APInt, std::unique_ptr<ConstantInt>, DenseMapAPIntKeyInfo>
1101 IntMapTy IntConstants;
1103 typedef DenseMap<APFloat, std::unique_ptr<ConstantFP>, DenseMapAPFloatKeyInfo>
1105 FPMapTy FPConstants;
1107 FoldingSet<AttributeImpl> AttrsSet;
1108 FoldingSet<AttributeSetImpl> AttrsLists;
1109 FoldingSet<AttributeSetNode> AttrsSetNodes;
1111 StringMap<MDString, BumpPtrAllocator> MDStringCache;
1112 DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
1113 DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
1115 DenseMap<const Value*, ValueName*> ValueNames;
1117 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
1118 DenseSet<CLASS *, CLASS##Info> CLASS##s;
1119 #include "llvm/IR/Metadata.def"
1121 // Optional map for looking up composite types by identifier.
1122 Optional<DenseMap<const MDString *, DICompositeType *>> DITypeMap;
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;
1130 DenseMap<Type *, std::unique_ptr<ConstantAggregateZero>> CAZConstants;
1132 typedef ConstantUniqueMap<ConstantArray> ArrayConstantsTy;
1133 ArrayConstantsTy ArrayConstants;
1135 typedef ConstantUniqueMap<ConstantStruct> StructConstantsTy;
1136 StructConstantsTy StructConstants;
1138 typedef ConstantUniqueMap<ConstantVector> VectorConstantsTy;
1139 VectorConstantsTy VectorConstants;
1141 DenseMap<PointerType *, std::unique_ptr<ConstantPointerNull>> CPNConstants;
1143 DenseMap<Type *, std::unique_ptr<UndefValue>> UVConstants;
1145 StringMap<ConstantDataSequential*> CDSConstants;
1147 DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *>
1149 ConstantUniqueMap<ConstantExpr> ExprConstants;
1151 ConstantUniqueMap<InlineAsm> InlineAsms;
1153 ConstantInt *TheTrueVal;
1154 ConstantInt *TheFalseVal;
1156 std::unique_ptr<ConstantTokenNone> TheNoneToken;
1158 // Basic type instances.
1159 Type VoidTy, LabelTy, HalfTy, FloatTy, DoubleTy, MetadataTy, TokenTy;
1160 Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
1161 IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty, Int128Ty;
1164 /// TypeAllocator - All dynamically allocated types are allocated from this.
1165 /// They live forever until the context is torn down.
1166 BumpPtrAllocator TypeAllocator;
1168 DenseMap<unsigned, IntegerType*> IntegerTypes;
1170 typedef DenseSet<FunctionType *, FunctionTypeKeyInfo> FunctionTypeSet;
1171 FunctionTypeSet FunctionTypes;
1172 typedef DenseSet<StructType *, AnonStructTypeKeyInfo> StructTypeSet;
1173 StructTypeSet AnonStructTypes;
1174 StringMap<StructType*> NamedStructTypes;
1175 unsigned NamedStructTypesUniqueID;
1177 DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes;
1178 DenseMap<std::pair<Type *, unsigned>, VectorType*> VectorTypes;
1179 DenseMap<Type*, PointerType*> PointerTypes; // Pointers in AddrSpace = 0
1180 DenseMap<std::pair<Type*, unsigned>, PointerType*> ASPointerTypes;
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.
1186 typedef DenseMap<Value*, ValueHandleBase*> ValueHandlesTy;
1187 ValueHandlesTy ValueHandles;
1189 /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
1190 StringMap<unsigned> CustomMDKindNames;
1192 /// Collection of per-instruction metadata used in this context.
1193 DenseMap<const Instruction *, MDAttachmentMap> InstructionMetadata;
1195 /// Collection of per-GlobalObject metadata used in this context.
1196 DenseMap<const GlobalObject *, MDGlobalAttachmentMap> GlobalObjectMetadata;
1198 /// Collection of per-GlobalObject sections used in this context.
1199 DenseMap<const GlobalObject *, StringRef> GlobalObjectSections;
1201 /// Stable collection of section strings.
1202 StringSet<> SectionStrings;
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.
1207 DenseMap<std::pair<const char *, unsigned>, unsigned> DiscriminatorTable;
1209 int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx);
1210 int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx);
1212 /// \brief A set of interned tags for operand bundles. The StringMap maps
1213 /// bundle tags to their IDs.
1215 /// \see LLVMContext::getOperandBundleTagID
1216 StringMap<uint32_t> BundleTagCache;
1218 StringMapEntry<uint32_t> *getOrInsertBundleTag(StringRef Tag);
1219 void getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const;
1220 uint32_t getOperandBundleTagID(StringRef Tag) const;
1222 /// Maintain the GC name for each function.
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.
1227 DenseMap<const Function*, std::string> GCNames;
1229 /// Flag to indicate if Value (other than GlobalValue) retains their name or
1231 bool DiscardValueNames = false;
1233 LLVMContextImpl(LLVMContext &C);
1236 /// Destroy the ConstantArrays if they are not used.
1237 void dropTriviallyDeadConstantArrays();
1239 /// \brief Access the object which manages optimization bisection for failure
1241 OptBisect &getOptBisect();