Jeffrey Yasskin | 4cfb3a7 | 2010-03-21 21:17:34 +0000 | [diff] [blame] | 1 | //===-- LLVMContextImpl.h - The LLVMContextImpl opaque class ----*- C++ -*-===// |
Owen Anderson | 8e66e0b | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Owen Anderson | 36f62e5 | 2009-06-30 17:06:46 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file declares LLVMContextImpl, the opaque implementation |
| 11 | // of LLVMContext. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
Owen Anderson | 8e66e0b | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 14 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_IR_LLVMCONTEXTIMPL_H |
| 16 | #define LLVM_LIB_IR_LLVMCONTEXTIMPL_H |
Owen Anderson | 8e66e0b | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 17 | |
Bill Wendling | 4607f4b | 2012-12-20 01:36:59 +0000 | [diff] [blame] | 18 | #include "AttributeImpl.h" |
Owen Anderson | afd0c4c | 2009-08-04 22:41:48 +0000 | [diff] [blame] | 19 | #include "ConstantsContext.h" |
Owen Anderson | c277dc4 | 2009-07-16 19:05:41 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/APFloat.h" |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/APInt.h" |
Jay Foad | c365eea | 2011-06-22 08:50:06 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/ArrayRef.h" |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/DenseMap.h" |
Duncan P. N. Exon Smith | f39c3b8 | 2014-11-17 23:28:21 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/DenseSet.h" |
Owen Anderson | 4118dde | 2009-07-16 23:44:30 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/FoldingSet.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/Hashing.h" |
Jeffrey Yasskin | 28f2448 | 2009-12-17 19:55:06 +0000 | [diff] [blame] | 27 | #include "llvm/ADT/SmallPtrSet.h" |
Owen Anderson | 69ab416 | 2009-07-16 22:11:26 +0000 | [diff] [blame] | 28 | #include "llvm/ADT/StringMap.h" |
Reid Kleckner | 443423e | 2017-01-10 23:23:58 +0000 | [diff] [blame] | 29 | #include "llvm/ADT/StringSet.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 30 | #include "llvm/IR/Constants.h" |
Duncan P. N. Exon Smith | d9901ff | 2015-02-02 18:53:21 +0000 | [diff] [blame] | 31 | #include "llvm/IR/DebugInfoMetadata.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 32 | #include "llvm/IR/DerivedTypes.h" |
| 33 | #include "llvm/IR/LLVMContext.h" |
| 34 | #include "llvm/IR/Metadata.h" |
Chandler Carruth | 4220e9c | 2014-03-04 11:17:44 +0000 | [diff] [blame] | 35 | #include "llvm/IR/ValueHandle.h" |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 36 | #include "llvm/Support/Dwarf.h" |
Adam Nemet | a62b7e1 | 2016-09-27 20:55:07 +0000 | [diff] [blame] | 37 | #include "llvm/Support/YAMLTraits.h" |
Duncan P. N. Exon Smith | 3eef9d1 | 2016-04-19 23:59:13 +0000 | [diff] [blame] | 38 | #include <vector> |
Owen Anderson | 39ede7b | 2009-07-21 20:13:12 +0000 | [diff] [blame] | 39 | |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 40 | namespace llvm { |
Owen Anderson | edb4a70 | 2009-07-24 23:12:02 +0000 | [diff] [blame] | 41 | |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 42 | class ConstantInt; |
Owen Anderson | c277dc4 | 2009-07-16 19:05:41 +0000 | [diff] [blame] | 43 | class ConstantFP; |
Diego Novillo | 7f8af8b | 2014-05-22 14:19:46 +0000 | [diff] [blame] | 44 | class DiagnosticInfoOptimizationRemark; |
| 45 | class DiagnosticInfoOptimizationRemarkMissed; |
| 46 | class DiagnosticInfoOptimizationRemarkAnalysis; |
Philip Reames | 2b45395 | 2015-01-16 20:07:33 +0000 | [diff] [blame] | 47 | class GCStrategy; |
Benjamin Kramer | 78c3bcb | 2009-08-11 17:45:13 +0000 | [diff] [blame] | 48 | class LLVMContext; |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 49 | class Type; |
Owen Anderson | 4118dde | 2009-07-16 23:44:30 +0000 | [diff] [blame] | 50 | class Value; |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 51 | |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 52 | struct DenseMapAPIntKeyInfo { |
Benjamin Kramer | 8e5dc53 | 2014-12-06 13:12:56 +0000 | [diff] [blame] | 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) { |
Chandler Carruth | 71bd7d1 | 2012-03-04 12:02:57 +0000 | [diff] [blame] | 64 | return static_cast<unsigned>(hash_value(Key)); |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 65 | } |
Benjamin Kramer | 8e5dc53 | 2014-12-06 13:12:56 +0000 | [diff] [blame] | 66 | static bool isEqual(const APInt &LHS, const APInt &RHS) { |
| 67 | return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS; |
| 68 | } |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 71 | struct DenseMapAPFloatKeyInfo { |
Stephan Bergmann | 17c7f70 | 2016-12-14 11:57:17 +0000 | [diff] [blame] | 72 | static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); } |
| 73 | static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus(), 2); } |
Benjamin Kramer | 8e5dc53 | 2014-12-06 13:12:56 +0000 | [diff] [blame] | 74 | static unsigned getHashValue(const APFloat &Key) { |
Chandler Carruth | 71bd7d1 | 2012-03-04 12:02:57 +0000 | [diff] [blame] | 75 | return static_cast<unsigned>(hash_value(Key)); |
Owen Anderson | c277dc4 | 2009-07-16 19:05:41 +0000 | [diff] [blame] | 76 | } |
Benjamin Kramer | 8e5dc53 | 2014-12-06 13:12:56 +0000 | [diff] [blame] | 77 | static bool isEqual(const APFloat &LHS, const APFloat &RHS) { |
| 78 | return LHS.bitwiseIsEqual(RHS); |
| 79 | } |
Owen Anderson | c277dc4 | 2009-07-16 19:05:41 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 82 | struct AnonStructTypeKeyInfo { |
Jay Foad | 529776c | 2012-02-23 09:17:40 +0000 | [diff] [blame] | 83 | struct KeyTy { |
| 84 | ArrayRef<Type*> ETypes; |
| 85 | bool isPacked; |
| 86 | KeyTy(const ArrayRef<Type*>& E, bool P) : |
| 87 | ETypes(E), isPacked(P) {} |
Rafael Espindola | 334b73f | 2014-11-21 18:53:05 +0000 | [diff] [blame] | 88 | KeyTy(const StructType *ST) |
| 89 | : ETypes(ST->elements()), isPacked(ST->isPacked()) {} |
Jay Foad | 529776c | 2012-02-23 09:17:40 +0000 | [diff] [blame] | 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() { |
| 102 | return DenseMapInfo<StructType*>::getEmptyKey(); |
| 103 | } |
| 104 | static inline StructType* getTombstoneKey() { |
| 105 | return DenseMapInfo<StructType*>::getTombstoneKey(); |
| 106 | } |
| 107 | static unsigned getHashValue(const KeyTy& Key) { |
Chandler Carruth | 1d03a3b | 2012-03-01 18:55:25 +0000 | [diff] [blame] | 108 | return hash_combine(hash_combine_range(Key.ETypes.begin(), |
| 109 | Key.ETypes.end()), |
| 110 | Key.isPacked); |
Jay Foad | 529776c | 2012-02-23 09:17:40 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 125 | struct FunctionTypeKeyInfo { |
Jay Foad | 529776c | 2012-02-23 09:17:40 +0000 | [diff] [blame] | 126 | struct KeyTy { |
| 127 | const Type *ReturnType; |
| 128 | ArrayRef<Type*> Params; |
| 129 | bool isVarArg; |
| 130 | KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) : |
| 131 | ReturnType(R), Params(P), isVarArg(V) {} |
Rafael Espindola | e973fd4 | 2014-11-21 19:03:35 +0000 | [diff] [blame] | 132 | KeyTy(const FunctionType *FT) |
| 133 | : ReturnType(FT->getReturnType()), Params(FT->params()), |
| 134 | isVarArg(FT->isVarArg()) {} |
Jay Foad | 529776c | 2012-02-23 09:17:40 +0000 | [diff] [blame] | 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() { |
| 149 | return DenseMapInfo<FunctionType*>::getEmptyKey(); |
| 150 | } |
| 151 | static inline FunctionType* getTombstoneKey() { |
| 152 | return DenseMapInfo<FunctionType*>::getTombstoneKey(); |
| 153 | } |
| 154 | static unsigned getHashValue(const KeyTy& Key) { |
Chandler Carruth | 1d03a3b | 2012-03-01 18:55:25 +0000 | [diff] [blame] | 155 | return hash_combine(Key.ReturnType, |
| 156 | hash_combine_range(Key.Params.begin(), |
| 157 | Key.Params.end()), |
| 158 | Key.isVarArg); |
Jay Foad | 529776c | 2012-02-23 09:17:40 +0000 | [diff] [blame] | 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 | |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 173 | /// \brief Structure for hashing arbitrary MDNode operands. |
| 174 | class MDNodeOpsKey { |
| 175 | ArrayRef<Metadata *> RawOps; |
| 176 | ArrayRef<MDOperand> Ops; |
| 177 | |
| 178 | unsigned Hash; |
| 179 | |
| 180 | protected: |
| 181 | MDNodeOpsKey(ArrayRef<Metadata *> Ops) |
| 182 | : RawOps(Ops), Hash(calculateHash(Ops)) {} |
| 183 | |
| 184 | template <class NodeTy> |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 185 | MDNodeOpsKey(const NodeTy *N, unsigned Offset = 0) |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 186 | : Ops(N->op_begin() + Offset, N->op_end()), Hash(N->getHash()) {} |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 187 | |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 188 | template <class NodeTy> |
| 189 | bool compareOps(const NodeTy *RHS, unsigned Offset = 0) const { |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 190 | if (getHash() != RHS->getHash()) |
| 191 | return false; |
| 192 | |
| 193 | assert((RawOps.empty() || Ops.empty()) && "Two sets of operands?"); |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 194 | return RawOps.empty() ? compareOps(Ops, RHS, Offset) |
| 195 | : compareOps(RawOps, RHS, Offset); |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 198 | static unsigned calculateHash(MDNode *N, unsigned Offset = 0); |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 199 | |
| 200 | private: |
| 201 | template <class T> |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 202 | static bool compareOps(ArrayRef<T> Ops, const MDNode *RHS, unsigned Offset) { |
| 203 | if (Ops.size() != RHS->getNumOperands() - Offset) |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 204 | return false; |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 205 | return std::equal(Ops.begin(), Ops.end(), RHS->op_begin() + Offset); |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | static unsigned calculateHash(ArrayRef<Metadata *> Ops); |
| 209 | |
| 210 | public: |
| 211 | unsigned getHash() const { return Hash; } |
| 212 | }; |
| 213 | |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 214 | template <class NodeTy> struct MDNodeKeyImpl; |
| 215 | template <class NodeTy> struct MDNodeInfo; |
| 216 | |
Duncan P. N. Exon Smith | f229127 | 2016-04-16 23:42:04 +0000 | [diff] [blame] | 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) { |
| 221 | return false; |
| 222 | } |
| 223 | static bool isSubsetEqual(const NodeTy *LHS, const NodeTy *RHS) { |
| 224 | return false; |
| 225 | } |
| 226 | }; |
| 227 | |
Duncan P. N. Exon Smith | 118632d | 2015-01-12 20:09:34 +0000 | [diff] [blame] | 228 | /// \brief DenseMapInfo for MDTuple. |
Duncan P. N. Exon Smith | f39c3b8 | 2014-11-17 23:28:21 +0000 | [diff] [blame] | 229 | /// |
| 230 | /// Note that we don't need the is-function-local bit, since that's implicit in |
| 231 | /// the operands. |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 232 | template <> struct MDNodeKeyImpl<MDTuple> : MDNodeOpsKey { |
| 233 | MDNodeKeyImpl(ArrayRef<Metadata *> Ops) : MDNodeOpsKey(Ops) {} |
| 234 | MDNodeKeyImpl(const MDTuple *N) : MDNodeOpsKey(N) {} |
Duncan P. N. Exon Smith | f39c3b8 | 2014-11-17 23:28:21 +0000 | [diff] [blame] | 235 | |
Duncan P. N. Exon Smith | 9c26d80 | 2015-02-05 00:51:35 +0000 | [diff] [blame] | 236 | bool isKeyOf(const MDTuple *RHS) const { return compareOps(RHS); } |
Duncan P. N. Exon Smith | 93e983e | 2015-01-19 22:53:18 +0000 | [diff] [blame] | 237 | |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 238 | unsigned getHashValue() const { return getHash(); } |
| 239 | |
| 240 | static unsigned calculateHash(MDTuple *N) { |
| 241 | return MDNodeOpsKey::calculateHash(N); |
Benjamin Kramer | 2335a5c | 2012-04-11 14:06:54 +0000 | [diff] [blame] | 242 | } |
| 243 | }; |
| 244 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 245 | /// \brief DenseMapInfo for DILocation. |
| 246 | template <> struct MDNodeKeyImpl<DILocation> { |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 247 | unsigned Line; |
| 248 | unsigned Column; |
| 249 | Metadata *Scope; |
| 250 | Metadata *InlinedAt; |
Duncan P. N. Exon Smith | de03ff5 | 2015-01-13 20:44:56 +0000 | [diff] [blame] | 251 | |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 252 | MDNodeKeyImpl(unsigned Line, unsigned Column, Metadata *Scope, |
| 253 | Metadata *InlinedAt) |
| 254 | : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {} |
Duncan P. N. Exon Smith | de03ff5 | 2015-01-13 20:44:56 +0000 | [diff] [blame] | 255 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 256 | MDNodeKeyImpl(const DILocation *L) |
Duncan P. N. Exon Smith | 2648998 | 2015-03-26 22:05:04 +0000 | [diff] [blame] | 257 | : Line(L->getLine()), Column(L->getColumn()), Scope(L->getRawScope()), |
| 258 | InlinedAt(L->getRawInlinedAt()) {} |
Duncan P. N. Exon Smith | de03ff5 | 2015-01-13 20:44:56 +0000 | [diff] [blame] | 259 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 260 | bool isKeyOf(const DILocation *RHS) const { |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 261 | return Line == RHS->getLine() && Column == RHS->getColumn() && |
Duncan P. N. Exon Smith | 2648998 | 2015-03-26 22:05:04 +0000 | [diff] [blame] | 262 | Scope == RHS->getRawScope() && InlinedAt == RHS->getRawInlinedAt(); |
Duncan P. N. Exon Smith | de03ff5 | 2015-01-13 20:44:56 +0000 | [diff] [blame] | 263 | } |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 264 | unsigned getHashValue() const { |
| 265 | return hash_combine(Line, Column, Scope, InlinedAt); |
Duncan P. N. Exon Smith | de03ff5 | 2015-01-13 20:44:56 +0000 | [diff] [blame] | 266 | } |
| 267 | }; |
| 268 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 269 | /// \brief DenseMapInfo for GenericDINode. |
| 270 | template <> struct MDNodeKeyImpl<GenericDINode> : MDNodeOpsKey { |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 271 | unsigned Tag; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 272 | MDString *Header; |
| 273 | MDNodeKeyImpl(unsigned Tag, MDString *Header, ArrayRef<Metadata *> DwarfOps) |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 274 | : MDNodeOpsKey(DwarfOps), Tag(Tag), Header(Header) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 275 | MDNodeKeyImpl(const GenericDINode *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 276 | : MDNodeOpsKey(N, 1), Tag(N->getTag()), Header(N->getRawHeader()) {} |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 277 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 278 | bool isKeyOf(const GenericDINode *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 279 | return Tag == RHS->getTag() && Header == RHS->getRawHeader() && |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 280 | compareOps(RHS, 1); |
| 281 | } |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 282 | |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 283 | unsigned getHashValue() const { return hash_combine(getHash(), Tag, Header); } |
| 284 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 285 | static unsigned calculateHash(GenericDINode *N) { |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 286 | return MDNodeOpsKey::calculateHash(N, 1); |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 287 | } |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 288 | }; |
| 289 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 290 | template <> struct MDNodeKeyImpl<DISubrange> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 291 | int64_t Count; |
Duncan P. N. Exon Smith | 5dcf621 | 2015-04-07 00:39:59 +0000 | [diff] [blame] | 292 | int64_t LowerBound; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 293 | |
Duncan P. N. Exon Smith | 5dcf621 | 2015-04-07 00:39:59 +0000 | [diff] [blame] | 294 | MDNodeKeyImpl(int64_t Count, int64_t LowerBound) |
| 295 | : Count(Count), LowerBound(LowerBound) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 296 | MDNodeKeyImpl(const DISubrange *N) |
Duncan P. N. Exon Smith | 5dcf621 | 2015-04-07 00:39:59 +0000 | [diff] [blame] | 297 | : Count(N->getCount()), LowerBound(N->getLowerBound()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 298 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 299 | bool isKeyOf(const DISubrange *RHS) const { |
Duncan P. N. Exon Smith | 5dcf621 | 2015-04-07 00:39:59 +0000 | [diff] [blame] | 300 | return Count == RHS->getCount() && LowerBound == RHS->getLowerBound(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 301 | } |
Duncan P. N. Exon Smith | 5dcf621 | 2015-04-07 00:39:59 +0000 | [diff] [blame] | 302 | unsigned getHashValue() const { return hash_combine(Count, LowerBound); } |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 303 | }; |
| 304 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 305 | template <> struct MDNodeKeyImpl<DIEnumerator> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 306 | int64_t Value; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 307 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 308 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 309 | MDNodeKeyImpl(int64_t Value, MDString *Name) : Value(Value), Name(Name) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 310 | MDNodeKeyImpl(const DIEnumerator *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 311 | : Value(N->getValue()), Name(N->getRawName()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 312 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 313 | bool isKeyOf(const DIEnumerator *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 314 | return Value == RHS->getValue() && Name == RHS->getRawName(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 315 | } |
| 316 | unsigned getHashValue() const { return hash_combine(Value, Name); } |
| 317 | }; |
| 318 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 319 | template <> struct MDNodeKeyImpl<DIBasicType> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 320 | unsigned Tag; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 321 | MDString *Name; |
Duncan P. N. Exon Smith | d34db17 | 2015-02-19 23:56:07 +0000 | [diff] [blame] | 322 | uint64_t SizeInBits; |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 323 | uint32_t AlignInBits; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 324 | unsigned Encoding; |
| 325 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 326 | MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits, |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 327 | uint32_t AlignInBits, unsigned Encoding) |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 328 | : Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits), |
| 329 | Encoding(Encoding) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 330 | MDNodeKeyImpl(const DIBasicType *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 331 | : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()), |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 332 | AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {} |
| 333 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 334 | bool isKeyOf(const DIBasicType *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 335 | return Tag == RHS->getTag() && Name == RHS->getRawName() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 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 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 345 | template <> struct MDNodeKeyImpl<DIDerivedType> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 346 | unsigned Tag; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 347 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 348 | Metadata *File; |
| 349 | unsigned Line; |
| 350 | Metadata *Scope; |
| 351 | Metadata *BaseType; |
Duncan P. N. Exon Smith | d34db17 | 2015-02-19 23:56:07 +0000 | [diff] [blame] | 352 | uint64_t SizeInBits; |
Duncan P. N. Exon Smith | d34db17 | 2015-02-19 23:56:07 +0000 | [diff] [blame] | 353 | uint64_t OffsetInBits; |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 354 | uint32_t AlignInBits; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 355 | unsigned Flags; |
| 356 | Metadata *ExtraData; |
| 357 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 358 | MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, |
Duncan P. N. Exon Smith | d34db17 | 2015-02-19 23:56:07 +0000 | [diff] [blame] | 359 | Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 360 | uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 361 | Metadata *ExtraData) |
| 362 | : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope), |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 363 | BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits), |
| 364 | AlignInBits(AlignInBits), Flags(Flags), ExtraData(ExtraData) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 365 | MDNodeKeyImpl(const DIDerivedType *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 366 | : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()), |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 367 | Line(N->getLine()), Scope(N->getRawScope()), |
| 368 | BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()), |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 369 | OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()), |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 370 | Flags(N->getFlags()), ExtraData(N->getRawExtraData()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 371 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 372 | bool isKeyOf(const DIDerivedType *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 373 | return Tag == RHS->getTag() && Name == RHS->getRawName() && |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 374 | File == RHS->getRawFile() && Line == RHS->getLine() && |
| 375 | Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 376 | SizeInBits == RHS->getSizeInBits() && |
| 377 | AlignInBits == RHS->getAlignInBits() && |
| 378 | OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() && |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 379 | ExtraData == RHS->getRawExtraData(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 380 | } |
| 381 | unsigned getHashValue() const { |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 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(). |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 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); |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 389 | |
Mehdi Amini | 9bc362a | 2016-03-19 01:06:24 +0000 | [diff] [blame] | 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. |
Mehdi Amini | 53fc389 | 2016-03-19 00:59:26 +0000 | [diff] [blame] | 394 | return hash_combine(Tag, Name, File, Line, Scope, BaseType, Flags); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 395 | } |
| 396 | }; |
| 397 | |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 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); |
| 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. |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 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()) |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 418 | return false; |
| 419 | |
| 420 | // Compare to the RHS. |
| 421 | return Tag == RHS->getTag() && Name == RHS->getRawName() && |
| 422 | Scope == RHS->getRawScope(); |
| 423 | } |
| 424 | }; |
| 425 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 426 | template <> struct MDNodeKeyImpl<DICompositeType> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 427 | unsigned Tag; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 428 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 429 | Metadata *File; |
| 430 | unsigned Line; |
| 431 | Metadata *Scope; |
| 432 | Metadata *BaseType; |
Duncan P. N. Exon Smith | d34db17 | 2015-02-19 23:56:07 +0000 | [diff] [blame] | 433 | uint64_t SizeInBits; |
Duncan P. N. Exon Smith | d34db17 | 2015-02-19 23:56:07 +0000 | [diff] [blame] | 434 | uint64_t OffsetInBits; |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 435 | uint32_t AlignInBits; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 436 | unsigned Flags; |
| 437 | Metadata *Elements; |
| 438 | unsigned RuntimeLang; |
| 439 | Metadata *VTableHolder; |
| 440 | Metadata *TemplateParams; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 441 | MDString *Identifier; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 442 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 443 | MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line, |
Duncan P. N. Exon Smith | d34db17 | 2015-02-19 23:56:07 +0000 | [diff] [blame] | 444 | Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 445 | uint32_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 446 | Metadata *Elements, unsigned RuntimeLang, |
| 447 | Metadata *VTableHolder, Metadata *TemplateParams, |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 448 | MDString *Identifier) |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 449 | : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope), |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 450 | BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits), |
| 451 | AlignInBits(AlignInBits), Flags(Flags), Elements(Elements), |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 452 | RuntimeLang(RuntimeLang), VTableHolder(VTableHolder), |
| 453 | TemplateParams(TemplateParams), Identifier(Identifier) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 454 | MDNodeKeyImpl(const DICompositeType *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 455 | : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()), |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 456 | Line(N->getLine()), Scope(N->getRawScope()), |
| 457 | BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()), |
Victor Leschuk | 197aa31 | 2016-10-18 14:31:22 +0000 | [diff] [blame] | 458 | OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()), |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 459 | Flags(N->getFlags()), Elements(N->getRawElements()), |
| 460 | RuntimeLang(N->getRuntimeLang()), VTableHolder(N->getRawVTableHolder()), |
| 461 | TemplateParams(N->getRawTemplateParams()), |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 462 | Identifier(N->getRawIdentifier()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 463 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 464 | bool isKeyOf(const DICompositeType *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 465 | return Tag == RHS->getTag() && Name == RHS->getRawName() && |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 466 | File == RHS->getRawFile() && Line == RHS->getLine() && |
| 467 | Scope == RHS->getRawScope() && BaseType == RHS->getRawBaseType() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 468 | SizeInBits == RHS->getSizeInBits() && |
| 469 | AlignInBits == RHS->getAlignInBits() && |
| 470 | OffsetInBits == RHS->getOffsetInBits() && Flags == RHS->getFlags() && |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 471 | Elements == RHS->getRawElements() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 472 | RuntimeLang == RHS->getRuntimeLang() && |
Duncan P. N. Exon Smith | 53855f0 | 2015-03-27 23:05:04 +0000 | [diff] [blame] | 473 | VTableHolder == RHS->getRawVTableHolder() && |
| 474 | TemplateParams == RHS->getRawTemplateParams() && |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 475 | Identifier == RHS->getRawIdentifier(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 476 | } |
| 477 | unsigned getHashValue() const { |
Mehdi Amini | 9bc362a | 2016-03-19 01:06:24 +0000 | [diff] [blame] | 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. |
Mehdi Amini | 53fc389 | 2016-03-19 00:59:26 +0000 | [diff] [blame] | 482 | return hash_combine(Name, File, Line, BaseType, Scope, Elements, |
| 483 | TemplateParams); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 484 | } |
| 485 | }; |
| 486 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 487 | template <> struct MDNodeKeyImpl<DISubroutineType> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 488 | unsigned Flags; |
Reid Kleckner | de3d8b5 | 2016-06-08 20:34:29 +0000 | [diff] [blame] | 489 | uint8_t CC; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 490 | Metadata *TypeArray; |
| 491 | |
Reid Kleckner | de3d8b5 | 2016-06-08 20:34:29 +0000 | [diff] [blame] | 492 | MDNodeKeyImpl(unsigned Flags, uint8_t CC, Metadata *TypeArray) |
| 493 | : Flags(Flags), CC(CC), TypeArray(TypeArray) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 494 | MDNodeKeyImpl(const DISubroutineType *N) |
Reid Kleckner | de3d8b5 | 2016-06-08 20:34:29 +0000 | [diff] [blame] | 495 | : Flags(N->getFlags()), CC(N->getCC()), TypeArray(N->getRawTypeArray()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 496 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 497 | bool isKeyOf(const DISubroutineType *RHS) const { |
Reid Kleckner | de3d8b5 | 2016-06-08 20:34:29 +0000 | [diff] [blame] | 498 | return Flags == RHS->getFlags() && CC == RHS->getCC() && |
| 499 | TypeArray == RHS->getRawTypeArray(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 500 | } |
Reid Kleckner | de3d8b5 | 2016-06-08 20:34:29 +0000 | [diff] [blame] | 501 | unsigned getHashValue() const { return hash_combine(Flags, CC, TypeArray); } |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 502 | }; |
| 503 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 504 | template <> struct MDNodeKeyImpl<DIFile> { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 505 | MDString *Filename; |
| 506 | MDString *Directory; |
Amjad Aboud | 7faeecc | 2016-12-25 10:12:09 +0000 | [diff] [blame] | 507 | DIFile::ChecksumKind CSKind; |
| 508 | MDString *Checksum; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 509 | |
Amjad Aboud | 7faeecc | 2016-12-25 10:12:09 +0000 | [diff] [blame] | 510 | MDNodeKeyImpl(MDString *Filename, MDString *Directory, |
| 511 | DIFile::ChecksumKind CSKind, MDString *Checksum) |
| 512 | : Filename(Filename), Directory(Directory), CSKind(CSKind), |
| 513 | Checksum(Checksum) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 514 | MDNodeKeyImpl(const DIFile *N) |
Amjad Aboud | 7faeecc | 2016-12-25 10:12:09 +0000 | [diff] [blame] | 515 | : Filename(N->getRawFilename()), Directory(N->getRawDirectory()), |
| 516 | CSKind(N->getChecksumKind()), Checksum(N->getRawChecksum()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 517 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 518 | bool isKeyOf(const DIFile *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 519 | return Filename == RHS->getRawFilename() && |
Amjad Aboud | 7faeecc | 2016-12-25 10:12:09 +0000 | [diff] [blame] | 520 | Directory == RHS->getRawDirectory() && |
| 521 | CSKind == RHS->getChecksumKind() && |
| 522 | Checksum == RHS->getRawChecksum(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 523 | } |
Amjad Aboud | 7faeecc | 2016-12-25 10:12:09 +0000 | [diff] [blame] | 524 | unsigned getHashValue() const { |
| 525 | return hash_combine(Filename, Directory, CSKind, Checksum); |
| 526 | } |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 527 | }; |
| 528 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 529 | template <> struct MDNodeKeyImpl<DISubprogram> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 530 | Metadata *Scope; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 531 | MDString *Name; |
| 532 | MDString *LinkageName; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 533 | Metadata *File; |
| 534 | unsigned Line; |
| 535 | Metadata *Type; |
| 536 | bool IsLocalToUnit; |
| 537 | bool IsDefinition; |
| 538 | unsigned ScopeLine; |
| 539 | Metadata *ContainingType; |
| 540 | unsigned Virtuality; |
| 541 | unsigned VirtualIndex; |
Reid Kleckner | b5af11d | 2016-07-01 02:41:21 +0000 | [diff] [blame] | 542 | int ThisAdjustment; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 543 | unsigned Flags; |
| 544 | bool IsOptimized; |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 545 | Metadata *Unit; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 546 | Metadata *TemplateParams; |
| 547 | Metadata *Declaration; |
| 548 | Metadata *Variables; |
| 549 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 550 | MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName, |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 551 | Metadata *File, unsigned Line, Metadata *Type, |
| 552 | bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, |
| 553 | Metadata *ContainingType, unsigned Virtuality, |
Reid Kleckner | b5af11d | 2016-07-01 02:41:21 +0000 | [diff] [blame] | 554 | unsigned VirtualIndex, int ThisAdjustment, unsigned Flags, |
| 555 | bool IsOptimized, Metadata *Unit, Metadata *TemplateParams, |
| 556 | Metadata *Declaration, Metadata *Variables) |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 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), |
Reid Kleckner | b5af11d | 2016-07-01 02:41:21 +0000 | [diff] [blame] | 561 | VirtualIndex(VirtualIndex), ThisAdjustment(ThisAdjustment), |
| 562 | Flags(Flags), IsOptimized(IsOptimized), Unit(Unit), |
| 563 | TemplateParams(TemplateParams), Declaration(Declaration), |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 564 | Variables(Variables) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 565 | MDNodeKeyImpl(const DISubprogram *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 566 | : Scope(N->getRawScope()), Name(N->getRawName()), |
| 567 | LinkageName(N->getRawLinkageName()), File(N->getRawFile()), |
Duncan P. N. Exon Smith | 869db50 | 2015-03-30 16:19:15 +0000 | [diff] [blame] | 568 | Line(N->getLine()), Type(N->getRawType()), |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 569 | IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()), |
Duncan P. N. Exon Smith | 869db50 | 2015-03-30 16:19:15 +0000 | [diff] [blame] | 570 | ScopeLine(N->getScopeLine()), ContainingType(N->getRawContainingType()), |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 571 | Virtuality(N->getVirtuality()), VirtualIndex(N->getVirtualIndex()), |
Reid Kleckner | b5af11d | 2016-07-01 02:41:21 +0000 | [diff] [blame] | 572 | ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()), |
| 573 | IsOptimized(N->isOptimized()), Unit(N->getRawUnit()), |
| 574 | TemplateParams(N->getRawTemplateParams()), |
Duncan P. N. Exon Smith | 869db50 | 2015-03-30 16:19:15 +0000 | [diff] [blame] | 575 | Declaration(N->getRawDeclaration()), Variables(N->getRawVariables()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 576 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 577 | bool isKeyOf(const DISubprogram *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 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() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 582 | IsDefinition == RHS->isDefinition() && |
| 583 | ScopeLine == RHS->getScopeLine() && |
Duncan P. N. Exon Smith | 869db50 | 2015-03-30 16:19:15 +0000 | [diff] [blame] | 584 | ContainingType == RHS->getRawContainingType() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 585 | Virtuality == RHS->getVirtuality() && |
Reid Kleckner | b5af11d | 2016-07-01 02:41:21 +0000 | [diff] [blame] | 586 | VirtualIndex == RHS->getVirtualIndex() && |
| 587 | ThisAdjustment == RHS->getThisAdjustment() && |
| 588 | Flags == RHS->getFlags() && IsOptimized == RHS->isOptimized() && |
| 589 | Unit == RHS->getUnit() && |
Duncan P. N. Exon Smith | 869db50 | 2015-03-30 16:19:15 +0000 | [diff] [blame] | 590 | TemplateParams == RHS->getRawTemplateParams() && |
| 591 | Declaration == RHS->getRawDeclaration() && |
| 592 | Variables == RHS->getRawVariables(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 593 | } |
| 594 | unsigned getHashValue() const { |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 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(). |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 598 | if (!IsDefinition && LinkageName) |
| 599 | if (auto *CT = dyn_cast_or_null<DICompositeType>(Scope)) |
| 600 | if (CT->getRawIdentifier()) |
| 601 | return hash_combine(LinkageName, Scope); |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 602 | |
Mehdi Amini | 9bc362a | 2016-03-19 01:06:24 +0000 | [diff] [blame] | 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. |
Mehdi Amini | 53fc389 | 2016-03-19 00:59:26 +0000 | [diff] [blame] | 607 | return hash_combine(Name, Scope, File, Type, Line); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 608 | } |
| 609 | }; |
| 610 | |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 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, |
Peter Collingbourne | e69e73c | 2017-02-06 21:23:03 +0000 | [diff] [blame^] | 615 | LHS.LinkageName, LHS.TemplateParams, RHS); |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 616 | } |
| 617 | static bool isSubsetEqual(const DISubprogram *LHS, const DISubprogram *RHS) { |
| 618 | return isDeclarationOfODRMember(LHS->isDefinition(), LHS->getRawScope(), |
Peter Collingbourne | e69e73c | 2017-02-06 21:23:03 +0000 | [diff] [blame^] | 619 | LHS->getRawLinkageName(), |
| 620 | LHS->getRawTemplateParams(), RHS); |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | /// Subprograms compare equal if they declare the same function in an ODR |
| 624 | /// type. |
| 625 | static bool isDeclarationOfODRMember(bool IsDefinition, const Metadata *Scope, |
| 626 | const MDString *LinkageName, |
Peter Collingbourne | e69e73c | 2017-02-06 21:23:03 +0000 | [diff] [blame^] | 627 | const Metadata *TemplateParams, |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 628 | const DISubprogram *RHS) { |
| 629 | // Check whether the LHS is eligible. |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 630 | if (IsDefinition || !Scope || !LinkageName) |
| 631 | return false; |
| 632 | |
| 633 | auto *CT = dyn_cast_or_null<DICompositeType>(Scope); |
| 634 | if (!CT || !CT->getRawIdentifier()) |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 635 | return false; |
| 636 | |
| 637 | // Compare to the RHS. |
Peter Collingbourne | e69e73c | 2017-02-06 21:23:03 +0000 | [diff] [blame^] | 638 | // FIXME: We need to compare template parameters here to avoid incorrect |
| 639 | // collisions in mapMetadata when RF_MoveDistinctMDs and a ODR-DISubprogram |
| 640 | // has a non-ODR template parameter (i.e., a DICompositeType that does not |
| 641 | // have an identifier). Eventually we should decouple ODR logic from |
| 642 | // uniquing logic. |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 643 | return IsDefinition == RHS->isDefinition() && Scope == RHS->getRawScope() && |
Peter Collingbourne | e69e73c | 2017-02-06 21:23:03 +0000 | [diff] [blame^] | 644 | LinkageName == RHS->getRawLinkageName() && |
| 645 | TemplateParams == RHS->getRawTemplateParams(); |
Duncan P. N. Exon Smith | 05ebfd0 | 2016-04-17 02:30:20 +0000 | [diff] [blame] | 646 | } |
| 647 | }; |
| 648 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 649 | template <> struct MDNodeKeyImpl<DILexicalBlock> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 650 | Metadata *Scope; |
| 651 | Metadata *File; |
| 652 | unsigned Line; |
| 653 | unsigned Column; |
| 654 | |
| 655 | MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column) |
| 656 | : Scope(Scope), File(File), Line(Line), Column(Column) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 657 | MDNodeKeyImpl(const DILexicalBlock *N) |
Duncan P. N. Exon Smith | 0e202b9 | 2015-03-30 16:37:48 +0000 | [diff] [blame] | 658 | : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()), |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 659 | Column(N->getColumn()) {} |
| 660 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 661 | bool isKeyOf(const DILexicalBlock *RHS) const { |
Duncan P. N. Exon Smith | 0e202b9 | 2015-03-30 16:37:48 +0000 | [diff] [blame] | 662 | return Scope == RHS->getRawScope() && File == RHS->getRawFile() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 663 | Line == RHS->getLine() && Column == RHS->getColumn(); |
| 664 | } |
| 665 | unsigned getHashValue() const { |
| 666 | return hash_combine(Scope, File, Line, Column); |
| 667 | } |
| 668 | }; |
| 669 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 670 | template <> struct MDNodeKeyImpl<DILexicalBlockFile> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 671 | Metadata *Scope; |
| 672 | Metadata *File; |
| 673 | unsigned Discriminator; |
| 674 | |
| 675 | MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator) |
| 676 | : Scope(Scope), File(File), Discriminator(Discriminator) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 677 | MDNodeKeyImpl(const DILexicalBlockFile *N) |
Duncan P. N. Exon Smith | 0e202b9 | 2015-03-30 16:37:48 +0000 | [diff] [blame] | 678 | : Scope(N->getRawScope()), File(N->getRawFile()), |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 679 | Discriminator(N->getDiscriminator()) {} |
| 680 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 681 | bool isKeyOf(const DILexicalBlockFile *RHS) const { |
Duncan P. N. Exon Smith | 0e202b9 | 2015-03-30 16:37:48 +0000 | [diff] [blame] | 682 | return Scope == RHS->getRawScope() && File == RHS->getRawFile() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 683 | Discriminator == RHS->getDiscriminator(); |
| 684 | } |
| 685 | unsigned getHashValue() const { |
| 686 | return hash_combine(Scope, File, Discriminator); |
| 687 | } |
| 688 | }; |
| 689 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 690 | template <> struct MDNodeKeyImpl<DINamespace> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 691 | Metadata *Scope; |
| 692 | Metadata *File; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 693 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 694 | unsigned Line; |
Adrian Prantl | dbfda63 | 2016-11-03 19:42:02 +0000 | [diff] [blame] | 695 | bool ExportSymbols; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 696 | |
Adrian Prantl | dbfda63 | 2016-11-03 19:42:02 +0000 | [diff] [blame] | 697 | MDNodeKeyImpl(Metadata *Scope, Metadata *File, MDString *Name, unsigned Line, |
| 698 | bool ExportSymbols) |
| 699 | : Scope(Scope), File(File), Name(Name), Line(Line), |
| 700 | ExportSymbols(ExportSymbols) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 701 | MDNodeKeyImpl(const DINamespace *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 702 | : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getRawName()), |
Adrian Prantl | dbfda63 | 2016-11-03 19:42:02 +0000 | [diff] [blame] | 703 | Line(N->getLine()), ExportSymbols(N->getExportSymbols()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 704 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 705 | bool isKeyOf(const DINamespace *RHS) const { |
Duncan P. N. Exon Smith | f9b4775 | 2015-03-30 17:21:38 +0000 | [diff] [blame] | 706 | return Scope == RHS->getRawScope() && File == RHS->getRawFile() && |
Adrian Prantl | dbfda63 | 2016-11-03 19:42:02 +0000 | [diff] [blame] | 707 | Name == RHS->getRawName() && Line == RHS->getLine() && |
| 708 | ExportSymbols == RHS->getExportSymbols(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 709 | } |
| 710 | unsigned getHashValue() const { |
| 711 | return hash_combine(Scope, File, Name, Line); |
| 712 | } |
| 713 | }; |
| 714 | |
Adrian Prantl | ab1243f | 2015-06-29 23:03:47 +0000 | [diff] [blame] | 715 | template <> struct MDNodeKeyImpl<DIModule> { |
| 716 | Metadata *Scope; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 717 | MDString *Name; |
| 718 | MDString *ConfigurationMacros; |
| 719 | MDString *IncludePath; |
| 720 | MDString *ISysRoot; |
| 721 | MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *ConfigurationMacros, |
| 722 | MDString *IncludePath, MDString *ISysRoot) |
| 723 | : Scope(Scope), Name(Name), ConfigurationMacros(ConfigurationMacros), |
| 724 | IncludePath(IncludePath), ISysRoot(ISysRoot) {} |
Adrian Prantl | ab1243f | 2015-06-29 23:03:47 +0000 | [diff] [blame] | 725 | MDNodeKeyImpl(const DIModule *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 726 | : Scope(N->getRawScope()), Name(N->getRawName()), |
| 727 | ConfigurationMacros(N->getRawConfigurationMacros()), |
| 728 | IncludePath(N->getRawIncludePath()), ISysRoot(N->getRawISysRoot()) {} |
Adrian Prantl | ab1243f | 2015-06-29 23:03:47 +0000 | [diff] [blame] | 729 | |
| 730 | bool isKeyOf(const DIModule *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 731 | return Scope == RHS->getRawScope() && Name == RHS->getRawName() && |
| 732 | ConfigurationMacros == RHS->getRawConfigurationMacros() && |
| 733 | IncludePath == RHS->getRawIncludePath() && |
| 734 | ISysRoot == RHS->getRawISysRoot(); |
Adrian Prantl | ab1243f | 2015-06-29 23:03:47 +0000 | [diff] [blame] | 735 | } |
| 736 | unsigned getHashValue() const { |
| 737 | return hash_combine(Scope, Name, |
| 738 | ConfigurationMacros, IncludePath, ISysRoot); |
| 739 | } |
| 740 | }; |
| 741 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 742 | template <> struct MDNodeKeyImpl<DITemplateTypeParameter> { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 743 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 744 | Metadata *Type; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 745 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 746 | MDNodeKeyImpl(MDString *Name, Metadata *Type) : Name(Name), Type(Type) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 747 | MDNodeKeyImpl(const DITemplateTypeParameter *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 748 | : Name(N->getRawName()), Type(N->getRawType()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 749 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 750 | bool isKeyOf(const DITemplateTypeParameter *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 751 | return Name == RHS->getRawName() && Type == RHS->getRawType(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 752 | } |
Duncan P. N. Exon Smith | 3d62bba | 2015-02-19 00:37:21 +0000 | [diff] [blame] | 753 | unsigned getHashValue() const { return hash_combine(Name, Type); } |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 754 | }; |
| 755 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 756 | template <> struct MDNodeKeyImpl<DITemplateValueParameter> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 757 | unsigned Tag; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 758 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 759 | Metadata *Type; |
| 760 | Metadata *Value; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 761 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 762 | MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, Metadata *Value) |
Duncan P. N. Exon Smith | 3d62bba | 2015-02-19 00:37:21 +0000 | [diff] [blame] | 763 | : Tag(Tag), Name(Name), Type(Type), Value(Value) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 764 | MDNodeKeyImpl(const DITemplateValueParameter *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 765 | : Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()), |
Duncan P. N. Exon Smith | 3d62bba | 2015-02-19 00:37:21 +0000 | [diff] [blame] | 766 | Value(N->getValue()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 767 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 768 | bool isKeyOf(const DITemplateValueParameter *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 769 | return Tag == RHS->getTag() && Name == RHS->getRawName() && |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 770 | Type == RHS->getRawType() && Value == RHS->getValue(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 771 | } |
Duncan P. N. Exon Smith | 3d62bba | 2015-02-19 00:37:21 +0000 | [diff] [blame] | 772 | unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); } |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 773 | }; |
| 774 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 775 | template <> struct MDNodeKeyImpl<DIGlobalVariable> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 776 | Metadata *Scope; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 777 | MDString *Name; |
| 778 | MDString *LinkageName; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 779 | Metadata *File; |
| 780 | unsigned Line; |
| 781 | Metadata *Type; |
| 782 | bool IsLocalToUnit; |
| 783 | bool IsDefinition; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 784 | Metadata *StaticDataMemberDeclaration; |
Victor Leschuk | a37660c | 2016-10-26 21:32:29 +0000 | [diff] [blame] | 785 | uint32_t AlignInBits; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 786 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 787 | MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName, |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 788 | Metadata *File, unsigned Line, Metadata *Type, |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 789 | bool IsLocalToUnit, bool IsDefinition, |
Adrian Prantl | bceaaa9 | 2016-12-20 02:09:43 +0000 | [diff] [blame] | 790 | Metadata *StaticDataMemberDeclaration, uint32_t AlignInBits) |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 791 | : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File), |
| 792 | Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit), |
Adrian Prantl | bceaaa9 | 2016-12-20 02:09:43 +0000 | [diff] [blame] | 793 | IsDefinition(IsDefinition), |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 794 | StaticDataMemberDeclaration(StaticDataMemberDeclaration), |
| 795 | AlignInBits(AlignInBits) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 796 | MDNodeKeyImpl(const DIGlobalVariable *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 797 | : Scope(N->getRawScope()), Name(N->getRawName()), |
| 798 | LinkageName(N->getRawLinkageName()), File(N->getRawFile()), |
Duncan P. N. Exon Smith | 3d2afaa | 2015-03-27 17:29:58 +0000 | [diff] [blame] | 799 | Line(N->getLine()), Type(N->getRawType()), |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 800 | IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()), |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 801 | StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()), |
| 802 | AlignInBits(N->getAlignInBits()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 803 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 804 | bool isKeyOf(const DIGlobalVariable *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 805 | return Scope == RHS->getRawScope() && Name == RHS->getRawName() && |
| 806 | LinkageName == RHS->getRawLinkageName() && |
| 807 | File == RHS->getRawFile() && Line == RHS->getLine() && |
| 808 | Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() && |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 809 | IsDefinition == RHS->isDefinition() && |
Duncan P. N. Exon Smith | 3d2afaa | 2015-03-27 17:29:58 +0000 | [diff] [blame] | 810 | StaticDataMemberDeclaration == |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 811 | RHS->getRawStaticDataMemberDeclaration() && |
| 812 | AlignInBits == RHS->getAlignInBits(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 813 | } |
| 814 | unsigned getHashValue() const { |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 815 | // We do not use AlignInBits in hashing function here on purpose: |
| 816 | // in most cases this param for local variable is zero (for function param |
| 817 | // it is always zero). This leads to lots of hash collisions and errors on |
| 818 | // cases with lots of similar variables. |
| 819 | // clang/test/CodeGen/debug-info-257-args.c is an example of this problem, |
| 820 | // generated IR is random for each run and test fails with Align included. |
| 821 | // TODO: make hashing work fine with such situations |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 822 | return hash_combine(Scope, Name, LinkageName, File, Line, Type, |
Adrian Prantl | bceaaa9 | 2016-12-20 02:09:43 +0000 | [diff] [blame] | 823 | IsLocalToUnit, IsDefinition, /* AlignInBits, */ |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 824 | StaticDataMemberDeclaration); |
| 825 | } |
| 826 | }; |
| 827 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 828 | template <> struct MDNodeKeyImpl<DILocalVariable> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 829 | Metadata *Scope; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 830 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 831 | Metadata *File; |
| 832 | unsigned Line; |
| 833 | Metadata *Type; |
| 834 | unsigned Arg; |
| 835 | unsigned Flags; |
Victor Leschuk | a37660c | 2016-10-26 21:32:29 +0000 | [diff] [blame] | 836 | uint32_t AlignInBits; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 837 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 838 | MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line, |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 839 | Metadata *Type, unsigned Arg, unsigned Flags, |
Victor Leschuk | a37660c | 2016-10-26 21:32:29 +0000 | [diff] [blame] | 840 | uint32_t AlignInBits) |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 841 | : Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg), |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 842 | Flags(Flags), AlignInBits(AlignInBits) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 843 | MDNodeKeyImpl(const DILocalVariable *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 844 | : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()), |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 845 | Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()), |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 846 | Flags(N->getFlags()), AlignInBits(N->getAlignInBits()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 847 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 848 | bool isKeyOf(const DILocalVariable *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 849 | return Scope == RHS->getRawScope() && Name == RHS->getRawName() && |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 850 | File == RHS->getRawFile() && Line == RHS->getLine() && |
| 851 | Type == RHS->getRawType() && Arg == RHS->getArg() && |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 852 | Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 853 | } |
| 854 | unsigned getHashValue() const { |
Victor Leschuk | 2ede126 | 2016-10-20 00:13:12 +0000 | [diff] [blame] | 855 | // We do not use AlignInBits in hashing function here on purpose: |
| 856 | // in most cases this param for local variable is zero (for function param |
| 857 | // it is always zero). This leads to lots of hash collisions and errors on |
| 858 | // cases with lots of similar variables. |
| 859 | // clang/test/CodeGen/debug-info-257-args.c is an example of this problem, |
| 860 | // generated IR is random for each run and test fails with Align included. |
| 861 | // TODO: make hashing work fine with such situations |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 862 | return hash_combine(Scope, Name, File, Line, Type, Arg, Flags); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 863 | } |
| 864 | }; |
| 865 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 866 | template <> struct MDNodeKeyImpl<DIExpression> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 867 | ArrayRef<uint64_t> Elements; |
| 868 | |
| 869 | MDNodeKeyImpl(ArrayRef<uint64_t> Elements) : Elements(Elements) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 870 | MDNodeKeyImpl(const DIExpression *N) : Elements(N->getElements()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 871 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 872 | bool isKeyOf(const DIExpression *RHS) const { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 873 | return Elements == RHS->getElements(); |
| 874 | } |
| 875 | unsigned getHashValue() const { |
| 876 | return hash_combine_range(Elements.begin(), Elements.end()); |
| 877 | } |
| 878 | }; |
| 879 | |
Adrian Prantl | bceaaa9 | 2016-12-20 02:09:43 +0000 | [diff] [blame] | 880 | template <> struct MDNodeKeyImpl<DIGlobalVariableExpression> { |
| 881 | Metadata *Variable; |
| 882 | Metadata *Expression; |
| 883 | |
| 884 | MDNodeKeyImpl(Metadata *Variable, Metadata *Expression) |
| 885 | : Variable(Variable), Expression(Expression) {} |
| 886 | MDNodeKeyImpl(const DIGlobalVariableExpression *N) |
| 887 | : Variable(N->getRawVariable()), Expression(N->getRawExpression()) {} |
| 888 | |
| 889 | bool isKeyOf(const DIGlobalVariableExpression *RHS) const { |
| 890 | return Variable == RHS->getRawVariable() && |
| 891 | Expression == RHS->getRawExpression(); |
| 892 | } |
| 893 | unsigned getHashValue() const { return hash_combine(Variable, Expression); } |
| 894 | }; |
| 895 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 896 | template <> struct MDNodeKeyImpl<DIObjCProperty> { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 897 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 898 | Metadata *File; |
| 899 | unsigned Line; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 900 | MDString *GetterName; |
| 901 | MDString *SetterName; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 902 | unsigned Attributes; |
| 903 | Metadata *Type; |
| 904 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 905 | MDNodeKeyImpl(MDString *Name, Metadata *File, unsigned Line, |
| 906 | MDString *GetterName, MDString *SetterName, unsigned Attributes, |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 907 | Metadata *Type) |
| 908 | : Name(Name), File(File), Line(Line), GetterName(GetterName), |
| 909 | SetterName(SetterName), Attributes(Attributes), Type(Type) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 910 | MDNodeKeyImpl(const DIObjCProperty *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 911 | : Name(N->getRawName()), File(N->getRawFile()), Line(N->getLine()), |
| 912 | GetterName(N->getRawGetterName()), SetterName(N->getRawSetterName()), |
Duncan P. N. Exon Smith | f9b4775 | 2015-03-30 17:21:38 +0000 | [diff] [blame] | 913 | Attributes(N->getAttributes()), Type(N->getRawType()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 914 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 915 | bool isKeyOf(const DIObjCProperty *RHS) const { |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 916 | return Name == RHS->getRawName() && File == RHS->getRawFile() && |
| 917 | Line == RHS->getLine() && GetterName == RHS->getRawGetterName() && |
| 918 | SetterName == RHS->getRawSetterName() && |
Duncan P. N. Exon Smith | f9b4775 | 2015-03-30 17:21:38 +0000 | [diff] [blame] | 919 | Attributes == RHS->getAttributes() && Type == RHS->getRawType(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 920 | } |
| 921 | unsigned getHashValue() const { |
| 922 | return hash_combine(Name, File, Line, GetterName, SetterName, Attributes, |
| 923 | Type); |
| 924 | } |
| 925 | }; |
| 926 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 927 | template <> struct MDNodeKeyImpl<DIImportedEntity> { |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 928 | unsigned Tag; |
| 929 | Metadata *Scope; |
| 930 | Metadata *Entity; |
| 931 | unsigned Line; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 932 | MDString *Name; |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 933 | |
| 934 | MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line, |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 935 | MDString *Name) |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 936 | : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 937 | MDNodeKeyImpl(const DIImportedEntity *N) |
Duncan P. N. Exon Smith | f9b4775 | 2015-03-30 17:21:38 +0000 | [diff] [blame] | 938 | : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()), |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 939 | Line(N->getLine()), Name(N->getRawName()) {} |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 940 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 941 | bool isKeyOf(const DIImportedEntity *RHS) const { |
Duncan P. N. Exon Smith | f9b4775 | 2015-03-30 17:21:38 +0000 | [diff] [blame] | 942 | return Tag == RHS->getTag() && Scope == RHS->getRawScope() && |
| 943 | Entity == RHS->getRawEntity() && Line == RHS->getLine() && |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 944 | Name == RHS->getRawName(); |
Duncan P. N. Exon Smith | 01fc176 | 2015-02-10 00:52:32 +0000 | [diff] [blame] | 945 | } |
| 946 | unsigned getHashValue() const { |
| 947 | return hash_combine(Tag, Scope, Entity, Line, Name); |
| 948 | } |
| 949 | }; |
| 950 | |
Amjad Aboud | a9bcf16 | 2015-12-10 12:56:35 +0000 | [diff] [blame] | 951 | template <> struct MDNodeKeyImpl<DIMacro> { |
| 952 | unsigned MIType; |
| 953 | unsigned Line; |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 954 | MDString *Name; |
| 955 | MDString *Value; |
Amjad Aboud | a9bcf16 | 2015-12-10 12:56:35 +0000 | [diff] [blame] | 956 | |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 957 | MDNodeKeyImpl(unsigned MIType, unsigned Line, MDString *Name, MDString *Value) |
Amjad Aboud | a9bcf16 | 2015-12-10 12:56:35 +0000 | [diff] [blame] | 958 | : MIType(MIType), Line(Line), Name(Name), Value(Value) {} |
| 959 | MDNodeKeyImpl(const DIMacro *N) |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 960 | : MIType(N->getMacinfoType()), Line(N->getLine()), Name(N->getRawName()), |
| 961 | Value(N->getRawValue()) {} |
Amjad Aboud | a9bcf16 | 2015-12-10 12:56:35 +0000 | [diff] [blame] | 962 | |
| 963 | bool isKeyOf(const DIMacro *RHS) const { |
| 964 | return MIType == RHS->getMacinfoType() && Line == RHS->getLine() && |
Mehdi Amini | 5d99c4e | 2016-03-19 01:02:34 +0000 | [diff] [blame] | 965 | Name == RHS->getRawName() && Value == RHS->getRawValue(); |
Amjad Aboud | a9bcf16 | 2015-12-10 12:56:35 +0000 | [diff] [blame] | 966 | } |
| 967 | unsigned getHashValue() const { |
| 968 | return hash_combine(MIType, Line, Name, Value); |
| 969 | } |
| 970 | }; |
| 971 | |
| 972 | template <> struct MDNodeKeyImpl<DIMacroFile> { |
| 973 | unsigned MIType; |
| 974 | unsigned Line; |
| 975 | Metadata *File; |
| 976 | Metadata *Elements; |
| 977 | |
| 978 | MDNodeKeyImpl(unsigned MIType, unsigned Line, Metadata *File, |
| 979 | Metadata *Elements) |
| 980 | : MIType(MIType), Line(Line), File(File), Elements(Elements) {} |
| 981 | MDNodeKeyImpl(const DIMacroFile *N) |
| 982 | : MIType(N->getMacinfoType()), Line(N->getLine()), File(N->getRawFile()), |
| 983 | Elements(N->getRawElements()) {} |
| 984 | |
| 985 | bool isKeyOf(const DIMacroFile *RHS) const { |
| 986 | return MIType == RHS->getMacinfoType() && Line == RHS->getLine() && |
Amjad Aboud | 580498d | 2016-07-31 14:41:50 +0000 | [diff] [blame] | 987 | File == RHS->getRawFile() && Elements == RHS->getRawElements(); |
Amjad Aboud | a9bcf16 | 2015-12-10 12:56:35 +0000 | [diff] [blame] | 988 | } |
| 989 | unsigned getHashValue() const { |
| 990 | return hash_combine(MIType, Line, File, Elements); |
| 991 | } |
| 992 | }; |
| 993 | |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 994 | /// \brief DenseMapInfo for MDNode subclasses. |
| 995 | template <class NodeTy> struct MDNodeInfo { |
| 996 | typedef MDNodeKeyImpl<NodeTy> KeyTy; |
Duncan P. N. Exon Smith | f229127 | 2016-04-16 23:42:04 +0000 | [diff] [blame] | 997 | typedef MDNodeSubsetEqualImpl<NodeTy> SubsetEqualTy; |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 998 | static inline NodeTy *getEmptyKey() { |
| 999 | return DenseMapInfo<NodeTy *>::getEmptyKey(); |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 1000 | } |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 1001 | static inline NodeTy *getTombstoneKey() { |
| 1002 | return DenseMapInfo<NodeTy *>::getTombstoneKey(); |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 1003 | } |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 1004 | static unsigned getHashValue(const KeyTy &Key) { return Key.getHashValue(); } |
| 1005 | static unsigned getHashValue(const NodeTy *N) { |
| 1006 | return KeyTy(N).getHashValue(); |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 1007 | } |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 1008 | static bool isEqual(const KeyTy &LHS, const NodeTy *RHS) { |
| 1009 | if (RHS == getEmptyKey() || RHS == getTombstoneKey()) |
| 1010 | return false; |
Duncan P. N. Exon Smith | f229127 | 2016-04-16 23:42:04 +0000 | [diff] [blame] | 1011 | return SubsetEqualTy::isSubsetEqual(LHS, RHS) || LHS.isKeyOf(RHS); |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 1012 | } |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 1013 | static bool isEqual(const NodeTy *LHS, const NodeTy *RHS) { |
Duncan P. N. Exon Smith | f229127 | 2016-04-16 23:42:04 +0000 | [diff] [blame] | 1014 | if (LHS == RHS) |
| 1015 | return true; |
| 1016 | if (RHS == getEmptyKey() || RHS == getTombstoneKey()) |
| 1017 | return false; |
| 1018 | return SubsetEqualTy::isSubsetEqual(LHS, RHS); |
Duncan P. N. Exon Smith | fed199a | 2015-01-20 00:01:43 +0000 | [diff] [blame] | 1019 | } |
| 1020 | }; |
| 1021 | |
Duncan P. N. Exon Smith | 8af6cfc | 2015-02-04 22:08:30 +0000 | [diff] [blame] | 1022 | #define HANDLE_MDNODE_LEAF(CLASS) typedef MDNodeInfo<CLASS> CLASS##Info; |
| 1023 | #include "llvm/IR/Metadata.def" |
| 1024 | |
Duncan P. N. Exon Smith | cbc28dc | 2015-04-24 20:36:25 +0000 | [diff] [blame] | 1025 | /// \brief Map-like storage for metadata attachments. |
| 1026 | class MDAttachmentMap { |
| 1027 | SmallVector<std::pair<unsigned, TrackingMDNodeRef>, 2> Attachments; |
| 1028 | |
| 1029 | public: |
| 1030 | bool empty() const { return Attachments.empty(); } |
| 1031 | size_t size() const { return Attachments.size(); } |
| 1032 | |
| 1033 | /// \brief Get a particular attachment (if any). |
| 1034 | MDNode *lookup(unsigned ID) const; |
| 1035 | |
| 1036 | /// \brief Set an attachment to a particular node. |
| 1037 | /// |
| 1038 | /// Set the \c ID attachment to \c MD, replacing the current attachment at \c |
| 1039 | /// ID (if anyway). |
| 1040 | void set(unsigned ID, MDNode &MD); |
| 1041 | |
| 1042 | /// \brief Remove an attachment. |
| 1043 | /// |
| 1044 | /// Remove the attachment at \c ID, if any. |
| 1045 | void erase(unsigned ID); |
| 1046 | |
| 1047 | /// \brief Copy out all the attachments. |
| 1048 | /// |
| 1049 | /// Copies all the current attachments into \c Result, sorting by attachment |
| 1050 | /// ID. This function does \em not clear \c Result. |
| 1051 | void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const; |
| 1052 | |
| 1053 | /// \brief Erase matching attachments. |
| 1054 | /// |
| 1055 | /// Erases all attachments matching the \c shouldRemove predicate. |
| 1056 | template <class PredTy> void remove_if(PredTy shouldRemove) { |
David Majnemer | 2d006e7 | 2016-08-12 04:32:42 +0000 | [diff] [blame] | 1057 | Attachments.erase(llvm::remove_if(Attachments, shouldRemove), |
| 1058 | Attachments.end()); |
Duncan P. N. Exon Smith | cbc28dc | 2015-04-24 20:36:25 +0000 | [diff] [blame] | 1059 | } |
| 1060 | }; |
| 1061 | |
Peter Collingbourne | 382d81c | 2016-06-01 01:17:57 +0000 | [diff] [blame] | 1062 | /// Multimap-like storage for metadata attachments for globals. This differs |
| 1063 | /// from MDAttachmentMap in that it allows multiple attachments per metadata |
| 1064 | /// kind. |
| 1065 | class MDGlobalAttachmentMap { |
| 1066 | struct Attachment { |
| 1067 | unsigned MDKind; |
| 1068 | TrackingMDNodeRef Node; |
| 1069 | }; |
| 1070 | SmallVector<Attachment, 1> Attachments; |
| 1071 | |
| 1072 | public: |
| 1073 | bool empty() const { return Attachments.empty(); } |
| 1074 | |
| 1075 | /// Appends all attachments with the given ID to \c Result in insertion order. |
| 1076 | /// If the global has no attachments with the given ID, or if ID is invalid, |
| 1077 | /// leaves Result unchanged. |
| 1078 | void get(unsigned ID, SmallVectorImpl<MDNode *> &Result); |
| 1079 | |
| 1080 | void insert(unsigned ID, MDNode &MD); |
| 1081 | void erase(unsigned ID); |
| 1082 | |
| 1083 | /// Appends all attachments for the global to \c Result, sorting by attachment |
| 1084 | /// ID. Attachments with the same ID appear in insertion order. This function |
| 1085 | /// does \em not clear \c Result. |
| 1086 | void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const; |
| 1087 | }; |
| 1088 | |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 1089 | class LLVMContextImpl { |
Benjamin Kramer | 78c3bcb | 2009-08-11 17:45:13 +0000 | [diff] [blame] | 1090 | public: |
Owen Anderson | 8e89e41 | 2010-09-08 18:03:32 +0000 | [diff] [blame] | 1091 | /// OwnedModules - The set of modules instantiated in this context, and which |
| 1092 | /// will be automatically deleted if this context is deleted. |
| 1093 | SmallPtrSet<Module*, 4> OwnedModules; |
| 1094 | |
Bob Wilson | a594fab | 2013-02-11 05:37:07 +0000 | [diff] [blame] | 1095 | LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler; |
| 1096 | void *InlineAsmDiagContext; |
Quentin Colombet | b4c44d2 | 2013-12-17 17:47:22 +0000 | [diff] [blame] | 1097 | |
| 1098 | LLVMContext::DiagnosticHandlerTy DiagnosticHandler; |
| 1099 | void *DiagnosticContext; |
Duncan P. N. Exon Smith | 30c9242 | 2014-10-01 18:36:03 +0000 | [diff] [blame] | 1100 | bool RespectDiagnosticFilters; |
Adam Nemet | aad8160 | 2016-07-15 17:23:20 +0000 | [diff] [blame] | 1101 | bool DiagnosticHotnessRequested; |
Adam Nemet | a62b7e1 | 2016-09-27 20:55:07 +0000 | [diff] [blame] | 1102 | std::unique_ptr<yaml::Output> DiagnosticsOutputFile; |
Quentin Colombet | b4c44d2 | 2013-12-17 17:47:22 +0000 | [diff] [blame] | 1103 | |
Juergen Ributzka | 34390c7 | 2014-05-16 02:33:15 +0000 | [diff] [blame] | 1104 | LLVMContext::YieldCallbackTy YieldCallback; |
| 1105 | void *YieldOpaqueHandle; |
| 1106 | |
Justin Lebar | 611c5c2 | 2016-10-10 16:26:13 +0000 | [diff] [blame] | 1107 | typedef DenseMap<APInt, std::unique_ptr<ConstantInt>, DenseMapAPIntKeyInfo> |
| 1108 | IntMapTy; |
Owen Anderson | 20b34ac | 2009-07-16 18:04:31 +0000 | [diff] [blame] | 1109 | IntMapTy IntConstants; |
NAKAMURA Takumi | fc3062f | 2014-12-06 05:57:06 +0000 | [diff] [blame] | 1110 | |
Justin Lebar | 611c5c2 | 2016-10-10 16:26:13 +0000 | [diff] [blame] | 1111 | typedef DenseMap<APFloat, std::unique_ptr<ConstantFP>, DenseMapAPFloatKeyInfo> |
| 1112 | FPMapTy; |
Owen Anderson | c277dc4 | 2009-07-16 19:05:41 +0000 | [diff] [blame] | 1113 | FPMapTy FPConstants; |
Bill Wendling | e38b804 | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 1114 | |
Bill Wendling | 4607f4b | 2012-12-20 01:36:59 +0000 | [diff] [blame] | 1115 | FoldingSet<AttributeImpl> AttrsSet; |
Bill Wendling | 6848e38 | 2012-12-19 22:42:22 +0000 | [diff] [blame] | 1116 | FoldingSet<AttributeSetImpl> AttrsLists; |
Bill Wendling | d2e493b | 2013-01-24 00:06:56 +0000 | [diff] [blame] | 1117 | FoldingSet<AttributeSetNode> AttrsSetNodes; |
Bill Wendling | f86efb9 | 2012-11-20 05:09:20 +0000 | [diff] [blame] | 1118 | |
Duncan P. N. Exon Smith | 3e0430e | 2016-04-06 06:41:54 +0000 | [diff] [blame] | 1119 | StringMap<MDString, BumpPtrAllocator> MDStringCache; |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 1120 | DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata; |
| 1121 | DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues; |
Bill Wendling | e38b804 | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 1122 | |
Owen Anderson | 7349ab9 | 2015-06-01 22:24:01 +0000 | [diff] [blame] | 1123 | DenseMap<const Value*, ValueName*> ValueNames; |
| 1124 | |
Duncan P. N. Exon Smith | 55ca964 | 2015-08-03 17:26:41 +0000 | [diff] [blame] | 1125 | #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ |
| 1126 | DenseSet<CLASS *, CLASS##Info> CLASS##s; |
Duncan P. N. Exon Smith | 104e402 | 2015-02-04 21:46:12 +0000 | [diff] [blame] | 1127 | #include "llvm/IR/Metadata.def" |
Bill Wendling | e38b804 | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 1128 | |
Duncan P. N. Exon Smith | 5ab2be0 | 2016-04-17 03:58:21 +0000 | [diff] [blame] | 1129 | // Optional map for looking up composite types by identifier. |
Duncan P. N. Exon Smith | e8b555c | 2016-04-19 16:06:50 +0000 | [diff] [blame] | 1130 | Optional<DenseMap<const MDString *, DICompositeType *>> DITypeMap; |
Duncan P. N. Exon Smith | 5ab2be0 | 2016-04-17 03:58:21 +0000 | [diff] [blame] | 1131 | |
Jeffrey Yasskin | 2cc2476 | 2010-03-13 01:26:15 +0000 | [diff] [blame] | 1132 | // MDNodes may be uniqued or not uniqued. When they're not uniqued, they |
| 1133 | // aren't in the MDNodeSet, but they're still shared between objects, so no |
Duncan P. N. Exon Smith | 3eef9d1 | 2016-04-19 23:59:13 +0000 | [diff] [blame] | 1134 | // one object can destroy them. Keep track of them here so we can delete |
| 1135 | // them on context teardown. |
| 1136 | std::vector<MDNode *> DistinctMDNodes; |
Duncan P. N. Exon Smith | 50846f8 | 2014-11-18 00:37:17 +0000 | [diff] [blame] | 1137 | |
Justin Lebar | 611c5c2 | 2016-10-10 16:26:13 +0000 | [diff] [blame] | 1138 | DenseMap<Type *, std::unique_ptr<ConstantAggregateZero>> CAZConstants; |
Owen Anderson | 13234f8 | 2009-08-10 18:16:08 +0000 | [diff] [blame] | 1139 | |
Duncan P. N. Exon Smith | 317c139 | 2014-08-19 16:39:58 +0000 | [diff] [blame] | 1140 | typedef ConstantUniqueMap<ConstantArray> ArrayConstantsTy; |
Owen Anderson | edb4a70 | 2009-07-24 23:12:02 +0000 | [diff] [blame] | 1141 | ArrayConstantsTy ArrayConstants; |
Owen Anderson | 39ede7b | 2009-07-21 20:13:12 +0000 | [diff] [blame] | 1142 | |
Duncan P. N. Exon Smith | 317c139 | 2014-08-19 16:39:58 +0000 | [diff] [blame] | 1143 | typedef ConstantUniqueMap<ConstantStruct> StructConstantsTy; |
Owen Anderson | edb4a70 | 2009-07-24 23:12:02 +0000 | [diff] [blame] | 1144 | StructConstantsTy StructConstants; |
Owen Anderson | 909f600 | 2009-07-23 23:25:33 +0000 | [diff] [blame] | 1145 | |
Duncan P. N. Exon Smith | 317c139 | 2014-08-19 16:39:58 +0000 | [diff] [blame] | 1146 | typedef ConstantUniqueMap<ConstantVector> VectorConstantsTy; |
Owen Anderson | edb4a70 | 2009-07-24 23:12:02 +0000 | [diff] [blame] | 1147 | VectorConstantsTy VectorConstants; |
Chris Lattner | c7f9fd4 | 2012-01-23 15:20:12 +0000 | [diff] [blame] | 1148 | |
Justin Lebar | 611c5c2 | 2016-10-10 16:26:13 +0000 | [diff] [blame] | 1149 | DenseMap<PointerType *, std::unique_ptr<ConstantPointerNull>> CPNConstants; |
| 1150 | |
| 1151 | DenseMap<Type *, std::unique_ptr<UndefValue>> UVConstants; |
| 1152 | |
Chris Lattner | 3756b91 | 2012-01-23 22:57:10 +0000 | [diff] [blame] | 1153 | StringMap<ConstantDataSequential*> CDSConstants; |
| 1154 | |
Chandler Carruth | 6a93692 | 2014-01-19 02:13:50 +0000 | [diff] [blame] | 1155 | DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *> |
| 1156 | BlockAddresses; |
Duncan P. N. Exon Smith | 317c139 | 2014-08-19 16:39:58 +0000 | [diff] [blame] | 1157 | ConstantUniqueMap<ConstantExpr> ExprConstants; |
Jeffrey Yasskin | ade270e | 2010-03-21 20:37:19 +0000 | [diff] [blame] | 1158 | |
Duncan P. N. Exon Smith | 317c139 | 2014-08-19 16:39:58 +0000 | [diff] [blame] | 1159 | ConstantUniqueMap<InlineAsm> InlineAsms; |
| 1160 | |
Owen Anderson | 2ad5217 | 2009-07-21 02:47:59 +0000 | [diff] [blame] | 1161 | ConstantInt *TheTrueVal; |
| 1162 | ConstantInt *TheFalseVal; |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 1163 | |
David Majnemer | 2dd41c5 | 2015-11-16 20:55:57 +0000 | [diff] [blame] | 1164 | std::unique_ptr<ConstantTokenNone> TheNoneToken; |
David Majnemer | f0f224d | 2015-11-11 21:57:16 +0000 | [diff] [blame] | 1165 | |
Dan Gohman | 97d2cb8 | 2009-08-25 16:00:35 +0000 | [diff] [blame] | 1166 | // Basic type instances. |
David Majnemer | b611e3f | 2015-08-14 05:09:07 +0000 | [diff] [blame] | 1167 | Type VoidTy, LabelTy, HalfTy, FloatTy, DoubleTy, MetadataTy, TokenTy; |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 1168 | Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy; |
Kit Barton | 7291802 | 2015-04-17 15:32:15 +0000 | [diff] [blame] | 1169 | IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty, Int128Ty; |
Dan Gohman | 97d2cb8 | 2009-08-25 16:00:35 +0000 | [diff] [blame] | 1170 | |
Chris Lattner | 07bd69c | 2011-07-15 05:49:15 +0000 | [diff] [blame] | 1171 | |
| 1172 | /// TypeAllocator - All dynamically allocated types are allocated from this. |
| 1173 | /// They live forever until the context is torn down. |
| 1174 | BumpPtrAllocator TypeAllocator; |
| 1175 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 1176 | DenseMap<unsigned, IntegerType*> IntegerTypes; |
Benjamin Kramer | 3280a5d | 2014-12-06 19:22:54 +0000 | [diff] [blame] | 1177 | |
| 1178 | typedef DenseSet<FunctionType *, FunctionTypeKeyInfo> FunctionTypeSet; |
| 1179 | FunctionTypeSet FunctionTypes; |
| 1180 | typedef DenseSet<StructType *, AnonStructTypeKeyInfo> StructTypeSet; |
| 1181 | StructTypeSet AnonStructTypes; |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 1182 | StringMap<StructType*> NamedStructTypes; |
| 1183 | unsigned NamedStructTypesUniqueID; |
| 1184 | |
| 1185 | DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes; |
| 1186 | DenseMap<std::pair<Type *, unsigned>, VectorType*> VectorTypes; |
| 1187 | DenseMap<Type*, PointerType*> PointerTypes; // Pointers in AddrSpace = 0 |
| 1188 | DenseMap<std::pair<Type*, unsigned>, PointerType*> ASPointerTypes; |
Jeffrey Yasskin | c660b23 | 2010-02-11 06:41:30 +0000 | [diff] [blame] | 1189 | |
Jeffrey Yasskin | 28f2448 | 2009-12-17 19:55:06 +0000 | [diff] [blame] | 1190 | |
Owen Anderson | e8f2185 | 2009-08-18 18:28:58 +0000 | [diff] [blame] | 1191 | /// ValueHandles - This map keeps track of all of the value handles that are |
| 1192 | /// watching a Value*. The Value::HasValueHandle bit is used to know |
Michael Ilseman | 516d703 | 2013-03-01 18:48:54 +0000 | [diff] [blame] | 1193 | /// whether or not a value has an entry in this map. |
Owen Anderson | e8f2185 | 2009-08-18 18:28:58 +0000 | [diff] [blame] | 1194 | typedef DenseMap<Value*, ValueHandleBase*> ValueHandlesTy; |
| 1195 | ValueHandlesTy ValueHandles; |
| 1196 | |
Chris Lattner | a056697 | 2009-12-29 09:01:33 +0000 | [diff] [blame] | 1197 | /// CustomMDKindNames - Map to hold the metadata string to ID mapping. |
| 1198 | StringMap<unsigned> CustomMDKindNames; |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 1199 | |
Duncan P. N. Exon Smith | 391fc56 | 2015-04-24 20:16:42 +0000 | [diff] [blame] | 1200 | /// Collection of per-instruction metadata used in this context. |
Duncan P. N. Exon Smith | cbc28dc | 2015-04-24 20:36:25 +0000 | [diff] [blame] | 1201 | DenseMap<const Instruction *, MDAttachmentMap> InstructionMetadata; |
Duncan P. N. Exon Smith | 391fc56 | 2015-04-24 20:16:42 +0000 | [diff] [blame] | 1202 | |
Peter Collingbourne | cceae7f | 2016-05-31 23:01:54 +0000 | [diff] [blame] | 1203 | /// Collection of per-GlobalObject metadata used in this context. |
Peter Collingbourne | 382d81c | 2016-06-01 01:17:57 +0000 | [diff] [blame] | 1204 | DenseMap<const GlobalObject *, MDGlobalAttachmentMap> GlobalObjectMetadata; |
Duncan P. N. Exon Smith | e2510cd | 2015-04-24 21:51:02 +0000 | [diff] [blame] | 1205 | |
Reid Kleckner | 443423e | 2017-01-10 23:23:58 +0000 | [diff] [blame] | 1206 | /// Collection of per-GlobalObject sections used in this context. |
| 1207 | DenseMap<const GlobalObject *, StringRef> GlobalObjectSections; |
| 1208 | |
| 1209 | /// Stable collection of section strings. |
| 1210 | StringSet<> SectionStrings; |
| 1211 | |
Diego Novillo | f5041ce | 2014-03-03 20:06:11 +0000 | [diff] [blame] | 1212 | /// DiscriminatorTable - This table maps file:line locations to an |
| 1213 | /// integer representing the next DWARF path discriminator to assign to |
| 1214 | /// instructions in different blocks at the same location. |
| 1215 | DenseMap<std::pair<const char *, unsigned>, unsigned> DiscriminatorTable; |
| 1216 | |
Chris Lattner | 8cb2aeb | 2010-04-01 00:37:44 +0000 | [diff] [blame] | 1217 | int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx); |
| 1218 | int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx); |
Philip Reames | 2b45395 | 2015-01-16 20:07:33 +0000 | [diff] [blame] | 1219 | |
Sanjoy Das | 9303c24 | 2015-09-24 19:14:18 +0000 | [diff] [blame] | 1220 | /// \brief A set of interned tags for operand bundles. The StringMap maps |
| 1221 | /// bundle tags to their IDs. |
| 1222 | /// |
| 1223 | /// \see LLVMContext::getOperandBundleTagID |
| 1224 | StringMap<uint32_t> BundleTagCache; |
| 1225 | |
| 1226 | StringMapEntry<uint32_t> *getOrInsertBundleTag(StringRef Tag); |
| 1227 | void getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const; |
| 1228 | uint32_t getOperandBundleTagID(StringRef Tag) const; |
| 1229 | |
Mehdi Amini | 599ebf2 | 2016-01-08 02:28:20 +0000 | [diff] [blame] | 1230 | /// Maintain the GC name for each function. |
| 1231 | /// |
| 1232 | /// This saves allocating an additional word in Function for programs which |
| 1233 | /// do not use GC (i.e., most programs) at the cost of increased overhead for |
| 1234 | /// clients which do use GC. |
| 1235 | DenseMap<const Function*, std::string> GCNames; |
| 1236 | |
Mehdi Amini | 09b4a8d | 2016-03-10 01:28:54 +0000 | [diff] [blame] | 1237 | /// Flag to indicate if Value (other than GlobalValue) retains their name or |
| 1238 | /// not. |
| 1239 | bool DiscardValueNames = false; |
| 1240 | |
Jeffrey Yasskin | 4cfb3a7 | 2010-03-21 21:17:34 +0000 | [diff] [blame] | 1241 | LLVMContextImpl(LLVMContext &C); |
| 1242 | ~LLVMContextImpl(); |
Manman Ren | dab999d | 2015-01-20 19:24:59 +0000 | [diff] [blame] | 1243 | |
| 1244 | /// Destroy the ConstantArrays if they are not used. |
| 1245 | void dropTriviallyDeadConstantArrays(); |
Andrew Kaylor | aa641a5 | 2016-04-22 22:06:11 +0000 | [diff] [blame] | 1246 | |
| 1247 | /// \brief Access the object which manages optimization bisection for failure |
| 1248 | /// analysis. |
| 1249 | OptBisect &getOptBisect(); |
Owen Anderson | 8e66e0b | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 1250 | }; |
| 1251 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 1252 | } |
Owen Anderson | 8e66e0b | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 1253 | |
Owen Anderson | 36f62e5 | 2009-06-30 17:06:46 +0000 | [diff] [blame] | 1254 | #endif |