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