/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/IR/ConstantsContext.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- ConstantsContext.h - Constants-related Context Interals -*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | // |
10 | | // This file defines various helper methods and classes used by |
11 | | // LLVMContextImpl for creating and managing constants. |
12 | | // |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_LIB_IR_CONSTANTSCONTEXT_H |
16 | | #define LLVM_LIB_IR_CONSTANTSCONTEXT_H |
17 | | |
18 | | #include "llvm/ADT/ArrayRef.h" |
19 | | #include "llvm/ADT/DenseMapInfo.h" |
20 | | #include "llvm/ADT/DenseSet.h" |
21 | | #include "llvm/ADT/Hashing.h" |
22 | | #include "llvm/ADT/None.h" |
23 | | #include "llvm/ADT/SmallVector.h" |
24 | | #include "llvm/ADT/StringRef.h" |
25 | | #include "llvm/IR/Constant.h" |
26 | | #include "llvm/IR/Constants.h" |
27 | | #include "llvm/IR/DerivedTypes.h" |
28 | | #include "llvm/IR/InlineAsm.h" |
29 | | #include "llvm/IR/Instruction.h" |
30 | | #include "llvm/IR/OperandTraits.h" |
31 | | #include "llvm/Support/Casting.h" |
32 | | #include "llvm/Support/Debug.h" |
33 | | #include "llvm/Support/ErrorHandling.h" |
34 | | #include "llvm/Support/raw_ostream.h" |
35 | | #include <cassert> |
36 | | #include <cstddef> |
37 | | #include <cstdint> |
38 | | #include <utility> |
39 | | |
40 | | #define DEBUG_TYPE "ir" |
41 | | |
42 | | namespace llvm { |
43 | | |
44 | | /// UnaryConstantExpr - This class is private to Constants.cpp, and is used |
45 | | /// behind the scenes to implement unary constant exprs. |
46 | | class UnaryConstantExpr : public ConstantExpr { |
47 | | public: |
48 | | UnaryConstantExpr(unsigned Opcode, Constant *C, Type *Ty) |
49 | 159k | : ConstantExpr(Ty, Opcode, &Op<0>(), 1) { |
50 | 159k | Op<0>() = C; |
51 | 159k | } |
52 | | |
53 | | // allocate space for exactly one operand |
54 | 159k | void *operator new(size_t s) { |
55 | 159k | return User::operator new(s, 1); |
56 | 159k | } |
57 | | |
58 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
59 | | }; |
60 | | |
61 | | /// BinaryConstantExpr - This class is private to Constants.cpp, and is used |
62 | | /// behind the scenes to implement binary constant exprs. |
63 | | class BinaryConstantExpr : public ConstantExpr { |
64 | | public: |
65 | | BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2, |
66 | | unsigned Flags) |
67 | 3.63k | : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) { |
68 | 3.63k | Op<0>() = C1; |
69 | 3.63k | Op<1>() = C2; |
70 | 3.63k | SubclassOptionalData = Flags; |
71 | 3.63k | } |
72 | | |
73 | | // allocate space for exactly two operands |
74 | 3.63k | void *operator new(size_t s) { |
75 | 3.63k | return User::operator new(s, 2); |
76 | 3.63k | } |
77 | | |
78 | | /// Transparently provide more efficient getOperand methods. |
79 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
80 | | }; |
81 | | |
82 | | /// SelectConstantExpr - This class is private to Constants.cpp, and is used |
83 | | /// behind the scenes to implement select constant exprs. |
84 | | class SelectConstantExpr : public ConstantExpr { |
85 | | public: |
86 | | SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) |
87 | 84 | : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { |
88 | 84 | Op<0>() = C1; |
89 | 84 | Op<1>() = C2; |
90 | 84 | Op<2>() = C3; |
91 | 84 | } |
92 | | |
93 | | // allocate space for exactly three operands |
94 | 84 | void *operator new(size_t s) { |
95 | 84 | return User::operator new(s, 3); |
96 | 84 | } |
97 | | |
98 | | /// Transparently provide more efficient getOperand methods. |
99 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
100 | | }; |
101 | | |
102 | | /// ExtractElementConstantExpr - This class is private to |
103 | | /// Constants.cpp, and is used behind the scenes to implement |
104 | | /// extractelement constant exprs. |
105 | | class ExtractElementConstantExpr : public ConstantExpr { |
106 | | public: |
107 | | ExtractElementConstantExpr(Constant *C1, Constant *C2) |
108 | | : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(), |
109 | 54 | Instruction::ExtractElement, &Op<0>(), 2) { |
110 | 54 | Op<0>() = C1; |
111 | 54 | Op<1>() = C2; |
112 | 54 | } |
113 | | |
114 | | // allocate space for exactly two operands |
115 | 54 | void *operator new(size_t s) { |
116 | 54 | return User::operator new(s, 2); |
117 | 54 | } |
118 | | |
119 | | /// Transparently provide more efficient getOperand methods. |
120 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
121 | | }; |
122 | | |
123 | | /// InsertElementConstantExpr - This class is private to |
124 | | /// Constants.cpp, and is used behind the scenes to implement |
125 | | /// insertelement constant exprs. |
126 | | class InsertElementConstantExpr : public ConstantExpr { |
127 | | public: |
128 | | InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) |
129 | | : ConstantExpr(C1->getType(), Instruction::InsertElement, |
130 | 0 | &Op<0>(), 3) { |
131 | 0 | Op<0>() = C1; |
132 | 0 | Op<1>() = C2; |
133 | 0 | Op<2>() = C3; |
134 | 0 | } |
135 | | |
136 | | // allocate space for exactly three operands |
137 | 0 | void *operator new(size_t s) { |
138 | 0 | return User::operator new(s, 3); |
139 | 0 | } |
140 | | |
141 | | /// Transparently provide more efficient getOperand methods. |
142 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
143 | | }; |
144 | | |
145 | | /// ShuffleVectorConstantExpr - This class is private to |
146 | | /// Constants.cpp, and is used behind the scenes to implement |
147 | | /// shufflevector constant exprs. |
148 | | class ShuffleVectorConstantExpr : public ConstantExpr { |
149 | | public: |
150 | | ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) |
151 | | : ConstantExpr(VectorType::get( |
152 | | cast<VectorType>(C1->getType())->getElementType(), |
153 | | cast<VectorType>(C3->getType())->getNumElements()), |
154 | | Instruction::ShuffleVector, |
155 | 0 | &Op<0>(), 3) { |
156 | 0 | Op<0>() = C1; |
157 | 0 | Op<1>() = C2; |
158 | 0 | Op<2>() = C3; |
159 | 0 | } |
160 | | |
161 | | // allocate space for exactly three operands |
162 | 0 | void *operator new(size_t s) { |
163 | 0 | return User::operator new(s, 3); |
164 | 0 | } |
165 | | |
166 | | /// Transparently provide more efficient getOperand methods. |
167 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
168 | | }; |
169 | | |
170 | | /// ExtractValueConstantExpr - This class is private to |
171 | | /// Constants.cpp, and is used behind the scenes to implement |
172 | | /// extractvalue constant exprs. |
173 | | class ExtractValueConstantExpr : public ConstantExpr { |
174 | | public: |
175 | | ExtractValueConstantExpr(Constant *Agg, ArrayRef<unsigned> IdxList, |
176 | | Type *DestTy) |
177 | | : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1), |
178 | 4 | Indices(IdxList.begin(), IdxList.end()) { |
179 | 4 | Op<0>() = Agg; |
180 | 4 | } |
181 | | |
182 | | // allocate space for exactly one operand |
183 | 4 | void *operator new(size_t s) { |
184 | 4 | return User::operator new(s, 1); |
185 | 4 | } |
186 | | |
187 | | /// Indices - These identify which value to extract. |
188 | | const SmallVector<unsigned, 4> Indices; |
189 | | |
190 | | /// Transparently provide more efficient getOperand methods. |
191 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
192 | | |
193 | 6 | static bool classof(const ConstantExpr *CE) { |
194 | 6 | return CE->getOpcode() == Instruction::ExtractValue; |
195 | 6 | } |
196 | 0 | static bool classof(const Value *V) { |
197 | 0 | return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)); |
198 | 0 | } |
199 | | }; |
200 | | |
201 | | /// InsertValueConstantExpr - This class is private to |
202 | | /// Constants.cpp, and is used behind the scenes to implement |
203 | | /// insertvalue constant exprs. |
204 | | class InsertValueConstantExpr : public ConstantExpr { |
205 | | public: |
206 | | InsertValueConstantExpr(Constant *Agg, Constant *Val, |
207 | | ArrayRef<unsigned> IdxList, Type *DestTy) |
208 | | : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2), |
209 | 1 | Indices(IdxList.begin(), IdxList.end()) { |
210 | 1 | Op<0>() = Agg; |
211 | 1 | Op<1>() = Val; |
212 | 1 | } |
213 | | |
214 | | // allocate space for exactly one operand |
215 | 1 | void *operator new(size_t s) { |
216 | 1 | return User::operator new(s, 2); |
217 | 1 | } |
218 | | |
219 | | /// Indices - These identify the position for the insertion. |
220 | | const SmallVector<unsigned, 4> Indices; |
221 | | |
222 | | /// Transparently provide more efficient getOperand methods. |
223 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
224 | | |
225 | 0 | static bool classof(const ConstantExpr *CE) { |
226 | 0 | return CE->getOpcode() == Instruction::InsertValue; |
227 | 0 | } |
228 | 0 | static bool classof(const Value *V) { |
229 | 0 | return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)); |
230 | 0 | } |
231 | | }; |
232 | | |
233 | | /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is |
234 | | /// used behind the scenes to implement getelementpr constant exprs. |
235 | | class GetElementPtrConstantExpr : public ConstantExpr { |
236 | | Type *SrcElementTy; |
237 | | Type *ResElementTy; |
238 | | |
239 | | GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C, |
240 | | ArrayRef<Constant *> IdxList, Type *DestTy); |
241 | | |
242 | | public: |
243 | | static GetElementPtrConstantExpr *Create(Type *SrcElementTy, Constant *C, |
244 | | ArrayRef<Constant *> IdxList, |
245 | 986k | Type *DestTy, unsigned Flags) { |
246 | 986k | GetElementPtrConstantExpr *Result = new (IdxList.size() + 1) |
247 | 986k | GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy); |
248 | 986k | Result->SubclassOptionalData = Flags; |
249 | 986k | return Result; |
250 | 986k | } |
251 | | |
252 | | Type *getSourceElementType() const; |
253 | | Type *getResultElementType() const; |
254 | | |
255 | | /// Transparently provide more efficient getOperand methods. |
256 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
257 | | |
258 | 0 | static bool classof(const ConstantExpr *CE) { |
259 | 0 | return CE->getOpcode() == Instruction::GetElementPtr; |
260 | 0 | } |
261 | 0 | static bool classof(const Value *V) { |
262 | 0 | return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)); |
263 | 0 | } |
264 | | }; |
265 | | |
266 | | // CompareConstantExpr - This class is private to Constants.cpp, and is used |
267 | | // behind the scenes to implement ICmp and FCmp constant expressions. This is |
268 | | // needed in order to store the predicate value for these instructions. |
269 | | class CompareConstantExpr : public ConstantExpr { |
270 | | public: |
271 | | unsigned short predicate; |
272 | | CompareConstantExpr(Type *ty, Instruction::OtherOps opc, |
273 | | unsigned short pred, Constant* LHS, Constant* RHS) |
274 | 575 | : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) { |
275 | 575 | Op<0>() = LHS; |
276 | 575 | Op<1>() = RHS; |
277 | 575 | } |
278 | | |
279 | | // allocate space for exactly two operands |
280 | 575 | void *operator new(size_t s) { |
281 | 575 | return User::operator new(s, 2); |
282 | 575 | } |
283 | | |
284 | | /// Transparently provide more efficient getOperand methods. |
285 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); |
286 | | |
287 | 0 | static bool classof(const ConstantExpr *CE) { |
288 | 0 | return CE->getOpcode() == Instruction::ICmp || |
289 | 0 | CE->getOpcode() == Instruction::FCmp; |
290 | 0 | } |
291 | 0 | static bool classof(const Value *V) { |
292 | 0 | return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)); |
293 | 0 | } |
294 | | }; |
295 | | |
296 | | template <> |
297 | | struct OperandTraits<UnaryConstantExpr> |
298 | | : public FixedNumOperandTraits<UnaryConstantExpr, 1> {}; |
299 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value) |
300 | | |
301 | | template <> |
302 | | struct OperandTraits<BinaryConstantExpr> |
303 | | : public FixedNumOperandTraits<BinaryConstantExpr, 2> {}; |
304 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) |
305 | | |
306 | | template <> |
307 | | struct OperandTraits<SelectConstantExpr> |
308 | | : public FixedNumOperandTraits<SelectConstantExpr, 3> {}; |
309 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) |
310 | | |
311 | | template <> |
312 | | struct OperandTraits<ExtractElementConstantExpr> |
313 | | : public FixedNumOperandTraits<ExtractElementConstantExpr, 2> {}; |
314 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value) |
315 | | |
316 | | template <> |
317 | | struct OperandTraits<InsertElementConstantExpr> |
318 | | : public FixedNumOperandTraits<InsertElementConstantExpr, 3> {}; |
319 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value) |
320 | | |
321 | | template <> |
322 | | struct OperandTraits<ShuffleVectorConstantExpr> |
323 | | : public FixedNumOperandTraits<ShuffleVectorConstantExpr, 3> {}; |
324 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) |
325 | | |
326 | | template <> |
327 | | struct OperandTraits<ExtractValueConstantExpr> |
328 | | : public FixedNumOperandTraits<ExtractValueConstantExpr, 1> {}; |
329 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueConstantExpr, Value) |
330 | | |
331 | | template <> |
332 | | struct OperandTraits<InsertValueConstantExpr> |
333 | | : public FixedNumOperandTraits<InsertValueConstantExpr, 2> {}; |
334 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value) |
335 | | |
336 | | template <> |
337 | | struct OperandTraits<GetElementPtrConstantExpr> |
338 | | : public VariadicOperandTraits<GetElementPtrConstantExpr, 1> {}; |
339 | | |
340 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value) |
341 | | |
342 | | template <> |
343 | | struct OperandTraits<CompareConstantExpr> |
344 | | : public FixedNumOperandTraits<CompareConstantExpr, 2> {}; |
345 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value) |
346 | | |
347 | | template <class ConstantClass> struct ConstantAggrKeyType; |
348 | | struct InlineAsmKeyType; |
349 | | struct ConstantExprKeyType; |
350 | | |
351 | | template <class ConstantClass> struct ConstantInfo; |
352 | | template <> struct ConstantInfo<ConstantExpr> { |
353 | | using ValType = ConstantExprKeyType; |
354 | | using TypeClass = Type; |
355 | | }; |
356 | | template <> struct ConstantInfo<InlineAsm> { |
357 | | using ValType = InlineAsmKeyType; |
358 | | using TypeClass = PointerType; |
359 | | }; |
360 | | template <> struct ConstantInfo<ConstantArray> { |
361 | | using ValType = ConstantAggrKeyType<ConstantArray>; |
362 | | using TypeClass = ArrayType; |
363 | | }; |
364 | | template <> struct ConstantInfo<ConstantStruct> { |
365 | | using ValType = ConstantAggrKeyType<ConstantStruct>; |
366 | | using TypeClass = StructType; |
367 | | }; |
368 | | template <> struct ConstantInfo<ConstantVector> { |
369 | | using ValType = ConstantAggrKeyType<ConstantVector>; |
370 | | using TypeClass = VectorType; |
371 | | }; |
372 | | |
373 | | template <class ConstantClass> struct ConstantAggrKeyType { |
374 | | ArrayRef<Constant *> Operands; |
375 | | |
376 | 430k | ConstantAggrKeyType(ArrayRef<Constant *> Operands) : Operands(Operands) {} llvm::ConstantAggrKeyType<llvm::ConstantVector>::ConstantAggrKeyType(llvm::ArrayRef<llvm::Constant*>) Line | Count | Source | 376 | 213k | ConstantAggrKeyType(ArrayRef<Constant *> Operands) : Operands(Operands) {} |
llvm::ConstantAggrKeyType<llvm::ConstantArray>::ConstantAggrKeyType(llvm::ArrayRef<llvm::Constant*>) Line | Count | Source | 376 | 30.3k | ConstantAggrKeyType(ArrayRef<Constant *> Operands) : Operands(Operands) {} |
llvm::ConstantAggrKeyType<llvm::ConstantStruct>::ConstantAggrKeyType(llvm::ArrayRef<llvm::Constant*>) Line | Count | Source | 376 | 186k | ConstantAggrKeyType(ArrayRef<Constant *> Operands) : Operands(Operands) {} |
|
377 | | |
378 | | ConstantAggrKeyType(ArrayRef<Constant *> Operands, const ConstantClass *) |
379 | 681 | : Operands(Operands) {} llvm::ConstantAggrKeyType<llvm::ConstantStruct>::ConstantAggrKeyType(llvm::ArrayRef<llvm::Constant*>, llvm::ConstantStruct const*) Line | Count | Source | 379 | 40 | : Operands(Operands) {} |
llvm::ConstantAggrKeyType<llvm::ConstantArray>::ConstantAggrKeyType(llvm::ArrayRef<llvm::Constant*>, llvm::ConstantArray const*) Line | Count | Source | 379 | 635 | : Operands(Operands) {} |
llvm::ConstantAggrKeyType<llvm::ConstantVector>::ConstantAggrKeyType(llvm::ArrayRef<llvm::Constant*>, llvm::ConstantVector const*) Line | Count | Source | 379 | 6 | : Operands(Operands) {} |
|
380 | | |
381 | | ConstantAggrKeyType(const ConstantClass *C, |
382 | 78.5k | SmallVectorImpl<Constant *> &Storage) { |
383 | 78.5k | assert(Storage.empty() && "Expected empty storage"); |
384 | 460k | for (unsigned I = 0, E = C->getNumOperands(); I != E460k ; ++I381k ) |
385 | 381k | Storage.push_back(C->getOperand(I)); |
386 | 78.5k | Operands = Storage; |
387 | 78.5k | } llvm::ConstantAggrKeyType<llvm::ConstantArray>::ConstantAggrKeyType(llvm::ConstantArray const*, llvm::SmallVectorImpl<llvm::Constant*>&) Line | Count | Source | 382 | 14.2k | SmallVectorImpl<Constant *> &Storage) { | 383 | 14.2k | assert(Storage.empty() && "Expected empty storage"); | 384 | 76.1k | for (unsigned I = 0, E = C->getNumOperands(); I != E76.1k ; ++I61.9k ) | 385 | 61.9k | Storage.push_back(C->getOperand(I)); | 386 | 14.2k | Operands = Storage; | 387 | 14.2k | } |
llvm::ConstantAggrKeyType<llvm::ConstantStruct>::ConstantAggrKeyType(llvm::ConstantStruct const*, llvm::SmallVectorImpl<llvm::Constant*>&) Line | Count | Source | 382 | 44.7k | SmallVectorImpl<Constant *> &Storage) { | 383 | 44.7k | assert(Storage.empty() && "Expected empty storage"); | 384 | 226k | for (unsigned I = 0, E = C->getNumOperands(); I != E226k ; ++I182k ) | 385 | 182k | Storage.push_back(C->getOperand(I)); | 386 | 44.7k | Operands = Storage; | 387 | 44.7k | } |
llvm::ConstantAggrKeyType<llvm::ConstantVector>::ConstantAggrKeyType(llvm::ConstantVector const*, llvm::SmallVectorImpl<llvm::Constant*>&) Line | Count | Source | 382 | 19.6k | SmallVectorImpl<Constant *> &Storage) { | 383 | 19.6k | assert(Storage.empty() && "Expected empty storage"); | 384 | 157k | for (unsigned I = 0, E = C->getNumOperands(); I != E157k ; ++I137k ) | 385 | 137k | Storage.push_back(C->getOperand(I)); | 386 | 19.6k | Operands = Storage; | 387 | 19.6k | } |
|
388 | | |
389 | | bool operator==(const ConstantAggrKeyType &X) const { |
390 | | return Operands == X.Operands; |
391 | | } |
392 | | |
393 | 280k | bool operator==(const ConstantClass *C) const { |
394 | 280k | if (Operands.size() != C->getNumOperands()) |
395 | 0 | return false; |
396 | 941k | for (unsigned I = 0, E = Operands.size(); 280k I != E941k ; ++I661k ) |
397 | 779k | if (779k Operands[I] != C->getOperand(I)779k ) |
398 | 118k | return false; |
399 | 162k | return true; |
400 | 280k | } llvm::ConstantAggrKeyType<llvm::ConstantArray>::operator==(llvm::ConstantArray const*) const Line | Count | Source | 393 | 7.26k | bool operator==(const ConstantClass *C) const { | 394 | 7.26k | if (Operands.size() != C->getNumOperands()) | 395 | 0 | return false; | 396 | 23.8k | for (unsigned I = 0, E = Operands.size(); 7.26k I != E23.8k ; ++I16.5k ) | 397 | 20.7k | if (20.7k Operands[I] != C->getOperand(I)20.7k ) | 398 | 4.19k | return false; | 399 | 3.06k | return true; | 400 | 7.26k | } |
llvm::ConstantAggrKeyType<llvm::ConstantStruct>::operator==(llvm::ConstantStruct const*) const Line | Count | Source | 393 | 63.3k | bool operator==(const ConstantClass *C) const { | 394 | 63.3k | if (Operands.size() != C->getNumOperands()) | 395 | 0 | return false; | 396 | 88.9k | for (unsigned I = 0, E = Operands.size(); 63.3k I != E88.9k ; ++I25.6k ) | 397 | 82.9k | if (82.9k Operands[I] != C->getOperand(I)82.9k ) | 398 | 57.3k | return false; | 399 | 6.04k | return true; | 400 | 63.3k | } |
llvm::ConstantAggrKeyType<llvm::ConstantVector>::operator==(llvm::ConstantVector const*) const Line | Count | Source | 393 | 210k | bool operator==(const ConstantClass *C) const { | 394 | 210k | if (Operands.size() != C->getNumOperands()) | 395 | 0 | return false; | 396 | 829k | for (unsigned I = 0, E = Operands.size(); 210k I != E829k ; ++I618k ) | 397 | 675k | if (675k Operands[I] != C->getOperand(I)675k ) | 398 | 57.1k | return false; | 399 | 153k | return true; | 400 | 210k | } |
|
401 | | |
402 | 510k | unsigned getHash() const { |
403 | 510k | return hash_combine_range(Operands.begin(), Operands.end()); |
404 | 510k | } llvm::ConstantAggrKeyType<llvm::ConstantVector>::getHash() const Line | Count | Source | 402 | 233k | unsigned getHash() const { | 403 | 233k | return hash_combine_range(Operands.begin(), Operands.end()); | 404 | 233k | } |
llvm::ConstantAggrKeyType<llvm::ConstantArray>::getHash() const Line | Count | Source | 402 | 45.2k | unsigned getHash() const { | 403 | 45.2k | return hash_combine_range(Operands.begin(), Operands.end()); | 404 | 45.2k | } |
llvm::ConstantAggrKeyType<llvm::ConstantStruct>::getHash() const Line | Count | Source | 402 | 231k | unsigned getHash() const { | 403 | 231k | return hash_combine_range(Operands.begin(), Operands.end()); | 404 | 231k | } |
|
405 | | |
406 | | using TypeClass = typename ConstantInfo<ConstantClass>::TypeClass; |
407 | | |
408 | 268k | ConstantClass *create(TypeClass *Ty) const { |
409 | 268k | return new (Operands.size()) ConstantClass(Ty, Operands); |
410 | 268k | } llvm::ConstantAggrKeyType<llvm::ConstantStruct>::create(llvm::StructType*) const Line | Count | Source | 408 | 180k | ConstantClass *create(TypeClass *Ty) const { | 409 | 180k | return new (Operands.size()) ConstantClass(Ty, Operands); | 410 | 180k | } |
llvm::ConstantAggrKeyType<llvm::ConstantVector>::create(llvm::VectorType*) const Line | Count | Source | 408 | 60.7k | ConstantClass *create(TypeClass *Ty) const { | 409 | 60.7k | return new (Operands.size()) ConstantClass(Ty, Operands); | 410 | 60.7k | } |
llvm::ConstantAggrKeyType<llvm::ConstantArray>::create(llvm::ArrayType*) const Line | Count | Source | 408 | 27.2k | ConstantClass *create(TypeClass *Ty) const { | 409 | 27.2k | return new (Operands.size()) ConstantClass(Ty, Operands); | 410 | 27.2k | } |
|
411 | | }; |
412 | | |
413 | | struct InlineAsmKeyType { |
414 | | StringRef AsmString; |
415 | | StringRef Constraints; |
416 | | FunctionType *FTy; |
417 | | bool HasSideEffects; |
418 | | bool IsAlignStack; |
419 | | InlineAsm::AsmDialect AsmDialect; |
420 | | |
421 | | InlineAsmKeyType(StringRef AsmString, StringRef Constraints, |
422 | | FunctionType *FTy, bool HasSideEffects, bool IsAlignStack, |
423 | | InlineAsm::AsmDialect AsmDialect) |
424 | | : AsmString(AsmString), Constraints(Constraints), FTy(FTy), |
425 | | HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack), |
426 | 12.8k | AsmDialect(AsmDialect) {} |
427 | | |
428 | | InlineAsmKeyType(const InlineAsm *Asm, SmallVectorImpl<Constant *> &) |
429 | | : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()), |
430 | | FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()), |
431 | 522 | IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()) {} |
432 | | |
433 | 0 | bool operator==(const InlineAsmKeyType &X) const { |
434 | 0 | return HasSideEffects == X.HasSideEffects && |
435 | 0 | IsAlignStack == X.IsAlignStack && AsmDialect == X.AsmDialect && |
436 | 0 | AsmString == X.AsmString && Constraints == X.Constraints && |
437 | 0 | FTy == X.FTy; |
438 | 0 | } |
439 | | |
440 | 9.31k | bool operator==(const InlineAsm *Asm) const { |
441 | 9.31k | return HasSideEffects == Asm->hasSideEffects() && |
442 | 9.31k | IsAlignStack == Asm->isAlignStack() && |
443 | 9.31k | AsmDialect == Asm->getDialect() && |
444 | 9.31k | AsmString == Asm->getAsmString() && |
445 | 8.71k | Constraints == Asm->getConstraintString() && |
446 | 8.19k | FTy == Asm->getFunctionType(); |
447 | 9.31k | } |
448 | | |
449 | 13.3k | unsigned getHash() const { |
450 | 13.3k | return hash_combine(AsmString, Constraints, HasSideEffects, IsAlignStack, |
451 | 13.3k | AsmDialect, FTy); |
452 | 13.3k | } |
453 | | |
454 | | using TypeClass = ConstantInfo<InlineAsm>::TypeClass; |
455 | | |
456 | 4.62k | InlineAsm *create(TypeClass *Ty) const { |
457 | 4.62k | assert(PointerType::getUnqual(FTy) == Ty); |
458 | 4.62k | return new InlineAsm(FTy, AsmString, Constraints, HasSideEffects, |
459 | 4.62k | IsAlignStack, AsmDialect); |
460 | 4.62k | } |
461 | | }; |
462 | | |
463 | | struct ConstantExprKeyType { |
464 | | uint8_t Opcode; |
465 | | uint8_t SubclassOptionalData; |
466 | | uint16_t SubclassData; |
467 | | ArrayRef<Constant *> Ops; |
468 | | ArrayRef<unsigned> Indexes; |
469 | | Type *ExplicitTy; |
470 | | |
471 | | ConstantExprKeyType(unsigned Opcode, ArrayRef<Constant *> Ops, |
472 | | unsigned short SubclassData = 0, |
473 | | unsigned short SubclassOptionalData = 0, |
474 | | ArrayRef<unsigned> Indexes = None, |
475 | | Type *ExplicitTy = nullptr) |
476 | | : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData), |
477 | | SubclassData(SubclassData), Ops(Ops), Indexes(Indexes), |
478 | 26.9M | ExplicitTy(ExplicitTy) {} |
479 | | |
480 | | ConstantExprKeyType(ArrayRef<Constant *> Operands, const ConstantExpr *CE) |
481 | | : Opcode(CE->getOpcode()), |
482 | | SubclassOptionalData(CE->getRawSubclassOptionalData()), |
483 | | SubclassData(CE->isCompare() ? CE->getPredicate() : 0), Ops(Operands), |
484 | 34.7k | Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) {} |
485 | | |
486 | | ConstantExprKeyType(const ConstantExpr *CE, |
487 | | SmallVectorImpl<Constant *> &Storage) |
488 | | : Opcode(CE->getOpcode()), |
489 | | SubclassOptionalData(CE->getRawSubclassOptionalData()), |
490 | | SubclassData(CE->isCompare() ? CE->getPredicate() : 0), |
491 | 1.10M | Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) { |
492 | 1.10M | assert(Storage.empty() && "Expected empty storage"); |
493 | 4.06M | for (unsigned I = 0, E = CE->getNumOperands(); I != E4.06M ; ++I2.95M ) |
494 | 2.95M | Storage.push_back(CE->getOperand(I)); |
495 | 1.10M | Ops = Storage; |
496 | 1.10M | } |
497 | | |
498 | 0 | bool operator==(const ConstantExprKeyType &X) const { |
499 | 0 | return Opcode == X.Opcode && SubclassData == X.SubclassData && |
500 | 0 | SubclassOptionalData == X.SubclassOptionalData && Ops == X.Ops && |
501 | 0 | Indexes == X.Indexes; |
502 | 0 | } |
503 | | |
504 | 36.1M | bool operator==(const ConstantExpr *CE) const { |
505 | 36.1M | if (Opcode != CE->getOpcode()) |
506 | 406k | return false; |
507 | 35.7M | if (35.7M SubclassOptionalData != CE->getRawSubclassOptionalData()35.7M ) |
508 | 44.5k | return false; |
509 | 35.6M | if (35.6M Ops.size() != CE->getNumOperands()35.6M ) |
510 | 85.6k | return false; |
511 | 35.5M | if (35.5M SubclassData != (CE->isCompare() ? 35.5M CE->getPredicate()5.13k : 035.5M )) |
512 | 543 | return false; |
513 | 106M | for (unsigned I = 0, E = Ops.size(); 35.5M I != E106M ; ++I71.2M ) |
514 | 80.9M | if (80.9M Ops[I] != CE->getOperand(I)80.9M ) |
515 | 9.74M | return false; |
516 | 25.8M | if (25.8M Indexes != (CE->hasIndices() ? 25.8M CE->getIndices()0 : ArrayRef<unsigned>()25.8M )) |
517 | 0 | return false; |
518 | 25.8M | return true; |
519 | 36.1M | } |
520 | | |
521 | 28.0M | unsigned getHash() const { |
522 | 28.0M | return hash_combine(Opcode, SubclassOptionalData, SubclassData, |
523 | 28.0M | hash_combine_range(Ops.begin(), Ops.end()), |
524 | 28.0M | hash_combine_range(Indexes.begin(), Indexes.end())); |
525 | 28.0M | } |
526 | | |
527 | | using TypeClass = ConstantInfo<ConstantExpr>::TypeClass; |
528 | | |
529 | 1.15M | ConstantExpr *create(TypeClass *Ty) const { |
530 | 1.15M | switch (Opcode) { |
531 | 163k | default: |
532 | 163k | if (Instruction::isCast(Opcode)) |
533 | 159k | return new UnaryConstantExpr(Opcode, Ops[0], Ty); |
534 | 3.63k | if (3.63k (Opcode >= Instruction::BinaryOpsBegin && |
535 | 3.63k | Opcode < Instruction::BinaryOpsEnd)) |
536 | 3.63k | return new BinaryConstantExpr(Opcode, Ops[0], Ops[1], |
537 | 3.63k | SubclassOptionalData); |
538 | 0 | llvm_unreachable0 ("Invalid ConstantExpr!"); |
539 | 84 | case Instruction::Select: |
540 | 84 | return new SelectConstantExpr(Ops[0], Ops[1], Ops[2]); |
541 | 54 | case Instruction::ExtractElement: |
542 | 54 | return new ExtractElementConstantExpr(Ops[0], Ops[1]); |
543 | 0 | case Instruction::InsertElement: |
544 | 0 | return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]); |
545 | 0 | case Instruction::ShuffleVector: |
546 | 0 | return new ShuffleVectorConstantExpr(Ops[0], Ops[1], Ops[2]); |
547 | 1 | case Instruction::InsertValue: |
548 | 1 | return new InsertValueConstantExpr(Ops[0], Ops[1], Indexes, Ty); |
549 | 4 | case Instruction::ExtractValue: |
550 | 4 | return new ExtractValueConstantExpr(Ops[0], Indexes, Ty); |
551 | 986k | case Instruction::GetElementPtr: |
552 | 986k | return GetElementPtrConstantExpr::Create( |
553 | 986k | ExplicitTy ? ExplicitTy |
554 | 0 | : cast<PointerType>(Ops[0]->getType()->getScalarType()) |
555 | 0 | ->getElementType(), |
556 | 986k | Ops[0], Ops.slice(1), Ty, SubclassOptionalData); |
557 | 563 | case Instruction::ICmp: |
558 | 563 | return new CompareConstantExpr(Ty, Instruction::ICmp, SubclassData, |
559 | 563 | Ops[0], Ops[1]); |
560 | 12 | case Instruction::FCmp: |
561 | 12 | return new CompareConstantExpr(Ty, Instruction::FCmp, SubclassData, |
562 | 12 | Ops[0], Ops[1]); |
563 | 1.15M | } |
564 | 1.15M | } |
565 | | }; |
566 | | |
567 | | template <class ConstantClass> class ConstantUniqueMap { |
568 | | public: |
569 | | using ValType = typename ConstantInfo<ConstantClass>::ValType; |
570 | | using TypeClass = typename ConstantInfo<ConstantClass>::TypeClass; |
571 | | using LookupKey = std::pair<TypeClass *, ValType>; |
572 | | |
573 | | /// Key and hash together, so that we compute the hash only once and reuse it. |
574 | | using LookupKeyHashed = std::pair<unsigned, LookupKey>; |
575 | | |
576 | | private: |
577 | | struct MapInfo { |
578 | | using ConstantClassInfo = DenseMapInfo<ConstantClass *>; |
579 | | |
580 | 79.1M | static inline ConstantClass *getEmptyKey() { |
581 | 79.1M | return ConstantClassInfo::getEmptyKey(); |
582 | 79.1M | } llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::getEmptyKey() Line | Count | Source | 580 | 1.07M | static inline ConstantClass *getEmptyKey() { | 581 | 1.07M | return ConstantClassInfo::getEmptyKey(); | 582 | 1.07M | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::getEmptyKey() Line | Count | Source | 580 | 718k | static inline ConstantClass *getEmptyKey() { | 581 | 718k | return ConstantClassInfo::getEmptyKey(); | 582 | 718k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::getEmptyKey() Line | Count | Source | 580 | 77.1M | static inline ConstantClass *getEmptyKey() { | 581 | 77.1M | return ConstantClassInfo::getEmptyKey(); | 582 | 77.1M | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::getEmptyKey() Line | Count | Source | 580 | 47.1k | static inline ConstantClass *getEmptyKey() { | 581 | 47.1k | return ConstantClassInfo::getEmptyKey(); | 582 | 47.1k | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::getEmptyKey() Line | Count | Source | 580 | 167k | static inline ConstantClass *getEmptyKey() { | 581 | 167k | return ConstantClassInfo::getEmptyKey(); | 582 | 167k | } |
|
583 | | |
584 | 75.1M | static inline ConstantClass *getTombstoneKey() { |
585 | 75.1M | return ConstantClassInfo::getTombstoneKey(); |
586 | 75.1M | } llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::getTombstoneKey() Line | Count | Source | 584 | 92.2k | static inline ConstantClass *getTombstoneKey() { | 585 | 92.2k | return ConstantClassInfo::getTombstoneKey(); | 586 | 92.2k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::getTombstoneKey() Line | Count | Source | 584 | 557k | static inline ConstantClass *getTombstoneKey() { | 585 | 557k | return ConstantClassInfo::getTombstoneKey(); | 586 | 557k | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::getTombstoneKey() Line | Count | Source | 584 | 33.2k | static inline ConstantClass *getTombstoneKey() { | 585 | 33.2k | return ConstantClassInfo::getTombstoneKey(); | 586 | 33.2k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::getTombstoneKey() Line | Count | Source | 584 | 73.9M | static inline ConstantClass *getTombstoneKey() { | 585 | 73.9M | return ConstantClassInfo::getTombstoneKey(); | 586 | 73.9M | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::getTombstoneKey() Line | Count | Source | 584 | 536k | static inline ConstantClass *getTombstoneKey() { | 585 | 536k | return ConstantClassInfo::getTombstoneKey(); | 586 | 536k | } |
|
587 | | |
588 | 1.18M | static unsigned getHashValue(const ConstantClass *CP) { |
589 | 1.18M | SmallVector<Constant *, 32> Storage; |
590 | 1.18M | return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage))); |
591 | 1.18M | } llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::getHashValue(llvm::ConstantExpr const*) Line | Count | Source | 588 | 1.10M | static unsigned getHashValue(const ConstantClass *CP) { | 589 | 1.10M | SmallVector<Constant *, 32> Storage; | 590 | 1.10M | return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage))); | 591 | 1.10M | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::getHashValue(llvm::InlineAsm const*) Line | Count | Source | 588 | 522 | static unsigned getHashValue(const ConstantClass *CP) { | 589 | 522 | SmallVector<Constant *, 32> Storage; | 590 | 522 | return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage))); | 591 | 522 | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::getHashValue(llvm::ConstantArray const*) Line | Count | Source | 588 | 14.2k | static unsigned getHashValue(const ConstantClass *CP) { | 589 | 14.2k | SmallVector<Constant *, 32> Storage; | 590 | 14.2k | return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage))); | 591 | 14.2k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::getHashValue(llvm::ConstantStruct const*) Line | Count | Source | 588 | 44.7k | static unsigned getHashValue(const ConstantClass *CP) { | 589 | 44.7k | SmallVector<Constant *, 32> Storage; | 590 | 44.7k | return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage))); | 591 | 44.7k | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::getHashValue(llvm::ConstantVector const*) Line | Count | Source | 588 | 19.6k | static unsigned getHashValue(const ConstantClass *CP) { | 589 | 19.6k | SmallVector<Constant *, 32> Storage; | 590 | 19.6k | return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage))); | 591 | 19.6k | } |
|
592 | | |
593 | 48.5M | static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) { |
594 | 48.5M | return LHS == RHS; |
595 | 48.5M | } llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::isEqual(llvm::InlineAsm const*, llvm::InlineAsm const*) Line | Count | Source | 593 | 189k | static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) { | 594 | 189k | return LHS == RHS; | 595 | 189k | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::isEqual(llvm::ConstantArray const*, llvm::ConstantArray const*) Line | Count | Source | 593 | 351k | static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) { | 594 | 351k | return LHS == RHS; | 595 | 351k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::isEqual(llvm::ConstantExpr const*, llvm::ConstantExpr const*) Line | Count | Source | 593 | 46.0M | static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) { | 594 | 46.0M | return LHS == RHS; | 595 | 46.0M | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::isEqual(llvm::ConstantVector const*, llvm::ConstantVector const*) Line | Count | Source | 593 | 739k | static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) { | 594 | 739k | return LHS == RHS; | 595 | 739k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::isEqual(llvm::ConstantStruct const*, llvm::ConstantStruct const*) Line | Count | Source | 593 | 1.25M | static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) { | 594 | 1.25M | return LHS == RHS; | 595 | 1.25M | } |
|
596 | | |
597 | 28.6M | static unsigned getHashValue(const LookupKey &Val) { |
598 | 28.6M | return hash_combine(Val.first, Val.second.getHash()); |
599 | 28.6M | } llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::getHashValue(std::__1::pair<llvm::ArrayType*, llvm::ConstantAggrKeyType<llvm::ConstantArray> > const&) Line | Count | Source | 597 | 45.2k | static unsigned getHashValue(const LookupKey &Val) { | 598 | 45.2k | return hash_combine(Val.first, Val.second.getHash()); | 599 | 45.2k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::getHashValue(std::__1::pair<llvm::StructType*, llvm::ConstantAggrKeyType<llvm::ConstantStruct> > const&) Line | Count | Source | 597 | 231k | static unsigned getHashValue(const LookupKey &Val) { | 598 | 231k | return hash_combine(Val.first, Val.second.getHash()); | 599 | 231k | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::getHashValue(std::__1::pair<llvm::VectorType*, llvm::ConstantAggrKeyType<llvm::ConstantVector> > const&) Line | Count | Source | 597 | 233k | static unsigned getHashValue(const LookupKey &Val) { | 598 | 233k | return hash_combine(Val.first, Val.second.getHash()); | 599 | 233k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::getHashValue(std::__1::pair<llvm::Type*, llvm::ConstantExprKeyType> const&) Line | Count | Source | 597 | 28.0M | static unsigned getHashValue(const LookupKey &Val) { | 598 | 28.0M | return hash_combine(Val.first, Val.second.getHash()); | 599 | 28.0M | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::getHashValue(std::__1::pair<llvm::PointerType*, llvm::InlineAsmKeyType> const&) Line | Count | Source | 597 | 13.3k | static unsigned getHashValue(const LookupKey &Val) { | 598 | 13.3k | return hash_combine(Val.first, Val.second.getHash()); | 599 | 13.3k | } |
|
600 | | |
601 | 28.8M | static unsigned getHashValue(const LookupKeyHashed &Val) { |
602 | 28.8M | return Val.first; |
603 | 28.8M | } llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::getHashValue(std::__1::pair<unsigned int, std::__1::pair<llvm::Type*, llvm::ConstantExprKeyType> > const&) Line | Count | Source | 601 | 28.1M | static unsigned getHashValue(const LookupKeyHashed &Val) { | 602 | 28.1M | return Val.first; | 603 | 28.1M | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::getHashValue(std::__1::pair<unsigned int, std::__1::pair<llvm::VectorType*, llvm::ConstantAggrKeyType<llvm::ConstantVector> > > const&) Line | Count | Source | 601 | 263k | static unsigned getHashValue(const LookupKeyHashed &Val) { | 602 | 263k | return Val.first; | 603 | 263k | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::getHashValue(std::__1::pair<unsigned int, std::__1::pair<llvm::PointerType*, llvm::InlineAsmKeyType> > const&) Line | Count | Source | 601 | 15.8k | static unsigned getHashValue(const LookupKeyHashed &Val) { | 602 | 15.8k | return Val.first; | 603 | 15.8k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::getHashValue(std::__1::pair<unsigned int, std::__1::pair<llvm::StructType*, llvm::ConstantAggrKeyType<llvm::ConstantStruct> > > const&) Line | Count | Source | 601 | 355k | static unsigned getHashValue(const LookupKeyHashed &Val) { | 602 | 355k | return Val.first; | 603 | 355k | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::getHashValue(std::__1::pair<unsigned int, std::__1::pair<llvm::ArrayType*, llvm::ConstantAggrKeyType<llvm::ConstantArray> > > const&) Line | Count | Source | 601 | 46.8k | static unsigned getHashValue(const LookupKeyHashed &Val) { | 602 | 46.8k | return Val.first; | 603 | 46.8k | } |
|
604 | | |
605 | 47.5M | static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) { |
606 | 47.5M | if (RHS == getEmptyKey() || 47.5M RHS == getTombstoneKey()44.7M ) |
607 | 2.97M | return false; |
608 | 44.5M | if (44.5M LHS.first != RHS->getType()44.5M ) |
609 | 8.16M | return false; |
610 | 36.4M | return LHS.second == RHS; |
611 | 47.5M | } llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::isEqual(std::__1::pair<llvm::VectorType*, llvm::ConstantAggrKeyType<llvm::ConstantVector> > const&, llvm::ConstantVector const*) Line | Count | Source | 605 | 340k | static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) { | 606 | 340k | if (RHS == getEmptyKey() || 340k RHS == getTombstoneKey()230k ) | 607 | 110k | return false; | 608 | 230k | if (230k LHS.first != RHS->getType()230k ) | 609 | 20.2k | return false; | 610 | 210k | return LHS.second == RHS; | 611 | 340k | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::isEqual(std::__1::pair<llvm::ArrayType*, llvm::ConstantAggrKeyType<llvm::ConstantArray> > const&, llvm::ConstantArray const*) Line | Count | Source | 605 | 62.4k | static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) { | 606 | 62.4k | if (RHS == getEmptyKey() || 62.4k RHS == getTombstoneKey()18.6k ) | 607 | 43.8k | return false; | 608 | 18.5k | if (18.5k LHS.first != RHS->getType()18.5k ) | 609 | 11.2k | return false; | 610 | 7.26k | return LHS.second == RHS; | 611 | 62.4k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::isEqual(std::__1::pair<llvm::StructType*, llvm::ConstantAggrKeyType<llvm::ConstantStruct> > const&, llvm::ConstantStruct const*) Line | Count | Source | 605 | 477k | static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) { | 606 | 477k | if (RHS == getEmptyKey() || 477k RHS == getTombstoneKey()128k ) | 607 | 349k | return false; | 608 | 128k | if (128k LHS.first != RHS->getType()128k ) | 609 | 65.0k | return false; | 610 | 63.3k | return LHS.second == RHS; | 611 | 477k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::isEqual(std::__1::pair<llvm::Type*, llvm::ConstantExprKeyType> const&, llvm::ConstantExpr const*) Line | Count | Source | 605 | 46.6M | static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) { | 606 | 46.6M | if (RHS == getEmptyKey() || 46.6M RHS == getTombstoneKey()44.3M ) | 607 | 2.46M | return false; | 608 | 44.1M | if (44.1M LHS.first != RHS->getType()44.1M ) | 609 | 8.06M | return false; | 610 | 36.1M | return LHS.second == RHS; | 611 | 46.6M | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::isEqual(std::__1::pair<llvm::PointerType*, llvm::InlineAsmKeyType> const&, llvm::InlineAsm const*) Line | Count | Source | 605 | 18.0k | static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) { | 606 | 18.0k | if (RHS == getEmptyKey() || 18.0k RHS == getTombstoneKey()10.3k ) | 607 | 7.70k | return false; | 608 | 10.3k | if (10.3k LHS.first != RHS->getType()10.3k ) | 609 | 1.07k | return false; | 610 | 9.31k | return LHS.second == RHS; | 611 | 18.0k | } |
|
612 | | |
613 | 47.5M | static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) { |
614 | 47.5M | return isEqual(LHS.second, RHS); |
615 | 47.5M | } llvm::ConstantUniqueMap<llvm::ConstantArray>::MapInfo::isEqual(std::__1::pair<unsigned int, std::__1::pair<llvm::ArrayType*, llvm::ConstantAggrKeyType<llvm::ConstantArray> > > const&, llvm::ConstantArray const*) Line | Count | Source | 613 | 62.4k | static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) { | 614 | 62.4k | return isEqual(LHS.second, RHS); | 615 | 62.4k | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::MapInfo::isEqual(std::__1::pair<unsigned int, std::__1::pair<llvm::PointerType*, llvm::InlineAsmKeyType> > const&, llvm::InlineAsm const*) Line | Count | Source | 613 | 18.0k | static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) { | 614 | 18.0k | return isEqual(LHS.second, RHS); | 615 | 18.0k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::MapInfo::isEqual(std::__1::pair<unsigned int, std::__1::pair<llvm::StructType*, llvm::ConstantAggrKeyType<llvm::ConstantStruct> > > const&, llvm::ConstantStruct const*) Line | Count | Source | 613 | 477k | static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) { | 614 | 477k | return isEqual(LHS.second, RHS); | 615 | 477k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo::isEqual(std::__1::pair<unsigned int, std::__1::pair<llvm::Type*, llvm::ConstantExprKeyType> > const&, llvm::ConstantExpr const*) Line | Count | Source | 613 | 46.6M | static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) { | 614 | 46.6M | return isEqual(LHS.second, RHS); | 615 | 46.6M | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::MapInfo::isEqual(std::__1::pair<unsigned int, std::__1::pair<llvm::VectorType*, llvm::ConstantAggrKeyType<llvm::ConstantVector> > > const&, llvm::ConstantVector const*) Line | Count | Source | 613 | 340k | static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) { | 614 | 340k | return isEqual(LHS.second, RHS); | 615 | 340k | } |
|
616 | | }; |
617 | | |
618 | | public: |
619 | | using MapTy = DenseSet<ConstantClass *, MapInfo>; |
620 | | |
621 | | private: |
622 | | MapTy Map; |
623 | | |
624 | | public: |
625 | 142k | typename MapTy::iterator begin() { return Map.begin(); } llvm::ConstantUniqueMap<llvm::ConstantExpr>::begin() Line | Count | Source | 625 | 35.3k | typename MapTy::iterator begin() { return Map.begin(); } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::begin() Line | Count | Source | 625 | 35.3k | typename MapTy::iterator begin() { return Map.begin(); } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::begin() Line | Count | Source | 625 | 36.2k | typename MapTy::iterator begin() { return Map.begin(); } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::begin() Line | Count | Source | 625 | 35.3k | typename MapTy::iterator begin() { return Map.begin(); } |
|
626 | 142k | typename MapTy::iterator end() { return Map.end(); } llvm::ConstantUniqueMap<llvm::ConstantStruct>::end() Line | Count | Source | 626 | 35.3k | typename MapTy::iterator end() { return Map.end(); } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::end() Line | Count | Source | 626 | 35.3k | typename MapTy::iterator end() { return Map.end(); } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::end() Line | Count | Source | 626 | 35.3k | typename MapTy::iterator end() { return Map.end(); } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::end() Line | Count | Source | 626 | 36.2k | typename MapTy::iterator end() { return Map.end(); } |
|
627 | | |
628 | 176k | void freeConstants() { |
629 | 176k | for (auto &I : Map) |
630 | 18.7k | delete I; // Asserts that use_empty(). |
631 | 176k | } llvm::ConstantUniqueMap<llvm::InlineAsm>::freeConstants() Line | Count | Source | 628 | 35.3k | void freeConstants() { | 629 | 35.3k | for (auto &I : Map) | 630 | 3.88k | delete I; // Asserts that use_empty(). | 631 | 35.3k | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::freeConstants() Line | Count | Source | 628 | 35.3k | void freeConstants() { | 629 | 35.3k | for (auto &I : Map) | 630 | 402 | delete I; // Asserts that use_empty(). | 631 | 35.3k | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::freeConstants() Line | Count | Source | 628 | 35.3k | void freeConstants() { | 629 | 35.3k | for (auto &I : Map) | 630 | 9.26k | delete I; // Asserts that use_empty(). | 631 | 35.3k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::freeConstants() Line | Count | Source | 628 | 35.3k | void freeConstants() { | 629 | 35.3k | for (auto &I : Map) | 630 | 2.09k | delete I; // Asserts that use_empty(). | 631 | 35.3k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::freeConstants() Line | Count | Source | 628 | 35.3k | void freeConstants() { | 629 | 35.3k | for (auto &I : Map) | 630 | 3.14k | delete I; // Asserts that use_empty(). | 631 | 35.3k | } |
|
632 | | |
633 | | private: |
634 | 1.42M | ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) { |
635 | 1.42M | ConstantClass *Result = V.create(Ty); |
636 | 1.42M | |
637 | 1.42M | assert(Result->getType() == Ty && "Type specified is not correct!"); |
638 | 1.42M | Map.insert_as(Result, HashKey); |
639 | 1.42M | |
640 | 1.42M | return Result; |
641 | 1.42M | } llvm::ConstantUniqueMap<llvm::ConstantArray>::create(llvm::ArrayType*, llvm::ConstantAggrKeyType<llvm::ConstantArray>, std::__1::pair<unsigned int, std::__1::pair<llvm::ArrayType*, llvm::ConstantAggrKeyType<llvm::ConstantArray> > >&) Line | Count | Source | 634 | 27.2k | ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) { | 635 | 27.2k | ConstantClass *Result = V.create(Ty); | 636 | 27.2k | | 637 | 27.2k | assert(Result->getType() == Ty && "Type specified is not correct!"); | 638 | 27.2k | Map.insert_as(Result, HashKey); | 639 | 27.2k | | 640 | 27.2k | return Result; | 641 | 27.2k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::create(llvm::Type*, llvm::ConstantExprKeyType, std::__1::pair<unsigned int, std::__1::pair<llvm::Type*, llvm::ConstantExprKeyType> >&) Line | Count | Source | 634 | 1.15M | ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) { | 635 | 1.15M | ConstantClass *Result = V.create(Ty); | 636 | 1.15M | | 637 | 1.15M | assert(Result->getType() == Ty && "Type specified is not correct!"); | 638 | 1.15M | Map.insert_as(Result, HashKey); | 639 | 1.15M | | 640 | 1.15M | return Result; | 641 | 1.15M | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::create(llvm::PointerType*, llvm::InlineAsmKeyType, std::__1::pair<unsigned int, std::__1::pair<llvm::PointerType*, llvm::InlineAsmKeyType> >&) Line | Count | Source | 634 | 4.62k | ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) { | 635 | 4.62k | ConstantClass *Result = V.create(Ty); | 636 | 4.62k | | 637 | 4.62k | assert(Result->getType() == Ty && "Type specified is not correct!"); | 638 | 4.62k | Map.insert_as(Result, HashKey); | 639 | 4.62k | | 640 | 4.62k | return Result; | 641 | 4.62k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::create(llvm::StructType*, llvm::ConstantAggrKeyType<llvm::ConstantStruct>, std::__1::pair<unsigned int, std::__1::pair<llvm::StructType*, llvm::ConstantAggrKeyType<llvm::ConstantStruct> > >&) Line | Count | Source | 634 | 180k | ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) { | 635 | 180k | ConstantClass *Result = V.create(Ty); | 636 | 180k | | 637 | 180k | assert(Result->getType() == Ty && "Type specified is not correct!"); | 638 | 180k | Map.insert_as(Result, HashKey); | 639 | 180k | | 640 | 180k | return Result; | 641 | 180k | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::create(llvm::VectorType*, llvm::ConstantAggrKeyType<llvm::ConstantVector>, std::__1::pair<unsigned int, std::__1::pair<llvm::VectorType*, llvm::ConstantAggrKeyType<llvm::ConstantVector> > >&) Line | Count | Source | 634 | 60.7k | ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) { | 635 | 60.7k | ConstantClass *Result = V.create(Ty); | 636 | 60.7k | | 637 | 60.7k | assert(Result->getType() == Ty && "Type specified is not correct!"); | 638 | 60.7k | Map.insert_as(Result, HashKey); | 639 | 60.7k | | 640 | 60.7k | return Result; | 641 | 60.7k | } |
|
642 | | |
643 | | public: |
644 | | /// Return the specified constant from the map, creating it if necessary. |
645 | 27.4M | ConstantClass *getOrCreate(TypeClass *Ty, ValType V) { |
646 | 27.4M | LookupKey Key(Ty, V); |
647 | 27.4M | /// Hash once, and reuse it for the lookup and the insertion if needed. |
648 | 27.4M | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); |
649 | 27.4M | |
650 | 27.4M | ConstantClass *Result = nullptr; |
651 | 27.4M | |
652 | 27.4M | auto I = Map.find_as(Lookup); |
653 | 27.4M | if (I == Map.end()) |
654 | 1.42M | Result = create(Ty, V, Lookup); |
655 | 27.4M | else |
656 | 25.9M | Result = *I; |
657 | 27.4M | assert(Result && "Unexpected nullptr"); |
658 | 27.4M | |
659 | 27.4M | return Result; |
660 | 27.4M | } llvm::ConstantUniqueMap<llvm::ConstantArray>::getOrCreate(llvm::ArrayType*, llvm::ConstantAggrKeyType<llvm::ConstantArray>) Line | Count | Source | 645 | 30.3k | ConstantClass *getOrCreate(TypeClass *Ty, ValType V) { | 646 | 30.3k | LookupKey Key(Ty, V); | 647 | 30.3k | /// Hash once, and reuse it for the lookup and the insertion if needed. | 648 | 30.3k | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 649 | 30.3k | | 650 | 30.3k | ConstantClass *Result = nullptr; | 651 | 30.3k | | 652 | 30.3k | auto I = Map.find_as(Lookup); | 653 | 30.3k | if (I == Map.end()) | 654 | 27.2k | Result = create(Ty, V, Lookup); | 655 | 30.3k | else | 656 | 3.06k | Result = *I; | 657 | 30.3k | assert(Result && "Unexpected nullptr"); | 658 | 30.3k | | 659 | 30.3k | return Result; | 660 | 30.3k | } |
llvm::ConstantUniqueMap<llvm::InlineAsm>::getOrCreate(llvm::PointerType*, llvm::InlineAsmKeyType) Line | Count | Source | 645 | 12.8k | ConstantClass *getOrCreate(TypeClass *Ty, ValType V) { | 646 | 12.8k | LookupKey Key(Ty, V); | 647 | 12.8k | /// Hash once, and reuse it for the lookup and the insertion if needed. | 648 | 12.8k | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 649 | 12.8k | | 650 | 12.8k | ConstantClass *Result = nullptr; | 651 | 12.8k | | 652 | 12.8k | auto I = Map.find_as(Lookup); | 653 | 12.8k | if (I == Map.end()) | 654 | 4.62k | Result = create(Ty, V, Lookup); | 655 | 12.8k | else | 656 | 8.19k | Result = *I; | 657 | 12.8k | assert(Result && "Unexpected nullptr"); | 658 | 12.8k | | 659 | 12.8k | return Result; | 660 | 12.8k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::getOrCreate(llvm::Type*, llvm::ConstantExprKeyType) Line | Count | Source | 645 | 26.9M | ConstantClass *getOrCreate(TypeClass *Ty, ValType V) { | 646 | 26.9M | LookupKey Key(Ty, V); | 647 | 26.9M | /// Hash once, and reuse it for the lookup and the insertion if needed. | 648 | 26.9M | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 649 | 26.9M | | 650 | 26.9M | ConstantClass *Result = nullptr; | 651 | 26.9M | | 652 | 26.9M | auto I = Map.find_as(Lookup); | 653 | 26.9M | if (I == Map.end()) | 654 | 1.15M | Result = create(Ty, V, Lookup); | 655 | 26.9M | else | 656 | 25.8M | Result = *I; | 657 | 26.9M | assert(Result && "Unexpected nullptr"); | 658 | 26.9M | | 659 | 26.9M | return Result; | 660 | 26.9M | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::getOrCreate(llvm::VectorType*, llvm::ConstantAggrKeyType<llvm::ConstantVector>) Line | Count | Source | 645 | 213k | ConstantClass *getOrCreate(TypeClass *Ty, ValType V) { | 646 | 213k | LookupKey Key(Ty, V); | 647 | 213k | /// Hash once, and reuse it for the lookup and the insertion if needed. | 648 | 213k | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 649 | 213k | | 650 | 213k | ConstantClass *Result = nullptr; | 651 | 213k | | 652 | 213k | auto I = Map.find_as(Lookup); | 653 | 213k | if (I == Map.end()) | 654 | 60.7k | Result = create(Ty, V, Lookup); | 655 | 213k | else | 656 | 153k | Result = *I; | 657 | 213k | assert(Result && "Unexpected nullptr"); | 658 | 213k | | 659 | 213k | return Result; | 660 | 213k | } |
llvm::ConstantUniqueMap<llvm::ConstantStruct>::getOrCreate(llvm::StructType*, llvm::ConstantAggrKeyType<llvm::ConstantStruct>) Line | Count | Source | 645 | 186k | ConstantClass *getOrCreate(TypeClass *Ty, ValType V) { | 646 | 186k | LookupKey Key(Ty, V); | 647 | 186k | /// Hash once, and reuse it for the lookup and the insertion if needed. | 648 | 186k | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 649 | 186k | | 650 | 186k | ConstantClass *Result = nullptr; | 651 | 186k | | 652 | 186k | auto I = Map.find_as(Lookup); | 653 | 186k | if (I == Map.end()) | 654 | 180k | Result = create(Ty, V, Lookup); | 655 | 186k | else | 656 | 6.04k | Result = *I; | 657 | 186k | assert(Result && "Unexpected nullptr"); | 658 | 186k | | 659 | 186k | return Result; | 660 | 186k | } |
|
661 | | |
662 | | /// Remove this constant from the map |
663 | 361k | void remove(ConstantClass *CP) { |
664 | 361k | typename MapTy::iterator I = Map.find(CP); |
665 | 361k | assert(I != Map.end() && "Constant not found in constant table!"); |
666 | 361k | assert(*I == CP && "Didn't find correct element?"); |
667 | 361k | Map.erase(I); |
668 | 361k | } Unexecuted instantiation: llvm::ConstantUniqueMap<llvm::InlineAsm>::remove(llvm::InlineAsm*) llvm::ConstantUniqueMap<llvm::ConstantStruct>::remove(llvm::ConstantStruct*) Line | Count | Source | 663 | 20.4k | void remove(ConstantClass *CP) { | 664 | 20.4k | typename MapTy::iterator I = Map.find(CP); | 665 | 20.4k | assert(I != Map.end() && "Constant not found in constant table!"); | 666 | 20.4k | assert(*I == CP && "Didn't find correct element?"); | 667 | 20.4k | Map.erase(I); | 668 | 20.4k | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::remove(llvm::ConstantExpr*) Line | Count | Source | 663 | 332k | void remove(ConstantClass *CP) { | 664 | 332k | typename MapTy::iterator I = Map.find(CP); | 665 | 332k | assert(I != Map.end() && "Constant not found in constant table!"); | 666 | 332k | assert(*I == CP && "Didn't find correct element?"); | 667 | 332k | Map.erase(I); | 668 | 332k | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::remove(llvm::ConstantVector*) Line | Count | Source | 663 | 66 | void remove(ConstantClass *CP) { | 664 | 66 | typename MapTy::iterator I = Map.find(CP); | 665 | 66 | assert(I != Map.end() && "Constant not found in constant table!"); | 666 | 66 | assert(*I == CP && "Didn't find correct element?"); | 667 | 66 | Map.erase(I); | 668 | 66 | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::remove(llvm::ConstantArray*) Line | Count | Source | 663 | 8.44k | void remove(ConstantClass *CP) { | 664 | 8.44k | typename MapTy::iterator I = Map.find(CP); | 665 | 8.44k | assert(I != Map.end() && "Constant not found in constant table!"); | 666 | 8.44k | assert(*I == CP && "Didn't find correct element?"); | 667 | 8.44k | Map.erase(I); | 668 | 8.44k | } |
|
669 | | |
670 | | ConstantClass *replaceOperandsInPlace(ArrayRef<Constant *> Operands, |
671 | | ConstantClass *CP, Value *From, |
672 | | Constant *To, unsigned NumUpdated = 0, |
673 | 35.4k | unsigned OperandNo = ~0u) { |
674 | 35.4k | LookupKey Key(CP->getType(), ValType(Operands, CP)); |
675 | 35.4k | /// Hash once, and reuse it for the lookup and the insertion if needed. |
676 | 35.4k | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); |
677 | 35.4k | |
678 | 35.4k | auto I = Map.find_as(Lookup); |
679 | 35.4k | if (I != Map.end()) |
680 | 29.1k | return *I; |
681 | 35.4k | |
682 | 35.4k | // Update to the new value. Optimize for the case when we have a single |
683 | 35.4k | // operand that we're changing, but handle bulk updates efficiently. |
684 | 6.31k | remove(CP); |
685 | 6.31k | if (NumUpdated == 16.31k ) { |
686 | 6.30k | assert(OperandNo < CP->getNumOperands() && "Invalid index"); |
687 | 6.30k | assert(CP->getOperand(OperandNo) != To && "I didn't contain From!"); |
688 | 6.30k | CP->setOperand(OperandNo, To); |
689 | 6.31k | } else { |
690 | 55 | for (unsigned I = 0, E = CP->getNumOperands(); I != E55 ; ++I44 ) |
691 | 44 | if (44 CP->getOperand(I) == From44 ) |
692 | 27 | CP->setOperand(I, To); |
693 | 11 | } |
694 | 6.31k | Map.insert_as(CP, Lookup); |
695 | 6.31k | return nullptr; |
696 | 35.4k | } llvm::ConstantUniqueMap<llvm::ConstantStruct>::replaceOperandsInPlace(llvm::ArrayRef<llvm::Constant*>, llvm::ConstantStruct*, llvm::Value*, llvm::Constant*, unsigned int, unsigned int) Line | Count | Source | 673 | 40 | unsigned OperandNo = ~0u) { | 674 | 40 | LookupKey Key(CP->getType(), ValType(Operands, CP)); | 675 | 40 | /// Hash once, and reuse it for the lookup and the insertion if needed. | 676 | 40 | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 677 | 40 | | 678 | 40 | auto I = Map.find_as(Lookup); | 679 | 40 | if (I != Map.end()) | 680 | 0 | return *I; | 681 | 40 | | 682 | 40 | // Update to the new value. Optimize for the case when we have a single | 683 | 40 | // operand that we're changing, but handle bulk updates efficiently. | 684 | 40 | remove(CP); | 685 | 40 | if (NumUpdated == 140 ) { | 686 | 32 | assert(OperandNo < CP->getNumOperands() && "Invalid index"); | 687 | 32 | assert(CP->getOperand(OperandNo) != To && "I didn't contain From!"); | 688 | 32 | CP->setOperand(OperandNo, To); | 689 | 40 | } else { | 690 | 32 | for (unsigned I = 0, E = CP->getNumOperands(); I != E32 ; ++I24 ) | 691 | 24 | if (24 CP->getOperand(I) == From24 ) | 692 | 16 | CP->setOperand(I, To); | 693 | 8 | } | 694 | 40 | Map.insert_as(CP, Lookup); | 695 | 40 | return nullptr; | 696 | 40 | } |
llvm::ConstantUniqueMap<llvm::ConstantExpr>::replaceOperandsInPlace(llvm::ArrayRef<llvm::Constant*>, llvm::ConstantExpr*, llvm::Value*, llvm::Constant*, unsigned int, unsigned int) Line | Count | Source | 673 | 34.7k | unsigned OperandNo = ~0u) { | 674 | 34.7k | LookupKey Key(CP->getType(), ValType(Operands, CP)); | 675 | 34.7k | /// Hash once, and reuse it for the lookup and the insertion if needed. | 676 | 34.7k | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 677 | 34.7k | | 678 | 34.7k | auto I = Map.find_as(Lookup); | 679 | 34.7k | if (I != Map.end()) | 680 | 29.0k | return *I; | 681 | 34.7k | | 682 | 34.7k | // Update to the new value. Optimize for the case when we have a single | 683 | 34.7k | // operand that we're changing, but handle bulk updates efficiently. | 684 | 5.63k | remove(CP); | 685 | 5.63k | if (NumUpdated == 15.63k ) { | 686 | 5.63k | assert(OperandNo < CP->getNumOperands() && "Invalid index"); | 687 | 5.63k | assert(CP->getOperand(OperandNo) != To && "I didn't contain From!"); | 688 | 5.63k | CP->setOperand(OperandNo, To); | 689 | 5.63k | } else { | 690 | 3 | for (unsigned I = 0, E = CP->getNumOperands(); I != E3 ; ++I2 ) | 691 | 2 | if (2 CP->getOperand(I) == From2 ) | 692 | 2 | CP->setOperand(I, To); | 693 | 1 | } | 694 | 5.63k | Map.insert_as(CP, Lookup); | 695 | 5.63k | return nullptr; | 696 | 34.7k | } |
llvm::ConstantUniqueMap<llvm::ConstantVector>::replaceOperandsInPlace(llvm::ArrayRef<llvm::Constant*>, llvm::ConstantVector*, llvm::Value*, llvm::Constant*, unsigned int, unsigned int) Line | Count | Source | 673 | 6 | unsigned OperandNo = ~0u) { | 674 | 6 | LookupKey Key(CP->getType(), ValType(Operands, CP)); | 675 | 6 | /// Hash once, and reuse it for the lookup and the insertion if needed. | 676 | 6 | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 677 | 6 | | 678 | 6 | auto I = Map.find_as(Lookup); | 679 | 6 | if (I != Map.end()) | 680 | 0 | return *I; | 681 | 6 | | 682 | 6 | // Update to the new value. Optimize for the case when we have a single | 683 | 6 | // operand that we're changing, but handle bulk updates efficiently. | 684 | 6 | remove(CP); | 685 | 6 | if (NumUpdated == 16 ) { | 686 | 6 | assert(OperandNo < CP->getNumOperands() && "Invalid index"); | 687 | 6 | assert(CP->getOperand(OperandNo) != To && "I didn't contain From!"); | 688 | 6 | CP->setOperand(OperandNo, To); | 689 | 6 | } else { | 690 | 0 | for (unsigned I = 0, E = CP->getNumOperands(); I != E0 ; ++I0 ) | 691 | 0 | if (0 CP->getOperand(I) == From0 ) | 692 | 0 | CP->setOperand(I, To); | 693 | 0 | } | 694 | 6 | Map.insert_as(CP, Lookup); | 695 | 6 | return nullptr; | 696 | 6 | } |
llvm::ConstantUniqueMap<llvm::ConstantArray>::replaceOperandsInPlace(llvm::ArrayRef<llvm::Constant*>, llvm::ConstantArray*, llvm::Value*, llvm::Constant*, unsigned int, unsigned int) Line | Count | Source | 673 | 635 | unsigned OperandNo = ~0u) { | 674 | 635 | LookupKey Key(CP->getType(), ValType(Operands, CP)); | 675 | 635 | /// Hash once, and reuse it for the lookup and the insertion if needed. | 676 | 635 | LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key); | 677 | 635 | | 678 | 635 | auto I = Map.find_as(Lookup); | 679 | 635 | if (I != Map.end()) | 680 | 4 | return *I; | 681 | 635 | | 682 | 635 | // Update to the new value. Optimize for the case when we have a single | 683 | 635 | // operand that we're changing, but handle bulk updates efficiently. | 684 | 631 | remove(CP); | 685 | 631 | if (NumUpdated == 1631 ) { | 686 | 629 | assert(OperandNo < CP->getNumOperands() && "Invalid index"); | 687 | 629 | assert(CP->getOperand(OperandNo) != To && "I didn't contain From!"); | 688 | 629 | CP->setOperand(OperandNo, To); | 689 | 631 | } else { | 690 | 20 | for (unsigned I = 0, E = CP->getNumOperands(); I != E20 ; ++I18 ) | 691 | 18 | if (18 CP->getOperand(I) == From18 ) | 692 | 9 | CP->setOperand(I, To); | 693 | 2 | } | 694 | 631 | Map.insert_as(CP, Lookup); | 695 | 631 | return nullptr; | 696 | 635 | } |
|
697 | | |
698 | | void dump() const { DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n"); } |
699 | | }; |
700 | | |
701 | | } // end namespace llvm |
702 | | |
703 | | #endif // LLVM_LIB_IR_CONSTANTSCONTEXT_H |