LLVMContextImpl.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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. #ifndef LLVM_LIB_IR_LLVMCONTEXTIMPL_H
  15. #define LLVM_LIB_IR_LLVMCONTEXTIMPL_H
  16. #include "AttributeImpl.h"
  17. #include "ConstantsContext.h"
  18. #include "llvm/ADT/APFloat.h"
  19. #include "llvm/ADT/APInt.h"
  20. #include "llvm/ADT/ArrayRef.h"
  21. #include "llvm/ADT/DenseMap.h"
  22. #include "llvm/ADT/DenseSet.h"
  23. #include "llvm/ADT/FoldingSet.h"
  24. #include "llvm/ADT/Hashing.h"
  25. #include "llvm/ADT/SmallPtrSet.h"
  26. #include "llvm/ADT/StringMap.h"
  27. #include "llvm/IR/Constants.h"
  28. #include "llvm/IR/DebugInfoMetadata.h"
  29. #include "llvm/IR/DerivedTypes.h"
  30. #include "llvm/IR/LLVMContext.h"
  31. #include "llvm/IR/Metadata.h"
  32. #include "llvm/IR/ValueHandle.h"
  33. #include <vector>
  34. namespace llvm {
  35. class ConstantInt;
  36. class ConstantFP;
  37. class DiagnosticInfoOptimizationRemark;
  38. class DiagnosticInfoOptimizationRemarkMissed;
  39. class DiagnosticInfoOptimizationRemarkAnalysis;
  40. class GCStrategy;
  41. class LLVMContext;
  42. class Type;
  43. class Value;
  44. struct DenseMapAPIntKeyInfo {
  45. static inline APInt getEmptyKey() {
  46. APInt V(nullptr, 0);
  47. V.VAL = 0;
  48. return V;
  49. }
  50. static inline APInt getTombstoneKey() {
  51. APInt V(nullptr, 0);
  52. V.VAL = 1;
  53. return V;
  54. }
  55. static unsigned getHashValue(const APInt &Key) {
  56. return static_cast<unsigned>(hash_value(Key));
  57. }
  58. static bool isEqual(const APInt &LHS, const APInt &RHS) {
  59. return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
  60. }
  61. };
  62. struct DenseMapAPFloatKeyInfo {
  63. static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus, 1); }
  64. static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus, 2); }
  65. static unsigned getHashValue(const APFloat &Key) {
  66. return static_cast<unsigned>(hash_value(Key));
  67. }
  68. static bool isEqual(const APFloat &LHS, const APFloat &RHS) {
  69. return LHS.bitwiseIsEqual(RHS);
  70. }
  71. };
  72. struct AnonStructTypeKeyInfo {
  73. struct KeyTy {
  74. ArrayRef<Type*> ETypes;
  75. bool isPacked;
  76. KeyTy(const ArrayRef<Type*>& E, bool P) :
  77. ETypes(E), isPacked(P) {}
  78. KeyTy(const StructType *ST)
  79. : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
  80. bool operator==(const KeyTy& that) const {
  81. if (isPacked != that.isPacked)
  82. return false;
  83. if (ETypes != that.ETypes)
  84. return false;
  85. return true;
  86. }
  87. bool operator!=(const KeyTy& that) const {
  88. return !this->operator==(that);
  89. }
  90. };
  91. static inline StructType* getEmptyKey() {
  92. return DenseMapInfo<StructType*>::getEmptyKey();
  93. }
  94. static inline StructType* getTombstoneKey() {
  95. return DenseMapInfo<StructType*>::getTombstoneKey();
  96. }
  97. static unsigned getHashValue(const KeyTy& Key) {
  98. return hash_combine(hash_combine_range(Key.ETypes.begin(),
  99. Key.ETypes.end()),
  100. Key.isPacked);
  101. }
  102. static unsigned getHashValue(const StructType *ST) {
  103. return getHashValue(KeyTy(ST));
  104. }
  105. static bool isEqual(const KeyTy& LHS, const StructType *RHS) {
  106. if (RHS == getEmptyKey() || RHS == getTombstoneKey())
  107. return false;
  108. return LHS == KeyTy(RHS);
  109. }
  110. static bool isEqual(const StructType *LHS, const StructType *RHS) {
  111. return LHS == RHS;
  112. }
  113. };
  114. struct FunctionTypeKeyInfo {
  115. struct KeyTy {
  116. const Type *ReturnType;
  117. ArrayRef<Type*> Params;
  118. bool isVarArg;
  119. KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) :
  120. ReturnType(R), Params(P), isVarArg(V) {}
  121. KeyTy(const FunctionType *FT)
  122. : ReturnType(FT->getReturnType()), Params(FT->params()),
  123. isVarArg(FT->isVarArg()) {}
  124. bool operator==(const KeyTy& that) const {
  125. if (ReturnType != that.ReturnType)
  126. return false;
  127. if (isVarArg != that.isVarArg)
  128. return false;
  129. if (Params != that.Params)
  130. return false;
  131. return true;
  132. }
  133. bool operator!=(const KeyTy& that) const {
  134. return !this->operator==(that);
  135. }
  136. };
  137. static inline FunctionType* getEmptyKey() {
  138. return DenseMapInfo<FunctionType*>::getEmptyKey();
  139. }
  140. static inline FunctionType* getTombstoneKey() {
  141. return DenseMapInfo<FunctionType*>::getTombstoneKey();
  142. }
  143. static unsigned getHashValue(const KeyTy& Key) {
  144. return hash_combine(Key.ReturnType,
  145. hash_combine_range(Key.Params.begin(),
  146. Key.Params.end()),
  147. Key.isVarArg);
  148. }
  149. static unsigned getHashValue(const FunctionType *FT) {
  150. return getHashValue(KeyTy(FT));
  151. }
  152. static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) {
  153. if (RHS == getEmptyKey() || RHS == getTombstoneKey())
  154. return false;
  155. return LHS == KeyTy(RHS);
  156. }
  157. static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
  158. return LHS == RHS;
  159. }
  160. };
  161. /// \brief Structure for hashing arbitrary MDNode operands.
  162. class MDNodeOpsKey {
  163. ArrayRef<Metadata *> RawOps;
  164. ArrayRef<MDOperand> Ops;
  165. unsigned Hash;
  166. protected:
  167. MDNodeOpsKey(ArrayRef<Metadata *> Ops)
  168. : RawOps(Ops), Hash(calculateHash(Ops)) {}
  169. template <class NodeTy>
  170. MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0)
  171. : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {}
  172. template <class NodeTy>
  173. bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const {
  174. if (getHash() != RHS->getHash())
  175. return false;
  176. assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?");
  177. return RawOps.empty() ? compareOps(Ops, RHS, Offset)
  178. : compareOps(RawOps, RHS, Offset);
  179. }
  180. static unsigned calculateHash(MDNode *N, unsigned Offset = 0);
  181. private:
  182. template <class T>
  183. static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) {
  184. if (Ops.size() != RHS->getNumOperands() - Offset)
  185. return false;
  186. return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset);
  187. }
  188. static unsigned calculateHash(ArrayRef<Metadata *> Ops);
  189. public:
  190. unsigned getHash() const { return Hash; }
  191. };
  192. template <class NodeTy> struct MDNodeKeyImpl;
  193. template <class NodeTy> struct MDNodeInfo;
  194. /// \brief DenseMapInfo for MDTuple.
  195. ///
  196. /// Note that we don't need the is-function-local bit, since that's implicit in
  197. /// the operands.
  198. template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey {
  199. MDNodeKeyImpl(ArrayRef<Metadata *> Ops) : MDNodeOpsKey(Ops) {}
  200. MDNodeKeyImpl(const MDTuple *N) : MDNodeOpsKey(N) {}
  201. bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); }
  202. unsigned getHashValue() const { return getHash(); }
  203. static unsigned calculateHash(MDTuple *N) {
  204. return MDNodeOpsKey::calculateHash(N);
  205. }
  206. };
  207. /// \brief DenseMapInfo for DILocation.
  208. template <> struct MDNodeKeyImpl<DILocation> {
  209. unsigned Line;
  210. unsigned Column;
  211. Metadata *Scope;
  212. Metadata *InlinedAt;
  213. MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope,
  214. Metadata *InlinedAt)
  215. : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {}
  216. MDNodeKeyImpl(const DILocation *L)
  217. : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()),
  218. InlinedAt(L->getRawInlinedAt()) {}
  219. bool isKeyOf(const DILocation *RHS) const {
  220. return Line == RHS->getLine() && Column == RHS->getColumn() &&
  221. Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt();
  222. }
  223. unsigned getHashValue() const {
  224. return hash_combine(Line, Column, Scope, InlinedAt);
  225. }
  226. };
  227. /// \brief DenseMapInfo for GenericDINode.
  228. template <> struct MDNodeKeyImpl<GenericDINode> : MDNodeOpsKey {
  229. unsigned Tag;
  230. StringRef Header;
  231. MDNodeKeyImpl(unsigned Tag, StringRef Header, ArrayRef<Metadata *> DwarfOps)
  232. : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {}
  233. MDNodeKeyImpl(const GenericDINode *N)
  234. : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getHeader()) {}
  235. bool isKeyOf(const GenericDINode *RHS) const {
  236. return Tag == RHS->getTag() && Header == RHS->getHeader() &&
  237. compareOps(RHS, 1);
  238. }
  239. unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); }
  240. static unsigned calculateHash(GenericDINode *N) {
  241. return MDNodeOpsKey::calculateHash(N, 1);
  242. }
  243. };
  244. template <> struct MDNodeKeyImpl<DISubrange> {
  245. int64_t Count;
  246. int64_t LowerBound;
  247. MDNodeKeyImpl(int64_t Count, int64_t LowerBound)
  248. : Count(Count), LowerBound(LowerBound) {}
  249. MDNodeKeyImpl(const DISubrange *N)
  250. : Count(N->getCount()), LowerBound(N->getLowerBound()) {}
  251. bool isKeyOf(const DISubrange *RHS) const {
  252. return Count == RHS->getCount() && LowerBound == RHS->getLowerBound();
  253. }
  254. unsigned getHashValue() const { return hash_combine(Count, LowerBound); }
  255. };
  256. template <> struct MDNodeKeyImpl<DIEnumerator> {
  257. int64_t Value;
  258. StringRef Name;
  259. MDNodeKeyImpl(int64_t Value, StringRef Name) : Value(Value), Name(Name) {}
  260. MDNodeKeyImpl(const DIEnumerator *N)
  261. : Value(N->getValue()), Name(N->getName()) {}
  262. bool isKeyOf(const DIEnumerator *RHS) const {
  263. return Value == RHS->getValue() && Name == RHS->getName();
  264. }
  265. unsigned getHashValue() const { return hash_combine(Value, Name); }
  266. };
  267. template <> struct MDNodeKeyImpl<DIBasicType> {
  268. unsigned Tag;
  269. StringRef Name;
  270. uint64_t SizeInBits;
  271. uint64_t AlignInBits;
  272. unsigned Encoding;
  273. MDNodeKeyImpl(unsigned Tag, StringRef Name, uint64_t SizeInBits,
  274. uint64_t AlignInBits, unsigned Encoding)
  275. : Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
  276. Encoding(Encoding) {}
  277. MDNodeKeyImpl(const DIBasicType *N)
  278. : Tag(N->getTag()), Name(N->getName()), SizeInBits(N->getSizeInBits()),
  279. AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {}
  280. bool isKeyOf(const DIBasicType *RHS) const {
  281. return Tag == RHS->getTag() && Name == RHS->getName() &&
  282. SizeInBits == RHS->getSizeInBits() &&
  283. AlignInBits == RHS->getAlignInBits() &&
  284. Encoding == RHS->getEncoding();
  285. }
  286. unsigned getHashValue() const {
  287. return hash_combine(Tag, Name, SizeInBits, AlignInBits, Encoding);
  288. }
  289. };
  290. template <> struct MDNodeKeyImpl<DIDerivedType> {
  291. unsigned Tag;
  292. StringRef Name;
  293. Metadata *File;
  294. unsigned Line;
  295. Metadata *Scope;
  296. Metadata *BaseType;
  297. uint64_t SizeInBits;
  298. uint64_t AlignInBits;
  299. uint64_t OffsetInBits;
  300. unsigned Flags;
  301. Metadata *ExtraData;
  302. MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *File, unsigned Line,
  303. Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
  304. uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
  305. Metadata *ExtraData)
  306. : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
  307. BaseType(BaseType), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
  308. OffsetInBits(OffsetInBits), Flags(Flags), ExtraData(ExtraData) {}
  309. MDNodeKeyImpl(const DIDerivedType *N)
  310. : Tag(N->getTag()), Name(N->getName()), File(N->getRawFile()),
  311. Line(N->getLine()), Scope(N->getRawScope()),
  312. BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
  313. AlignInBits(N->getAlignInBits()), OffsetInBits(N->getOffsetInBits()),
  314. Flags(N->getFlags()), ExtraData(N->getRawExtraData()) {}
  315. bool isKeyOf(const DIDerivedType *RHS) const {
  316. return Tag == RHS->getTag() && Name == RHS->getName() &&
  317. File == RHS->getRawFile() && Line == RHS->getLine() &&
  318. Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
  319. SizeInBits == RHS->getSizeInBits() &&
  320. AlignInBits == RHS->getAlignInBits() &&
  321. OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() &&
  322. ExtraData == RHS->getRawExtraData();
  323. }
  324. unsigned getHashValue() const {
  325. return hash_combine(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
  326. AlignInBits, OffsetInBits, Flags, ExtraData);
  327. }
  328. };
  329. template <> struct MDNodeKeyImpl<DICompositeType> {
  330. unsigned Tag;
  331. StringRef Name;
  332. Metadata *File;
  333. unsigned Line;
  334. Metadata *Scope;
  335. Metadata *BaseType;
  336. uint64_t SizeInBits;
  337. uint64_t AlignInBits;
  338. uint64_t OffsetInBits;
  339. unsigned Flags;
  340. Metadata *Elements;
  341. unsigned RuntimeLang;
  342. Metadata *VTableHolder;
  343. Metadata *TemplateParams;
  344. StringRef Identifier;
  345. MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *File, unsigned Line,
  346. Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
  347. uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
  348. Metadata *Elements, unsigned RuntimeLang,
  349. Metadata *VTableHolder, Metadata *TemplateParams,
  350. StringRef Identifier)
  351. : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
  352. BaseType(BaseType), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
  353. OffsetInBits(OffsetInBits), Flags(Flags), Elements(Elements),
  354. RuntimeLang(RuntimeLang), VTableHolder(VTableHolder),
  355. TemplateParams(TemplateParams), Identifier(Identifier) {}
  356. MDNodeKeyImpl(const DICompositeType *N)
  357. : Tag(N->getTag()), Name(N->getName()), File(N->getRawFile()),
  358. Line(N->getLine()), Scope(N->getRawScope()),
  359. BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
  360. AlignInBits(N->getAlignInBits()), OffsetInBits(N->getOffsetInBits()),
  361. Flags(N->getFlags()), Elements(N->getRawElements()),
  362. RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()),
  363. TemplateParams(N->getRawTemplateParams()),
  364. Identifier(N->getIdentifier()) {}
  365. bool isKeyOf(const DICompositeType *RHS) const {
  366. return Tag == RHS->getTag() && Name == RHS->getName() &&
  367. File == RHS->getRawFile() && Line == RHS->getLine() &&
  368. Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() &&
  369. SizeInBits == RHS->getSizeInBits() &&
  370. AlignInBits == RHS->getAlignInBits() &&
  371. OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() &&
  372. Elements == RHS->getRawElements() &&
  373. RuntimeLang == RHS->getRuntimeLang() &&
  374. VTableHolder == RHS->getRawVTableHolder() &&
  375. TemplateParams == RHS->getRawTemplateParams() &&
  376. Identifier == RHS->getIdentifier();
  377. }
  378. unsigned getHashValue() const {
  379. return hash_combine(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
  380. AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
  381. VTableHolder, TemplateParams, Identifier);
  382. }
  383. };
  384. template <> struct MDNodeKeyImpl<DISubroutineType> {
  385. unsigned Flags;
  386. Metadata *TypeArray;
  387. MDNodeKeyImpl(int64_t Flags, Metadata *TypeArray)
  388. : Flags(Flags), TypeArray(TypeArray) {}
  389. MDNodeKeyImpl(const DISubroutineType *N)
  390. : Flags(N->getFlags()), TypeArray(N->getRawTypeArray()) {}
  391. bool isKeyOf(const DISubroutineType *RHS) const {
  392. return Flags == RHS->getFlags() && TypeArray == RHS->getRawTypeArray();
  393. }
  394. unsigned getHashValue() const { return hash_combine(Flags, TypeArray); }
  395. };
  396. template <> struct MDNodeKeyImpl<DIFile> {
  397. StringRef Filename;
  398. StringRef Directory;
  399. MDNodeKeyImpl(StringRef Filename, StringRef Directory)
  400. : Filename(Filename), Directory(Directory) {}
  401. MDNodeKeyImpl(const DIFile *N)
  402. : Filename(N->getFilename()), Directory(N->getDirectory()) {}
  403. bool isKeyOf(const DIFile *RHS) const {
  404. return Filename == RHS->getFilename() && Directory == RHS->getDirectory();
  405. }
  406. unsigned getHashValue() const { return hash_combine(Filename, Directory); }
  407. };
  408. template <> struct MDNodeKeyImpl<DICompileUnit> {
  409. unsigned SourceLanguage;
  410. Metadata *File;
  411. StringRef Producer;
  412. bool IsOptimized;
  413. StringRef Flags;
  414. unsigned RuntimeVersion;
  415. StringRef SplitDebugFilename;
  416. unsigned EmissionKind;
  417. Metadata *EnumTypes;
  418. Metadata *RetainedTypes;
  419. Metadata *Subprograms;
  420. Metadata *GlobalVariables;
  421. Metadata *ImportedEntities;
  422. uint64_t DWOId;
  423. MDNodeKeyImpl(unsigned SourceLanguage, Metadata *File, StringRef Producer,
  424. bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
  425. StringRef SplitDebugFilename, unsigned EmissionKind,
  426. Metadata *EnumTypes, Metadata *RetainedTypes,
  427. Metadata *Subprograms, Metadata *GlobalVariables,
  428. Metadata *ImportedEntities, uint64_t DWOId)
  429. : SourceLanguage(SourceLanguage), File(File), Producer(Producer),
  430. IsOptimized(IsOptimized), Flags(Flags), RuntimeVersion(RuntimeVersion),
  431. SplitDebugFilename(SplitDebugFilename), EmissionKind(EmissionKind),
  432. EnumTypes(EnumTypes), RetainedTypes(RetainedTypes),
  433. Subprograms(Subprograms), GlobalVariables(GlobalVariables),
  434. ImportedEntities(ImportedEntities), DWOId(DWOId) {}
  435. MDNodeKeyImpl(const DICompileUnit *N)
  436. : SourceLanguage(N->getSourceLanguage()), File(N->getRawFile()),
  437. Producer(N->getProducer()), IsOptimized(N->isOptimized()),
  438. Flags(N->getFlags()), RuntimeVersion(N->getRuntimeVersion()),
  439. SplitDebugFilename(N->getSplitDebugFilename()),
  440. EmissionKind(N->getEmissionKind()), EnumTypes(N->getRawEnumTypes()),
  441. RetainedTypes(N->getRawRetainedTypes()),
  442. Subprograms(N->getRawSubprograms()),
  443. GlobalVariables(N->getRawGlobalVariables()),
  444. ImportedEntities(N->getRawImportedEntities()), DWOId(N->getDWOId()) {}
  445. bool isKeyOf(const DICompileUnit *RHS) const {
  446. return SourceLanguage == RHS->getSourceLanguage() &&
  447. File == RHS->getRawFile() && Producer == RHS->getProducer() &&
  448. IsOptimized == RHS->isOptimized() && Flags == RHS->getFlags() &&
  449. RuntimeVersion == RHS->getRuntimeVersion() &&
  450. SplitDebugFilename == RHS->getSplitDebugFilename() &&
  451. EmissionKind == RHS->getEmissionKind() &&
  452. EnumTypes == RHS->getRawEnumTypes() &&
  453. RetainedTypes == RHS->getRawRetainedTypes() &&
  454. Subprograms == RHS->getRawSubprograms() &&
  455. GlobalVariables == RHS->getRawGlobalVariables() &&
  456. ImportedEntities == RHS->getRawImportedEntities() &&
  457. DWOId == RHS->getDWOId();
  458. }
  459. unsigned getHashValue() const {
  460. return hash_combine(SourceLanguage, File, Producer, IsOptimized, Flags,
  461. RuntimeVersion, SplitDebugFilename, EmissionKind,
  462. EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
  463. ImportedEntities, DWOId);
  464. }
  465. };
  466. template <> struct MDNodeKeyImpl<DISubprogram> {
  467. Metadata *Scope;
  468. StringRef Name;
  469. StringRef LinkageName;
  470. Metadata *File;
  471. unsigned Line;
  472. Metadata *Type;
  473. bool IsLocalToUnit;
  474. bool IsDefinition;
  475. unsigned ScopeLine;
  476. Metadata *ContainingType;
  477. unsigned Virtuality;
  478. unsigned VirtualIndex;
  479. unsigned Flags;
  480. bool IsOptimized;
  481. Metadata *Function;
  482. Metadata *TemplateParams;
  483. Metadata *Declaration;
  484. Metadata *Variables;
  485. MDNodeKeyImpl(Metadata *Scope, StringRef Name, StringRef LinkageName,
  486. Metadata *File, unsigned Line, Metadata *Type,
  487. bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
  488. Metadata *ContainingType, unsigned Virtuality,
  489. unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
  490. Metadata *Function, Metadata *TemplateParams,
  491. Metadata *Declaration, Metadata *Variables)
  492. : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
  493. Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
  494. IsDefinition(IsDefinition), ScopeLine(ScopeLine),
  495. ContainingType(ContainingType), Virtuality(Virtuality),
  496. VirtualIndex(VirtualIndex), Flags(Flags), IsOptimized(IsOptimized),
  497. Function(Function), TemplateParams(TemplateParams),
  498. Declaration(Declaration), Variables(Variables) {}
  499. MDNodeKeyImpl(const DISubprogram *N)
  500. : Scope(N->getRawScope()), Name(N->getName()),
  501. LinkageName(N->getLinkageName()), File(N->getRawFile()),
  502. Line(N->getLine()), Type(N->getRawType()),
  503. IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
  504. ScopeLine(N->getScopeLine()), ContainingType(N->getRawContainingType()),
  505. Virtuality(N->getVirtuality()), VirtualIndex(N->getVirtualIndex()),
  506. Flags(N->getFlags()), IsOptimized(N->isOptimized()),
  507. Function(N->getRawFunction()),
  508. TemplateParams(N->getRawTemplateParams()),
  509. Declaration(N->getRawDeclaration()), Variables(N->getRawVariables()) {}
  510. bool isKeyOf(const DISubprogram *RHS) const {
  511. return Scope == RHS->getRawScope() && Name == RHS->getName() &&
  512. LinkageName == RHS->getLinkageName() && File == RHS->getRawFile() &&
  513. Line == RHS->getLine() && Type == RHS->getRawType() &&
  514. IsLocalToUnit == RHS->isLocalToUnit() &&
  515. IsDefinition == RHS->isDefinition() &&
  516. ScopeLine == RHS->getScopeLine() &&
  517. ContainingType == RHS->getRawContainingType() &&
  518. Virtuality == RHS->getVirtuality() &&
  519. VirtualIndex == RHS->getVirtualIndex() && Flags == RHS->getFlags() &&
  520. IsOptimized == RHS->isOptimized() &&
  521. Function == RHS->getRawFunction() &&
  522. TemplateParams == RHS->getRawTemplateParams() &&
  523. Declaration == RHS->getRawDeclaration() &&
  524. Variables == RHS->getRawVariables();
  525. }
  526. unsigned getHashValue() const {
  527. return hash_combine(Scope, Name, LinkageName, File, Line, Type,
  528. IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
  529. Virtuality, VirtualIndex, Flags, IsOptimized, Function,
  530. TemplateParams, Declaration, Variables);
  531. }
  532. };
  533. template <> struct MDNodeKeyImpl<DILexicalBlock> {
  534. Metadata *Scope;
  535. Metadata *File;
  536. unsigned Line;
  537. unsigned Column;
  538. MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column)
  539. : Scope(Scope), File(File), Line(Line), Column(Column) {}
  540. MDNodeKeyImpl(const DILexicalBlock *N)
  541. : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()),
  542. Column(N->getColumn()) {}
  543. bool isKeyOf(const DILexicalBlock *RHS) const {
  544. return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
  545. Line == RHS->getLine() && Column == RHS->getColumn();
  546. }
  547. unsigned getHashValue() const {
  548. return hash_combine(Scope, File, Line, Column);
  549. }
  550. };
  551. template <> struct MDNodeKeyImpl<DILexicalBlockFile> {
  552. Metadata *Scope;
  553. Metadata *File;
  554. unsigned Discriminator;
  555. MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator)
  556. : Scope(Scope), File(File), Discriminator(Discriminator) {}
  557. MDNodeKeyImpl(const DILexicalBlockFile *N)
  558. : Scope(N->getRawScope()), File(N->getRawFile()),
  559. Discriminator(N->getDiscriminator()) {}
  560. bool isKeyOf(const DILexicalBlockFile *RHS) const {
  561. return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
  562. Discriminator == RHS->getDiscriminator();
  563. }
  564. unsigned getHashValue() const {
  565. return hash_combine(Scope, File, Discriminator);
  566. }
  567. };
  568. template <> struct MDNodeKeyImpl<DINamespace> {
  569. Metadata *Scope;
  570. Metadata *File;
  571. StringRef Name;
  572. unsigned Line;
  573. MDNodeKeyImpl(Metadata *Scope, Metadata *File, StringRef Name, unsigned Line)
  574. : Scope(Scope), File(File), Name(Name), Line(Line) {}
  575. MDNodeKeyImpl(const DINamespace *N)
  576. : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getName()),
  577. Line(N->getLine()) {}
  578. bool isKeyOf(const DINamespace *RHS) const {
  579. return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
  580. Name == RHS->getName() && Line == RHS->getLine();
  581. }
  582. unsigned getHashValue() const {
  583. return hash_combine(Scope, File, Name, Line);
  584. }
  585. };
  586. template <> struct MDNodeKeyImpl<DIModule> {
  587. Metadata *Scope;
  588. StringRef Name;
  589. StringRef ConfigurationMacros;
  590. StringRef IncludePath;
  591. StringRef ISysRoot;
  592. MDNodeKeyImpl(Metadata *Scope, StringRef Name,
  593. StringRef ConfigurationMacros,
  594. StringRef IncludePath,
  595. StringRef ISysRoot)
  596. : Scope(Scope), Name(Name), ConfigurationMacros(ConfigurationMacros),
  597. IncludePath(IncludePath), ISysRoot(ISysRoot) {}
  598. MDNodeKeyImpl(const DIModule *N)
  599. : Scope(N->getRawScope()), Name(N->getName()),
  600. ConfigurationMacros(N->getConfigurationMacros()),
  601. IncludePath(N->getIncludePath()), ISysRoot(N->getISysRoot()) {}
  602. bool isKeyOf(const DIModule *RHS) const {
  603. return Scope == RHS->getRawScope() && Name == RHS->getName() &&
  604. ConfigurationMacros == RHS->getConfigurationMacros() &&
  605. IncludePath == RHS->getIncludePath() &&
  606. ISysRoot == RHS->getISysRoot();
  607. }
  608. unsigned getHashValue() const {
  609. return hash_combine(Scope, Name,
  610. ConfigurationMacros, IncludePath, ISysRoot);
  611. }
  612. };
  613. template <> struct MDNodeKeyImpl<DITemplateTypeParameter> {
  614. StringRef Name;
  615. Metadata *Type;
  616. MDNodeKeyImpl(StringRef Name, Metadata *Type) : Name(Name), Type(Type) {}
  617. MDNodeKeyImpl(const DITemplateTypeParameter *N)
  618. : Name(N->getName()), Type(N->getRawType()) {}
  619. bool isKeyOf(const DITemplateTypeParameter *RHS) const {
  620. return Name == RHS->getName() && Type == RHS->getRawType();
  621. }
  622. unsigned getHashValue() const { return hash_combine(Name, Type); }
  623. };
  624. template <> struct MDNodeKeyImpl<DITemplateValueParameter> {
  625. unsigned Tag;
  626. StringRef Name;
  627. Metadata *Type;
  628. Metadata *Value;
  629. MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *Type, Metadata *Value)
  630. : Tag(Tag), Name(Name), Type(Type), Value(Value) {}
  631. MDNodeKeyImpl(const DITemplateValueParameter *N)
  632. : Tag(N->getTag()), Name(N->getName()), Type(N->getRawType()),
  633. Value(N->getValue()) {}
  634. bool isKeyOf(const DITemplateValueParameter *RHS) const {
  635. return Tag == RHS->getTag() && Name == RHS->getName() &&
  636. Type == RHS->getRawType() && Value == RHS->getValue();
  637. }
  638. unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
  639. };
  640. template <> struct MDNodeKeyImpl<DIGlobalVariable> {
  641. Metadata *Scope;
  642. StringRef Name;
  643. StringRef LinkageName;
  644. Metadata *File;
  645. unsigned Line;
  646. Metadata *Type;
  647. bool IsLocalToUnit;
  648. bool IsDefinition;
  649. Metadata *Variable;
  650. Metadata *StaticDataMemberDeclaration;
  651. MDNodeKeyImpl(Metadata *Scope, StringRef Name, StringRef LinkageName,
  652. Metadata *File, unsigned Line, Metadata *Type,
  653. bool IsLocalToUnit, bool IsDefinition, Metadata *Variable,
  654. Metadata *StaticDataMemberDeclaration)
  655. : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
  656. Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
  657. IsDefinition(IsDefinition), Variable(Variable),
  658. StaticDataMemberDeclaration(StaticDataMemberDeclaration) {}
  659. MDNodeKeyImpl(const DIGlobalVariable *N)
  660. : Scope(N->getRawScope()), Name(N->getName()),
  661. LinkageName(N->getLinkageName()), File(N->getRawFile()),
  662. Line(N->getLine()), Type(N->getRawType()),
  663. IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
  664. Variable(N->getRawVariable()),
  665. StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()) {}
  666. bool isKeyOf(const DIGlobalVariable *RHS) const {
  667. return Scope == RHS->getRawScope() && Name == RHS->getName() &&
  668. LinkageName == RHS->getLinkageName() && File == RHS->getRawFile() &&
  669. Line == RHS->getLine() && Type == RHS->getRawType() &&
  670. IsLocalToUnit == RHS->isLocalToUnit() &&
  671. IsDefinition == RHS->isDefinition() &&
  672. Variable == RHS->getRawVariable() &&
  673. StaticDataMemberDeclaration ==
  674. RHS->getRawStaticDataMemberDeclaration();
  675. }
  676. unsigned getHashValue() const {
  677. return hash_combine(Scope, Name, LinkageName, File, Line, Type,
  678. IsLocalToUnit, IsDefinition, Variable,
  679. StaticDataMemberDeclaration);
  680. }
  681. };
  682. template <> struct MDNodeKeyImpl<DILocalVariable> {
  683. unsigned Tag;
  684. Metadata *Scope;
  685. StringRef Name;
  686. Metadata *File;
  687. unsigned Line;
  688. Metadata *Type;
  689. unsigned Arg;
  690. unsigned Flags;
  691. MDNodeKeyImpl(unsigned Tag, Metadata *Scope, StringRef Name, Metadata *File,
  692. unsigned Line, Metadata *Type, unsigned Arg, unsigned Flags)
  693. : Tag(Tag), Scope(Scope), Name(Name), File(File), Line(Line), Type(Type),
  694. Arg(Arg), Flags(Flags) {}
  695. MDNodeKeyImpl(const DILocalVariable *N)
  696. : Tag(N->getTag()), Scope(N->getRawScope()), Name(N->getName()),
  697. File(N->getRawFile()), Line(N->getLine()), Type(N->getRawType()),
  698. Arg(N->getArg()), Flags(N->getFlags()) {}
  699. bool isKeyOf(const DILocalVariable *RHS) const {
  700. return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
  701. Name == RHS->getName() && File == RHS->getRawFile() &&
  702. Line == RHS->getLine() && Type == RHS->getRawType() &&
  703. Arg == RHS->getArg() && Flags == RHS->getFlags();
  704. }
  705. unsigned getHashValue() const {
  706. return hash_combine(Tag, Scope, Name, File, Line, Type, Arg, Flags);
  707. }
  708. };
  709. template <> struct MDNodeKeyImpl<DIExpression> {
  710. ArrayRef<uint64_t> Elements;
  711. MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {}
  712. MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {}
  713. bool isKeyOf(const DIExpression *RHS) const {
  714. return Elements == RHS->getElements();
  715. }
  716. unsigned getHashValue() const {
  717. return hash_combine_range(Elements.begin(), Elements.end());
  718. }
  719. };
  720. template <> struct MDNodeKeyImpl<DIObjCProperty> {
  721. StringRef Name;
  722. Metadata *File;
  723. unsigned Line;
  724. StringRef GetterName;
  725. StringRef SetterName;
  726. unsigned Attributes;
  727. Metadata *Type;
  728. MDNodeKeyImpl(StringRef Name, Metadata *File, unsigned Line,
  729. StringRef GetterName, StringRef SetterName, unsigned Attributes,
  730. Metadata *Type)
  731. : Name(Name), File(File), Line(Line), GetterName(GetterName),
  732. SetterName(SetterName), Attributes(Attributes), Type(Type) {}
  733. MDNodeKeyImpl(const DIObjCProperty *N)
  734. : Name(N->getName()), File(N->getRawFile()), Line(N->getLine()),
  735. GetterName(N->getGetterName()), SetterName(N->getSetterName()),
  736. Attributes(N->getAttributes()), Type(N->getRawType()) {}
  737. bool isKeyOf(const DIObjCProperty *RHS) const {
  738. return Name == RHS->getName() && File == RHS->getRawFile() &&
  739. Line == RHS->getLine() && GetterName == RHS->getGetterName() &&
  740. SetterName == RHS->getSetterName() &&
  741. Attributes == RHS->getAttributes() && Type == RHS->getRawType();
  742. }
  743. unsigned getHashValue() const {
  744. return hash_combine(Name, File, Line, GetterName, SetterName, Attributes,
  745. Type);
  746. }
  747. };
  748. template <> struct MDNodeKeyImpl<DIImportedEntity> {
  749. unsigned Tag;
  750. Metadata *Scope;
  751. Metadata *Entity;
  752. unsigned Line;
  753. StringRef Name;
  754. MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line,
  755. StringRef Name)
  756. : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {}
  757. MDNodeKeyImpl(const DIImportedEntity *N)
  758. : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
  759. Line(N->getLine()), Name(N->getName()) {}
  760. bool isKeyOf(const DIImportedEntity *RHS) const {
  761. return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
  762. Entity == RHS->getRawEntity() && Line == RHS->getLine() &&
  763. Name == RHS->getName();
  764. }
  765. unsigned getHashValue() const {
  766. return hash_combine(Tag, Scope, Entity, Line, Name);
  767. }
  768. };
  769. /// \brief DenseMapInfo for MDNode subclasses.
  770. template <class NodeTy> struct MDNodeInfo {
  771. typedef MDNodeKeyImpl<NodeTy> KeyTy;
  772. static inline NodeTy *getEmptyKey() {
  773. return DenseMapInfo<NodeTy *>::getEmptyKey();
  774. }
  775. static inline NodeTy *getTombstoneKey() {
  776. return DenseMapInfo<NodeTy *>::getTombstoneKey();
  777. }
  778. static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); }
  779. static unsigned getHashValue(const NodeTy *N) {
  780. return KeyTy(N).getHashValue();
  781. }
  782. static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) {
  783. if (RHS == getEmptyKey() || RHS == getTombstoneKey())
  784. return false;
  785. return LHS.isKeyOf(RHS);
  786. }
  787. static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) {
  788. return LHS == RHS;
  789. }
  790. };
  791. #define HANDLE_MDNODE_LEAF(CLASS) typedef MDNodeInfo<CLASS> CLASS##Info;
  792. #include "llvm/IR/Metadata.def"
  793. /// \brief Map-like storage for metadata attachments.
  794. class MDAttachmentMap {
  795. SmallVector<std::pair<unsigned, TrackingMDNodeRef>, 2> Attachments;
  796. public:
  797. bool empty() const { return Attachments.empty(); }
  798. size_t size() const { return Attachments.size(); }
  799. /// \brief Get a particular attachment (if any).
  800. MDNode *lookup(unsigned ID) const;
  801. /// \brief Set an attachment to a particular node.
  802. ///
  803. /// Set the \c ID attachment to \c MD, replacing the current attachment at \c
  804. /// ID (if anyway).
  805. void set(unsigned ID, MDNode &MD);
  806. /// \brief Remove an attachment.
  807. ///
  808. /// Remove the attachment at \c ID, if any.
  809. void erase(unsigned ID);
  810. /// \brief Copy out all the attachments.
  811. ///
  812. /// Copies all the current attachments into \c Result, sorting by attachment
  813. /// ID. This function does \em not clear \c Result.
  814. void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
  815. /// \brief Erase matching attachments.
  816. ///
  817. /// Erases all attachments matching the \c shouldRemove predicate.
  818. template <class PredTy> void remove_if(PredTy shouldRemove) {
  819. Attachments.erase(
  820. std::remove_if(Attachments.begin(), Attachments.end(), shouldRemove),
  821. Attachments.end());
  822. }
  823. };
  824. class LLVMContextImpl {
  825. public:
  826. /// OwnedModules - The set of modules instantiated in this context, and which
  827. /// will be automatically deleted if this context is deleted.
  828. SmallPtrSet<Module*, 4> OwnedModules;
  829. LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler;
  830. void *InlineAsmDiagContext;
  831. LLVMContext::DiagnosticHandlerTy DiagnosticHandler;
  832. void *DiagnosticContext;
  833. bool RespectDiagnosticFilters;
  834. LLVMContext::YieldCallbackTy YieldCallback;
  835. void *YieldOpaqueHandle;
  836. typedef DenseMap<APInt, ConstantInt *, DenseMapAPIntKeyInfo> IntMapTy;
  837. IntMapTy IntConstants;
  838. typedef DenseMap<APFloat, ConstantFP *, DenseMapAPFloatKeyInfo> FPMapTy;
  839. FPMapTy FPConstants;
  840. FoldingSet<AttributeImpl> AttrsSet;
  841. FoldingSet<AttributeSetImpl> AttrsLists;
  842. FoldingSet<AttributeSetNode> AttrsSetNodes;
  843. StringMap<MDString> MDStringCache;
  844. DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
  845. DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
  846. DenseMap<const Value*, ValueName*> ValueNames;
  847. #define HANDLE_MDNODE_LEAF(CLASS) DenseSet<CLASS *, CLASS##Info> CLASS##s;
  848. #include "llvm/IR/Metadata.def"
  849. // MDNodes may be uniqued or not uniqued. When they're not uniqued, they
  850. // aren't in the MDNodeSet, but they're still shared between objects, so no
  851. // one object can destroy them. This set allows us to at least destroy them
  852. // on Context destruction.
  853. SmallPtrSet<MDNode *, 1> DistinctMDNodes;
  854. DenseMap<Type*, ConstantAggregateZero*> CAZConstants;
  855. typedef ConstantUniqueMap<ConstantArray> ArrayConstantsTy;
  856. ArrayConstantsTy ArrayConstants;
  857. typedef ConstantUniqueMap<ConstantStruct> StructConstantsTy;
  858. StructConstantsTy StructConstants;
  859. typedef ConstantUniqueMap<ConstantVector> VectorConstantsTy;
  860. VectorConstantsTy VectorConstants;
  861. DenseMap<PointerType*, ConstantPointerNull*> CPNConstants;
  862. DenseMap<Type*, UndefValue*> UVConstants;
  863. StringMap<ConstantDataSequential*> CDSConstants;
  864. DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *>
  865. BlockAddresses;
  866. ConstantUniqueMap<ConstantExpr> ExprConstants;
  867. ConstantUniqueMap<InlineAsm> InlineAsms;
  868. ConstantInt *TheTrueVal;
  869. ConstantInt *TheFalseVal;
  870. // Basic type instances.
  871. Type VoidTy, LabelTy, HalfTy, FloatTy, DoubleTy, MetadataTy;
  872. Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy;
  873. IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty, Int128Ty;
  874. /// TypeAllocator - All dynamically allocated types are allocated from this.
  875. /// They live forever until the context is torn down.
  876. BumpPtrAllocator TypeAllocator;
  877. DenseMap<unsigned, IntegerType*> IntegerTypes;
  878. typedef DenseSet<FunctionType *, FunctionTypeKeyInfo> FunctionTypeSet;
  879. FunctionTypeSet FunctionTypes;
  880. typedef DenseSet<StructType *, AnonStructTypeKeyInfo> StructTypeSet;
  881. StructTypeSet AnonStructTypes;
  882. StringMap<StructType*> NamedStructTypes;
  883. unsigned NamedStructTypesUniqueID;
  884. DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes;
  885. DenseMap<std::pair<Type *, unsigned>, VectorType*> VectorTypes;
  886. DenseMap<Type*, PointerType*> PointerTypes; // Pointers in AddrSpace = 0
  887. DenseMap<std::pair<Type*, unsigned>, PointerType*> ASPointerTypes;
  888. /// ValueHandles - This map keeps track of all of the value handles that are
  889. /// watching a Value*. The Value::HasValueHandle bit is used to know
  890. /// whether or not a value has an entry in this map.
  891. typedef DenseMap<Value*, ValueHandleBase*> ValueHandlesTy;
  892. ValueHandlesTy ValueHandles;
  893. /// CustomMDKindNames - Map to hold the metadata string to ID mapping.
  894. StringMap<unsigned> CustomMDKindNames;
  895. /// Collection of per-instruction metadata used in this context.
  896. DenseMap<const Instruction *, MDAttachmentMap> InstructionMetadata;
  897. /// Collection of per-function metadata used in this context.
  898. DenseMap<const Function *, MDAttachmentMap> FunctionMetadata;
  899. /// DiscriminatorTable - This table maps file:line locations to an
  900. /// integer representing the next DWARF path discriminator to assign to
  901. /// instructions in different blocks at the same location.
  902. DenseMap<std::pair<const char *, unsigned>, unsigned> DiscriminatorTable;
  903. /// \brief Mapping from a function to its prefix data, which is stored as the
  904. /// operand of an unparented ReturnInst so that the prefix data has a Use.
  905. typedef DenseMap<const Function *, ReturnInst *> PrefixDataMapTy;
  906. PrefixDataMapTy PrefixDataMap;
  907. /// \brief Mapping from a function to its prologue data, which is stored as
  908. /// the operand of an unparented ReturnInst so that the prologue data has a
  909. /// Use.
  910. typedef DenseMap<const Function *, ReturnInst *> PrologueDataMapTy;
  911. PrologueDataMapTy PrologueDataMap;
  912. int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx);
  913. int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx);
  914. LLVMContextImpl(LLVMContext &C);
  915. ~LLVMContextImpl();
  916. /// Destroy the ConstantArrays if they are not used.
  917. void dropTriviallyDeadConstantArrays();
  918. };
  919. }
  920. #endif